mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
chrome: Fix callbacks for different Profile types (see issue #2969)
- Only install network intercepts for Profiles that have an associated CefBrowserContext. For incognito windows the CefBrowserContext is associated with the OffTheRecordProfileImpl's original Profile. - cefsimple: Return the default CefClient instance for browser windows created via the Chrome UI, and allow Chrome to show error pages.
This commit is contained in:
@@ -47,6 +47,10 @@ void SimpleHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
// Allow Chrome to handle the title change.
|
||||
if (IsChromeRuntimeEnabled())
|
||||
return;
|
||||
|
||||
if (use_views_) {
|
||||
// Set the title of the window using the Views framework.
|
||||
CefRefPtr<CefBrowserView> browser_view =
|
||||
@@ -110,6 +114,10 @@ void SimpleHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& failedUrl) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
// Allow Chrome to show the error page.
|
||||
if (IsChromeRuntimeEnabled())
|
||||
return;
|
||||
|
||||
// Don't display an error for downloaded files.
|
||||
if (errorCode == ERR_ABORTED)
|
||||
return;
|
||||
@@ -139,3 +147,14 @@ void SimpleHandler::CloseAllBrowsers(bool force_close) {
|
||||
for (; it != browser_list_.end(); ++it)
|
||||
(*it)->GetHost()->CloseBrowser(force_close);
|
||||
}
|
||||
|
||||
// static
|
||||
bool SimpleHandler::IsChromeRuntimeEnabled() {
|
||||
static int value = -1;
|
||||
if (value == -1) {
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
value = command_line->HasSwitch("enable-chrome-runtime") ? 1 : 0;
|
||||
}
|
||||
return value == 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user