-
Notifications
You must be signed in to change notification settings - Fork 257
Enable support for CEF 6613+ (Chrome 128 to 147) and Chrome Runtime #523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
WizardCM
wants to merge
1
commit into
obsproject:master
Choose a base branch
from
WizardCM:chrome-runtime-changes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -48,11 +48,62 @@ CefRefPtr<CefBrowserProcessHandler> BrowserApp::GetBrowserProcessHandler() | |||||
| return this; | ||||||
| } | ||||||
|
|
||||||
| CefRefPtr<CefClient> BrowserApp::GetDefaultClient() | ||||||
| { | ||||||
| return GetDummy(); | ||||||
| } | ||||||
|
|
||||||
| void BrowserApp::OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) | ||||||
| { | ||||||
| registrar->AddCustomScheme("http", CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_CORS_ENABLED); | ||||||
| } | ||||||
|
|
||||||
| void BrowserApp::OnContextInitialized() | ||||||
| { | ||||||
| // Without a default client, CefBrowser is unmanaged, allowing full-blown Chromium windows outside of our control | ||||||
| // We don't actually want those, so define a dummy client which will automatically close any such windows | ||||||
| dummy = new BrowserDummyClient(); | ||||||
|
|
||||||
| CefRefPtr<CefRequestContext> requestContext = CefRequestContext::GetGlobalContext(); | ||||||
| CefString errorMessage; | ||||||
| CefRefPtr<CefValue> optionValue = CefValue::Create(); | ||||||
|
|
||||||
| constexpr std::array<std::string_view, 20> kBrowserFeaturesToDisable{ | ||||||
| "autofill.credit_card_enabled", | ||||||
| "autofill.enabled", | ||||||
| "autofill.iban_enabled", | ||||||
| "autofill.payment_card_benefits", | ||||||
| "autofill.payment_cvc_storage", | ||||||
| "autofill.profile_enabled", | ||||||
| "autologin.enabled", | ||||||
| "browser_labs_enabled", | ||||||
| "credentials_enable_autosignin", | ||||||
| "credentials_enable_service", | ||||||
| "payments.can_make_payment_enabled", | ||||||
| "printing.enabled", | ||||||
| "search.suggest_enabled", | ||||||
| "shopping_list_enabled", | ||||||
| "side_panel.google_search_side_panel_enabled", | ||||||
| "side_search.enabled", | ||||||
| "signin.allowed", | ||||||
| "signin.allowed_on_next_startup", | ||||||
| "translate", | ||||||
| "url_keyed_anonymized_data_collection.enabled"}; | ||||||
|
|
||||||
| constexpr std::array<std::string_view, 2> kBrowserFeaturesToEnable{"extensions.block_external_extensions", | ||||||
|
PatTheMav marked this conversation as resolved.
|
||||||
| "extensions.disabled"}; | ||||||
|
|
||||||
| optionValue->SetBool(false); | ||||||
| for (std::string_view feature : kBrowserFeaturesToDisable) { | ||||||
| requestContext->SetPreference(feature.data(), optionValue.get(), errorMessage); | ||||||
| } | ||||||
|
|
||||||
| optionValue->SetBool(true); | ||||||
| for (std::string_view feature : kBrowserFeaturesToEnable) { | ||||||
| requestContext->SetPreference(feature.data(), optionValue.get(), errorMessage); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| void BrowserApp::OnBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_line) | ||||||
| { | ||||||
| #ifdef _WIN32 | ||||||
|
|
@@ -82,16 +133,35 @@ void BrowserApp::OnBeforeCommandLineProcessing(const CefString &, CefRefPtr<CefC | |||||
| disableFeatures += ",EnableWindowsGamingInputDataFetcher"; | ||||||
| #endif | ||||||
| disableFeatures += ",WebBluetooth"; | ||||||
| disableFeatures += ",MediaRouter"; | ||||||
| disableFeatures += ",CalculateNativeWinOcclusion"; | ||||||
| disableFeatures += ",LiveCaption"; | ||||||
| // https://github.com/chromiumembedded/cef/issues/3966 | ||||||
| disableFeatures += ".StorageNotificationService"; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ?
Suggested change
|
||||||
| command_line->AppendSwitchWithValue("disable-features", disableFeatures); | ||||||
| } else { | ||||||
| command_line->AppendSwitchWithValue("disable-features", "WebBluetooth," | ||||||
| #ifdef _WIN32 | ||||||
| "EnableWindowsGamingInputDataFetcher," | ||||||
| #endif | ||||||
| "MediaRouter," | ||||||
| "CalculateNativeWinOcclusion," | ||||||
| "LiveCaption," | ||||||
| "StorageNotificationService," | ||||||
| "HardwareMediaKeyHandling"); | ||||||
| } | ||||||
|
|
||||||
| if (command_line->HasSwitch("disable-blink-features")) { | ||||||
| std::string disableBlinkFeatures = command_line->GetSwitchValue("disable-blink-features"); | ||||||
| disableBlinkFeatures += ",DocumentPictureInPictureAPI"; | ||||||
| command_line->AppendSwitchWithValue("disable-blink-features", disableBlinkFeatures); | ||||||
| } else { | ||||||
| command_line->AppendSwitchWithValue("disable-blink-features", "DocumentPictureInPictureAPI"); | ||||||
| } | ||||||
|
|
||||||
| command_line->AppendSwitchWithValue("autoplay-policy", "no-user-gesture-required"); | ||||||
| command_line->AppendSwitch("disable-extensions"); | ||||||
| command_line->AppendSwitch("hide-crash-restore-bubble"); | ||||||
| #ifdef __APPLE__ | ||||||
| command_line->AppendSwitch("use-mock-keychain"); | ||||||
| #elif !defined(_WIN32) | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
|
|
||
| #include "browser-dummy-client.hpp" | ||
|
|
||
| CefRefPtr<CefCommandHandler> BrowserDummyClient::GetCommandHandler() | ||
| { | ||
| return this; | ||
| } | ||
|
|
||
| CefRefPtr<CefRequestHandler> BrowserDummyClient::GetRequestHandler() | ||
| { | ||
| return this; | ||
| } | ||
|
|
||
| CefRefPtr<CefLifeSpanHandler> BrowserDummyClient::GetLifeSpanHandler() | ||
| { | ||
| return this; | ||
| } | ||
|
|
||
| bool BrowserDummyClient::OnChromeCommand(CefRefPtr<CefBrowser>, int, cef_window_open_disposition_t) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| bool BrowserDummyClient::IsChromeAppMenuItemVisible(CefRefPtr<CefBrowser>, int) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| bool BrowserDummyClient::IsChromeToolbarButtonVisible(cef_chrome_toolbar_button_type_t) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| bool BrowserDummyClient::IsChromePageActionIconVisible(cef_chrome_page_action_icon_type_t) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| bool BrowserDummyClient::IsChromeAppMenuItemEnabled(CefRefPtr<CefBrowser>, int) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| bool BrowserDummyClient::OnBeforePopup(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, | ||
| #if CHROME_VERSION_BUILD >= 6834 | ||
| int, | ||
| #endif | ||
| const CefString &, const CefString &, cef_window_open_disposition_t, bool, | ||
| const CefPopupFeatures &, CefWindowInfo &, CefRefPtr<CefClient> &, | ||
| CefBrowserSettings &, CefRefPtr<CefDictionaryValue> &, bool *) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| void BrowserDummyClient::OnAfterCreated(CefRefPtr<CefBrowser> browser) | ||
| { | ||
| if (browser && browser->GetHost()) { | ||
| browser->GetHost()->CloseBrowser(false); | ||
| } | ||
| } | ||
|
|
||
| bool BrowserDummyClient::OnOpenURLFromTab(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, const CefString &, | ||
| CefRequestHandler::WindowOpenDisposition, bool) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| bool BrowserDummyClient::OnBeforeBrowse(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, CefRefPtr<CefRequest>, bool, bool) | ||
| { | ||
| return true; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #pragma once | ||
|
|
||
| #include "cef-headers.hpp" | ||
|
|
||
| class BrowserDummyClient : public CefClient, | ||
| public CefCommandHandler, | ||
| public CefRequestHandler, | ||
| public CefLifeSpanHandler { | ||
| public: | ||
| virtual CefRefPtr<CefCommandHandler> GetCommandHandler() override; | ||
| virtual CefRefPtr<CefRequestHandler> GetRequestHandler() override; | ||
| virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override; | ||
|
|
||
| /* CefCommandHandler */ | ||
| virtual bool OnChromeCommand(CefRefPtr<CefBrowser> browser, int command_id, | ||
| cef_window_open_disposition_t disposition) override; | ||
| virtual bool IsChromeAppMenuItemVisible(CefRefPtr<CefBrowser> browser, int command_id) override; | ||
| virtual bool IsChromeToolbarButtonVisible(cef_chrome_toolbar_button_type_t button_type) override; | ||
|
|
||
| virtual bool IsChromePageActionIconVisible(cef_chrome_page_action_icon_type_t icon_type) override; | ||
|
|
||
| virtual bool IsChromeAppMenuItemEnabled(CefRefPtr<CefBrowser> browser, int command_id) override; | ||
|
|
||
| /* CefLifeSpanHandler */ | ||
| virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, | ||
| #if CHROME_VERSION_BUILD >= 6834 | ||
| int, | ||
| #endif | ||
| const CefString &target_url, const CefString &target_frame_name, | ||
| cef_window_open_disposition_t target_disposition, bool user_gesture, | ||
| const CefPopupFeatures &popupFeatures, CefWindowInfo &windowInfo, | ||
| CefRefPtr<CefClient> &client, CefBrowserSettings &settings, | ||
| CefRefPtr<CefDictionaryValue> &extra_info, bool *no_javascript_access) override; | ||
|
|
||
| virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) override; | ||
|
|
||
| /* CefRequestHandler */ | ||
| virtual bool OnOpenURLFromTab(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, | ||
| const CefString &target_url, | ||
| CefRequestHandler::WindowOpenDisposition target_disposition, | ||
| bool user_gesture) override; | ||
|
|
||
| virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, | ||
| CefRefPtr<CefRequest> request, bool user_gesture, bool is_redirect) override; | ||
|
|
||
| IMPLEMENT_REFCOUNTING(BrowserDummyClient); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.