mirror of
https://github.com/aphrody-labs/cef.git
synced 2026-10-13 21:07:07 +00:00
- Windows SDK 10.0.28000.2270 is now required - CefRegisterExtension is deprecated due to https://crbug.com/40347662
184 lines
7.7 KiB
Diff
184 lines
7.7 KiB
Diff
diff --git chrome/browser/extensions/api/chrome_extensions_api_client.cc chrome/browser/extensions/api/chrome_extensions_api_client.cc
|
|
index 2d73f4cf7e49380c9793751b24ceab848d753e6c..2e95396a5fd514d2953234ca6f57a3f482e23bd5 100644
|
|
--- chrome/browser/extensions/api/chrome_extensions_api_client.cc
|
|
+++ chrome/browser/extensions/api/chrome_extensions_api_client.cc
|
|
@@ -16,6 +16,7 @@
|
|
#include "base/task/single_thread_task_runner.h"
|
|
#include "build/build_config.h"
|
|
#include "build/chromeos_buildflags.h"
|
|
+#include "cef/libcef/features/features.h"
|
|
#include "chrome/browser/extensions/api/automation_internal/chrome_automation_internal_api_delegate.h"
|
|
#include "chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.h"
|
|
#include "chrome/browser/extensions/api/declarative_content/default_content_predicate_evaluators.h"
|
|
@@ -102,6 +103,10 @@
|
|
#include "chromeos/ash/components/settings/cros_settings.h"
|
|
#endif
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+#include "cef/libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.h"
|
|
+#endif
|
|
+
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
|
#include "chrome/browser/printing/printing_init.h"
|
|
#endif
|
|
@@ -364,7 +369,11 @@ ChromeExtensionsAPIClient::CreateGuestViewManagerDelegate() const {
|
|
std::unique_ptr<MimeHandlerViewGuestDelegate>
|
|
ChromeExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate(
|
|
MimeHandlerViewGuest* guest) const {
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+ return std::make_unique<ChromeMimeHandlerViewGuestDelegateCef>(guest);
|
|
+#else
|
|
return std::make_unique<ChromeMimeHandlerViewGuestDelegate>();
|
|
+#endif
|
|
}
|
|
#endif
|
|
|
|
diff --git chrome/browser/extensions/api/tabs/tabs_api.cc chrome/browser/extensions/api/tabs/tabs_api.cc
|
|
index d225b3926e66808ba3f78ed9b654517d9fec4b1d..6ccbe28a4765747c5bdf42a294a4b58b2f763705 100644
|
|
--- chrome/browser/extensions/api/tabs/tabs_api.cc
|
|
+++ chrome/browser/extensions/api/tabs/tabs_api.cc
|
|
@@ -2593,31 +2593,31 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
|
}
|
|
|
|
// tabs_internal::GetTabById may return a null window for prerender tabs.
|
|
- if (!window || !ExtensionTabUtil::BrowserSupportsTabs(
|
|
- window->GetBrowserWindowInterface())) {
|
|
- return RespondNow(Error(ExtensionTabUtil::kNoCurrentWindowError));
|
|
- }
|
|
+ TabListInterface* tab_list = nullptr;
|
|
+ ::tabs::TabInterface* target_tab = nullptr;
|
|
+ if (window && ExtensionTabUtil::BrowserSupportsTabs(
|
|
+ window->GetBrowserWindowInterface())) {
|
|
+ tab_list = TabListInterface::From(window->GetBrowserWindowInterface());
|
|
+ CHECK(tab_list);
|
|
|
|
- // Cache the original web contents.
|
|
- content::WebContents* original_contents = contents;
|
|
+ // Update the active (aka selected) tab.
|
|
+ if (!UpdateActiveTab(*params, *window->profile(),
|
|
+ *window->GetBrowserWindowInterface(), *tab_list,
|
|
+ tab_index, error)) {
|
|
+ return RespondNow(Error(std::move(error)));
|
|
+ }
|
|
|
|
- // Update the active (aka selected) tab.
|
|
- TabListInterface* tab_list =
|
|
- TabListInterface::From(window->GetBrowserWindowInterface());
|
|
- CHECK(tab_list);
|
|
- if (!UpdateActiveTab(*params, *window->profile(),
|
|
- *window->GetBrowserWindowInterface(), *tab_list,
|
|
- tab_index, error)) {
|
|
- return RespondNow(Error(std::move(error)));
|
|
+ // Update the highlighted tab.
|
|
+ target_tab = tab_list->GetTab(tab_index);
|
|
+ CHECK(target_tab);
|
|
+ if (!UpdateHighlightedTab(*params, *window->profile(), *tab_list,
|
|
+ *target_tab, error)) {
|
|
+ return RespondNow(Error(std::move(error)));
|
|
+ }
|
|
}
|
|
|
|
- // Update the highlighted tab.
|
|
- ::tabs::TabInterface* target_tab = tab_list->GetTab(tab_index);
|
|
- CHECK(target_tab);
|
|
- if (!UpdateHighlightedTab(*params, *window->profile(), *tab_list, *target_tab,
|
|
- error)) {
|
|
- return RespondNow(Error(std::move(error)));
|
|
- }
|
|
+ // Cache the original web contents.
|
|
+ content::WebContents* original_contents = contents;
|
|
|
|
if (params->update_properties.muted &&
|
|
!SetTabAudioMuted(contents, *params->update_properties.muted,
|
|
@@ -2658,7 +2658,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
|
}
|
|
#endif
|
|
|
|
- if (params->update_properties.pinned) {
|
|
+ if (target_tab && params->update_properties.pinned) {
|
|
bool pinned = *params->update_properties.pinned;
|
|
|
|
if (target_tab->IsPinned() != pinned) {
|
|
@@ -2688,7 +2688,8 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
|
// Navigate the tab to a new location if the url is different.
|
|
if (params->update_properties.url) {
|
|
std::string updated_url = *params->update_properties.url;
|
|
- if (window->profile()->IsIncognitoProfile() &&
|
|
+ auto* profile = Profile::FromBrowserContext(browser_context());
|
|
+ if (profile->IsIncognitoProfile() &&
|
|
!IsURLAllowedInIncognito(GURL(updated_url))) {
|
|
return RespondNow(Error(ErrorUtils::FormatErrorMessage(
|
|
tabs_constants::kURLsNotAllowedInIncognitoError, updated_url)));
|
|
diff --git chrome/browser/extensions/extension_tab_util.cc chrome/browser/extensions/extension_tab_util.cc
|
|
index 285481f45a49b82ba50e9b5b0df33519add40a7d..da312fc7869222d7e88963a02b51d0185cf6c9ad 100644
|
|
--- chrome/browser/extensions/extension_tab_util.cc
|
|
+++ chrome/browser/extensions/extension_tab_util.cc
|
|
@@ -70,6 +70,7 @@
|
|
#include "chrome/browser/ui/android/tab_model/tab_model.h"
|
|
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
|
|
#else
|
|
+#include "cef/libcef/features/features.h"
|
|
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h"
|
|
// nogncheck
|
|
#include "chrome/browser/ui/navigator/browser_navigator_params.h" // nogncheck
|
|
@@ -86,6 +87,10 @@
|
|
|
|
static_assert(BUILDFLAG(ENABLE_EXTENSIONS_CORE));
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+#include "cef/libcef/browser/chrome/extensions/chrome_extension_util.h"
|
|
+#endif
|
|
+
|
|
using content::NavigationEntry;
|
|
using content::WebContents;
|
|
using extensions::mojom::APIPermissionID;
|
|
@@ -671,6 +676,14 @@ bool ExtensionTabUtil::GetTabById(int tab_id,
|
|
}
|
|
}
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+ if (cef::GetAlloyTabById(tab_id, profile, include_incognito, out_contents)) {
|
|
+ // |out_window| and |out_tab_index| are tied to a specific Browser window,
|
|
+ // which doesn't exist for an Alloy style browser.
|
|
+ return true;
|
|
+ }
|
|
+#endif
|
|
+
|
|
// Prerendering tab is not visible and it cannot be in `TabStripModel`, if the
|
|
// tab id exists as a prerendering tab, and the API will returns
|
|
// `api::tabs::TAB_INDEX_NONE` for `out_tab_index` and a valid `WebContents`.
|
|
diff --git chrome/browser/ui/tab_helpers.h chrome/browser/ui/tab_helpers.h
|
|
index d80eafa666b384cf1ec16ebc638456b570ca4e79..bff4d77829ad5875518b8c9434e00fba69833cf8 100644
|
|
--- chrome/browser/ui/tab_helpers.h
|
|
+++ chrome/browser/ui/tab_helpers.h
|
|
@@ -6,6 +6,7 @@
|
|
#define CHROME_BROWSER_UI_TAB_HELPERS_H_
|
|
|
|
#include "build/build_config.h"
|
|
+#include "cef/libcef/features/features.h"
|
|
|
|
#if BUILDFLAG(IS_ANDROID)
|
|
|
|
@@ -41,6 +42,10 @@ namespace tabs {
|
|
class TabModel;
|
|
} // namespace tabs
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+class CefBrowserPlatformDelegateAlloy;
|
|
+#endif
|
|
+
|
|
// A "tab contents" is a WebContents that is used as a tab in a browser window
|
|
// (or the equivalent on Android). The TabHelpers class allows specific classes
|
|
// to attach the set of tab helpers that is used for tab contents.
|
|
@@ -80,6 +85,10 @@ class TabHelpers {
|
|
// Link Preview shows a preview of a page, then promote it as a new tab.
|
|
friend class PreviewTab;
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+ friend class CefBrowserPlatformDelegateAlloy;
|
|
+#endif
|
|
+
|
|
// FYI: Do NOT add any more friends here. The functions above are the ONLY
|
|
// ones that need to call AttachTabHelpers; if you think you do, re-read the
|
|
// design document linked above, especially the section "Reusing tab helpers".
|