chrome: Add setting for controlling the status bubble (fixes isse #3279)
This change adds `CefBrowserSettings.chrome_status_bubble` for controlling whether the Chrome status bubble will be used. Testable in cefclient by passing the `--hide-chrome-status-bubble` command-line flag.
This commit is contained in:
parent
1eab4322f8
commit
4615fffafb
|
@ -42,13 +42,13 @@
|
|||
// way that may cause binary incompatibility with other builds. The universal
|
||||
// hash value will change if any platform is affected whereas the platform hash
|
||||
// values will change only if that particular platform is affected.
|
||||
#define CEF_API_HASH_UNIVERSAL "2aa3d374f5c27a433acba25d772b3a67fb1c528a"
|
||||
#define CEF_API_HASH_UNIVERSAL "5065a3791a6b09aac128efd3131b77ac38a4257a"
|
||||
#if defined(OS_WIN)
|
||||
#define CEF_API_HASH_PLATFORM "acdae91db336230e00c4e8863236fd479576249f"
|
||||
#define CEF_API_HASH_PLATFORM "6402341997737ba956460d92af756a3b9e59d0f0"
|
||||
#elif defined(OS_MAC)
|
||||
#define CEF_API_HASH_PLATFORM "6cdb410709486a7e78bf5876e9ca4a79e4553a30"
|
||||
#define CEF_API_HASH_PLATFORM "cd4c53d8024e52d2041de8a49db69c69edd8e62b"
|
||||
#elif defined(OS_LINUX)
|
||||
#define CEF_API_HASH_PLATFORM "3b89d9dab5020373d90525066de3166d0b949f25"
|
||||
#define CEF_API_HASH_PLATFORM "bd498b3ef328a60a11eae6871a13b7c517e583f1"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -520,7 +520,7 @@ typedef struct _cef_browser_settings_t {
|
|||
///
|
||||
int windowless_frame_rate;
|
||||
|
||||
// The below values map to WebPreferences settings.
|
||||
// BEGIN values that map to WebPreferences settings.
|
||||
|
||||
///
|
||||
// Font settings.
|
||||
|
@ -622,6 +622,8 @@ typedef struct _cef_browser_settings_t {
|
|||
///
|
||||
cef_state_t webgl;
|
||||
|
||||
// END values that map to WebPreferences settings.
|
||||
|
||||
///
|
||||
// Background color used for the browser before a document is loaded and when
|
||||
// no document color is specified. The alpha component must be either fully
|
||||
|
@ -641,6 +643,13 @@ typedef struct _cef_browser_settings_t {
|
|||
// empty then "en-US,en" will be used.
|
||||
///
|
||||
cef_string_t accept_language_list;
|
||||
|
||||
///
|
||||
// Controls whether the Chrome status bubble will be used. Only supported with
|
||||
// the Chrome runtime. For details about the status bubble see
|
||||
// https://www.chromium.org/user-experience/status-bubble/
|
||||
///
|
||||
cef_state_t chrome_status_bubble;
|
||||
} cef_browser_settings_t;
|
||||
|
||||
///
|
||||
|
|
|
@ -718,6 +718,8 @@ struct CefBrowserSettingsTraits {
|
|||
cef_string_set(src->accept_language_list.str,
|
||||
src->accept_language_list.length,
|
||||
&target->accept_language_list, copy);
|
||||
|
||||
target->chrome_status_bubble = src->chrome_status_bubble;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -41,6 +41,12 @@ class BrowserDelegate : public content::WebContentsDelegate {
|
|||
// Add or remove ownership of the WebContents.
|
||||
virtual void SetAsDelegate(content::WebContents* web_contents,
|
||||
bool set_delegate) = 0;
|
||||
|
||||
// Return true to show the status bubble. This should consistently return the
|
||||
// same value for the lifespan of a Browser.
|
||||
virtual bool ShowStatusBubble(bool show_by_default) {
|
||||
return show_by_default;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace cef
|
||||
|
|
|
@ -72,6 +72,22 @@ void ChromeBrowserDelegate::SetAsDelegate(content::WebContents* web_contents,
|
|||
request_context_impl);
|
||||
}
|
||||
|
||||
bool ChromeBrowserDelegate::ShowStatusBubble(bool show_by_default) {
|
||||
if (!show_status_bubble_.has_value()) {
|
||||
show_status_bubble_ = show_by_default;
|
||||
if (auto browser = ChromeBrowserHostImpl::GetBrowserForBrowser(browser_)) {
|
||||
const auto& state = browser->settings().chrome_status_bubble;
|
||||
if (show_by_default && state == STATE_DISABLED) {
|
||||
show_status_bubble_ = false;
|
||||
} else if (!show_by_default && state == STATE_ENABLED) {
|
||||
show_status_bubble_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return *show_status_bubble_;
|
||||
}
|
||||
|
||||
void ChromeBrowserDelegate::WebContentsCreated(
|
||||
content::WebContents* source_contents,
|
||||
int opener_render_process_id,
|
||||
|
|
|
@ -51,6 +51,7 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
|||
void OnWebContentsCreated(content::WebContents* new_contents) override;
|
||||
void SetAsDelegate(content::WebContents* web_contents,
|
||||
bool set_delegate) override;
|
||||
bool ShowStatusBubble(bool show_by_default) override;
|
||||
|
||||
// WebContentsDelegate methods:
|
||||
void WebContentsCreated(content::WebContents* source_contents,
|
||||
|
@ -109,6 +110,8 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
|||
|
||||
// Used when creating a new browser host.
|
||||
const CefBrowserCreateParams create_params_;
|
||||
|
||||
absl::optional<bool> show_status_bubble_;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_DELEGATE_H_
|
||||
|
|
|
@ -91,6 +91,14 @@ CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForGlobalId(
|
|||
return static_cast<ChromeBrowserHostImpl*>(browser.get());
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForBrowser(
|
||||
const Browser* browser) {
|
||||
REQUIRE_CHROME_RUNTIME();
|
||||
return GetBrowserForContents(
|
||||
browser->tab_strip_model()->GetActiveWebContents());
|
||||
}
|
||||
|
||||
ChromeBrowserHostImpl::~ChromeBrowserHostImpl() = default;
|
||||
|
||||
void ChromeBrowserHostImpl::AddNewContents(
|
||||
|
|
|
@ -47,6 +47,9 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
|||
// Returns the browser associated with the specified global ID.
|
||||
static CefRefPtr<ChromeBrowserHostImpl> GetBrowserForGlobalId(
|
||||
const content::GlobalRenderFrameHostId& global_id);
|
||||
// Returns the browser associated with the specified Browser.
|
||||
static CefRefPtr<ChromeBrowserHostImpl> GetBrowserForBrowser(
|
||||
const Browser* browser);
|
||||
|
||||
~ChromeBrowserHostImpl() override;
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ index 9e534ff1683f1..de406f5879be0 100644
|
|||
return false;
|
||||
}
|
||||
diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc
|
||||
index 04e327d970b87..0b808a691eb49 100644
|
||||
index 04e327d970b87..6bd83131116d9 100644
|
||||
--- chrome/browser/ui/browser.cc
|
||||
+++ chrome/browser/ui/browser.cc
|
||||
@@ -262,6 +262,20 @@
|
||||
@@ -262,6 +262,25 @@
|
||||
#include "components/captive_portal/content/captive_portal_tab_helper.h"
|
||||
#endif
|
||||
|
||||
|
@ -29,15 +29,20 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
+ if (cef_browser_delegate_) { \
|
||||
+ return cef_browser_delegate_->name(__VA_ARGS__); \
|
||||
+ }
|
||||
+#define CALL_CEF_DELEGATE_RESULT(name, result, ...) \
|
||||
+ if (cef_browser_delegate_) { \
|
||||
+ result = cef_browser_delegate_->name(__VA_ARGS__); \
|
||||
+ }
|
||||
+#else // !BUILDFLAG(ENABLE_CEF)
|
||||
+#define CALL_CEF_DELEGATE(name, ...)
|
||||
+#define CALL_CEF_DELEGATE_RETURN(name, ...)
|
||||
+#define CALL_CEF_DELEGATE_RESULT(name, result, ...)
|
||||
+#endif
|
||||
+
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
#include "chrome/browser/extensions/extension_browser_window_helper.h"
|
||||
#endif
|
||||
@@ -504,6 +518,13 @@ Browser::Browser(const CreateParams& params)
|
||||
@@ -504,6 +523,13 @@ Browser::Browser(const CreateParams& params)
|
||||
|
||||
tab_strip_model_->AddObserver(this);
|
||||
|
||||
|
@ -51,7 +56,7 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
location_bar_model_ = std::make_unique<LocationBarModelImpl>(
|
||||
location_bar_model_delegate_.get(), content::kMaxURLDisplayChars);
|
||||
|
||||
@@ -1327,6 +1348,14 @@ content::KeyboardEventProcessingResult Browser::PreHandleKeyboardEvent(
|
||||
@@ -1327,6 +1353,14 @@ content::KeyboardEventProcessingResult Browser::PreHandleKeyboardEvent(
|
||||
if (exclusive_access_manager_->HandleUserKeyEvent(event))
|
||||
return content::KeyboardEventProcessingResult::HANDLED;
|
||||
|
||||
|
@ -66,7 +71,7 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
return window()->PreHandleKeyboardEvent(event);
|
||||
}
|
||||
|
||||
@@ -1334,8 +1363,18 @@ bool Browser::HandleKeyboardEvent(content::WebContents* source,
|
||||
@@ -1334,8 +1368,18 @@ bool Browser::HandleKeyboardEvent(content::WebContents* source,
|
||||
const NativeWebKeyboardEvent& event) {
|
||||
DevToolsWindow* devtools_window =
|
||||
DevToolsWindow::GetInstanceForInspectedWebContents(source);
|
||||
|
@ -87,7 +92,7 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
}
|
||||
|
||||
bool Browser::TabsNeedBeforeUnloadFired() {
|
||||
@@ -1540,6 +1579,14 @@ WebContents* Browser::OpenURLFromTab(WebContents* source,
|
||||
@@ -1540,6 +1584,14 @@ WebContents* Browser::OpenURLFromTab(WebContents* source,
|
||||
return window->OpenURLFromTab(source, params);
|
||||
}
|
||||
|
||||
|
@ -102,7 +107,7 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
NavigateParams nav_params(this, params.url, params.transition);
|
||||
nav_params.FillNavigateParamsFromOpenURLParams(params);
|
||||
nav_params.source_contents = source;
|
||||
@@ -1639,6 +1686,15 @@ void Browser::AddNewContents(WebContents* source,
|
||||
@@ -1639,6 +1691,15 @@ void Browser::AddNewContents(WebContents* source,
|
||||
source, disposition);
|
||||
}
|
||||
|
||||
|
@ -118,7 +123,7 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
chrome::AddWebContents(this, source, std::move(new_contents), target_url,
|
||||
disposition, initial_rect);
|
||||
}
|
||||
@@ -1657,6 +1713,8 @@ void Browser::LoadingStateChanged(WebContents* source,
|
||||
@@ -1657,6 +1718,8 @@ void Browser::LoadingStateChanged(WebContents* source,
|
||||
bool should_show_loading_ui) {
|
||||
ScheduleUIUpdate(source, content::INVALIDATE_TYPE_LOAD);
|
||||
UpdateWindowForLoadingStateChanged(source, should_show_loading_ui);
|
||||
|
@ -127,7 +132,7 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
}
|
||||
|
||||
void Browser::CloseContents(WebContents* source) {
|
||||
@@ -1684,6 +1742,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
|
||||
@@ -1684,6 +1747,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
|
||||
}
|
||||
|
||||
void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
||||
|
@ -136,7 +141,7 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
if (!GetStatusBubble())
|
||||
return;
|
||||
|
||||
@@ -1691,6 +1751,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
||||
@@ -1691,6 +1756,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
||||
GetStatusBubble()->SetURL(url);
|
||||
}
|
||||
|
||||
|
@ -154,7 +159,7 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
void Browser::ContentsMouseEvent(WebContents* source,
|
||||
bool motion,
|
||||
bool exited) {
|
||||
@@ -1807,6 +1878,10 @@ void Browser::WebContentsCreated(WebContents* source_contents,
|
||||
@@ -1807,6 +1883,10 @@ void Browser::WebContentsCreated(WebContents* source_contents,
|
||||
|
||||
// Make the tab show up in the task manager.
|
||||
task_manager::WebContentsTags::CreateForTabContents(new_contents);
|
||||
|
@ -165,7 +170,7 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
}
|
||||
|
||||
void Browser::PortalWebContentsCreated(WebContents* portal_web_contents) {
|
||||
@@ -1851,6 +1926,8 @@ void Browser::RendererResponsive(
|
||||
@@ -1851,6 +1931,8 @@ void Browser::RendererResponsive(
|
||||
void Browser::DidNavigatePrimaryMainFramePostCommit(WebContents* web_contents) {
|
||||
if (web_contents == tab_strip_model_->GetActiveWebContents())
|
||||
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
|
||||
|
@ -174,7 +179,7 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
}
|
||||
|
||||
content::JavaScriptDialogManager* Browser::GetJavaScriptDialogManager(
|
||||
@@ -1906,11 +1983,15 @@ void Browser::EnterFullscreenModeForTab(
|
||||
@@ -1906,11 +1988,15 @@ void Browser::EnterFullscreenModeForTab(
|
||||
const blink::mojom::FullscreenOptions& options) {
|
||||
exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab(
|
||||
requesting_frame, options.display_id);
|
||||
|
@ -190,7 +195,29 @@ index 04e327d970b87..0b808a691eb49 100644
|
|||
}
|
||||
|
||||
bool Browser::IsFullscreenForTabOrPending(const WebContents* web_contents) {
|
||||
@@ -2753,6 +2834,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
|
||||
@@ -2620,13 +2706,20 @@ void Browser::RemoveScheduledUpdatesFor(WebContents* contents) {
|
||||
// Browser, Getters for UI (private):
|
||||
|
||||
StatusBubble* Browser::GetStatusBubble() {
|
||||
+ bool show_by_default = true;
|
||||
+
|
||||
// In kiosk and exclusive app mode we want to always hide the status bubble.
|
||||
if (chrome::IsRunningInAppMode() ||
|
||||
(base::FeatureList::IsEnabled(features::kRemoveStatusBarInWebApps) &&
|
||||
web_app::AppBrowserController::IsWebApp(this))) {
|
||||
- return nullptr;
|
||||
+ show_by_default = false;
|
||||
}
|
||||
|
||||
+ bool show = show_by_default;
|
||||
+ CALL_CEF_DELEGATE_RESULT(ShowStatusBubble, show, show_by_default);
|
||||
+ if (!show)
|
||||
+ return nullptr;
|
||||
+
|
||||
return window_ ? window_->GetStatusBubble() : nullptr;
|
||||
}
|
||||
|
||||
@@ -2753,6 +2846,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
|
||||
content_translate_driver->RemoveTranslationObserver(this);
|
||||
BookmarkTabHelper::FromWebContents(web_contents)->RemoveObserver(this);
|
||||
}
|
||||
|
|
|
@ -43,13 +43,7 @@ cef_color_t ParseColor(const std::string& color) {
|
|||
MainContextImpl::MainContextImpl(CefRefPtr<CefCommandLine> command_line,
|
||||
bool terminate_when_all_windows_closed)
|
||||
: command_line_(command_line),
|
||||
terminate_when_all_windows_closed_(terminate_when_all_windows_closed),
|
||||
initialized_(false),
|
||||
shutdown_(false),
|
||||
background_color_(0),
|
||||
browser_background_color_(0),
|
||||
windowless_frame_rate_(0),
|
||||
use_views_(false) {
|
||||
terminate_when_all_windows_closed_(terminate_when_all_windows_closed) {
|
||||
DCHECK(command_line_.get());
|
||||
|
||||
// Set the main URL.
|
||||
|
@ -206,6 +200,11 @@ void MainContextImpl::PopulateBrowserSettings(CefBrowserSettings* settings) {
|
|||
|
||||
if (browser_background_color_ != 0)
|
||||
settings->background_color = browser_background_color_;
|
||||
|
||||
if (use_chrome_runtime_ &&
|
||||
command_line_->HasSwitch(switches::kHideChromeStatusBubble)) {
|
||||
settings->chrome_status_bubble = STATE_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
void MainContextImpl::PopulateOsrSettings(OsrRendererSettings* settings) {
|
||||
|
|
|
@ -64,17 +64,16 @@ class MainContextImpl : public MainContext {
|
|||
// Track context state. Accessing these variables from multiple threads is
|
||||
// safe because only a single thread will exist at the time that they're set
|
||||
// (during context initialization and shutdown).
|
||||
bool initialized_;
|
||||
bool shutdown_;
|
||||
bool initialized_ = false;
|
||||
bool shutdown_ = false;
|
||||
|
||||
std::string main_url_;
|
||||
cef_color_t background_color_;
|
||||
cef_color_t browser_background_color_;
|
||||
cef_color_t background_color_ = 0;
|
||||
cef_color_t browser_background_color_ = 0;
|
||||
bool use_windowless_rendering_;
|
||||
int windowless_frame_rate_;
|
||||
int windowless_frame_rate_ = 0;
|
||||
bool use_chrome_runtime_;
|
||||
bool use_views_;
|
||||
bool touch_events_enabled_;
|
||||
|
||||
std::unique_ptr<RootWindowManager> root_window_manager_;
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ const char kNoActivate[] = "no-activate";
|
|||
const char kEnableChromeRuntime[] = "enable-chrome-runtime";
|
||||
const char kShowChromeToolbar[] = "show-chrome-toolbar";
|
||||
const char kInitialShowState[] = "initial-show-state";
|
||||
const char kHideChromeStatusBubble[] = "hide-chrome-status-bubble";
|
||||
|
||||
} // namespace switches
|
||||
} // namespace client
|
||||
|
|
|
@ -41,6 +41,7 @@ extern const char kNoActivate[];
|
|||
extern const char kEnableChromeRuntime[];
|
||||
extern const char kShowChromeToolbar[];
|
||||
extern const char kInitialShowState[];
|
||||
extern const char kHideChromeStatusBubble[];
|
||||
|
||||
} // namespace switches
|
||||
} // namespace client
|
||||
|
|
Loading…
Reference in New Issue