2021-11-17 01:17:39 +01:00
|
|
|
diff --git chrome/browser/extensions/api/chrome_extensions_api_client.cc chrome/browser/extensions/api/chrome_extensions_api_client.cc
|
2024-10-24 17:53:43 +02:00
|
|
|
index 66ea000f8c048..02eeb15adceed 100644
|
2021-11-17 01:17:39 +01:00
|
|
|
--- chrome/browser/extensions/api/chrome_extensions_api_client.cc
|
|
|
|
+++ chrome/browser/extensions/api/chrome_extensions_api_client.cc
|
2024-10-24 17:05:31 +02:00
|
|
|
@@ -15,6 +15,7 @@
|
2022-04-21 20:58:48 +02:00
|
|
|
#include "base/strings/string_util.h"
|
2021-11-17 01:17:39 +01:00
|
|
|
#include "build/build_config.h"
|
|
|
|
#include "build/chromeos_buildflags.h"
|
2024-07-05 19:07:07 +02:00
|
|
|
+#include "cef/libcef/features/features.h"
|
2021-11-17 01:17:39 +01:00
|
|
|
#include "chrome/browser/extensions/api/automation_internal/chrome_automation_internal_api_delegate.h"
|
|
|
|
#include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h"
|
|
|
|
#include "chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.h"
|
2024-10-24 17:53:43 +02:00
|
|
|
@@ -86,6 +87,10 @@
|
2021-11-17 01:17:39 +01:00
|
|
|
#include "chrome/browser/extensions/clipboard_extension_helper_chromeos.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+#include "cef/libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.h"
|
|
|
|
+#endif
|
|
|
|
+
|
2023-09-15 21:51:43 +02:00
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
|
|
|
#include "chrome/browser/printing/printing_init.h"
|
|
|
|
#endif
|
2024-10-24 17:53:43 +02:00
|
|
|
@@ -309,7 +314,11 @@ ChromeExtensionsAPIClient::CreateGuestViewManagerDelegate() const {
|
2021-11-17 01:17:39 +01:00
|
|
|
std::unique_ptr<MimeHandlerViewGuestDelegate>
|
|
|
|
ChromeExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate(
|
|
|
|
MimeHandlerViewGuest* guest) const {
|
2023-01-23 18:58:40 +01:00
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
2024-07-05 19:07:07 +02:00
|
|
|
+ return std::make_unique<ChromeMimeHandlerViewGuestDelegateCef>(guest);
|
|
|
|
+#else
|
2021-11-17 01:17:39 +01:00
|
|
|
return std::make_unique<ChromeMimeHandlerViewGuestDelegate>();
|
2024-07-05 19:07:07 +02:00
|
|
|
+#endif
|
2021-11-17 01:17:39 +01:00
|
|
|
}
|
|
|
|
|
2024-07-05 19:07:07 +02:00
|
|
|
WebViewGuestDelegate* ChromeExtensionsAPIClient::CreateWebViewGuestDelegate(
|
2024-04-27 03:21:18 +02:00
|
|
|
diff --git chrome/browser/extensions/api/tabs/tabs_api.cc chrome/browser/extensions/api/tabs/tabs_api.cc
|
2024-10-24 17:53:43 +02:00
|
|
|
index d0ec6330ae8c1..c9e2857fa06b4 100644
|
2024-04-27 03:21:18 +02:00
|
|
|
--- chrome/browser/extensions/api/tabs/tabs_api.cc
|
|
|
|
+++ chrome/browser/extensions/api/tabs/tabs_api.cc
|
2024-10-24 17:53:43 +02:00
|
|
|
@@ -1603,7 +1603,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
2024-10-24 17:05:31 +02:00
|
|
|
return RespondNow(Error(ExtensionTabUtil::kTabStripNotEditableError));
|
2024-04-27 03:21:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- if (tab_strip->active_index() != tab_index) {
|
|
|
|
+ if (tab_strip && tab_strip->active_index() != tab_index) {
|
|
|
|
tab_strip->ActivateTabAt(tab_index);
|
|
|
|
DCHECK_EQ(contents, tab_strip->GetActiveWebContents());
|
|
|
|
}
|
2024-10-24 17:53:43 +02:00
|
|
|
@@ -1617,7 +1617,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
2024-04-27 03:21:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool highlighted = *params->update_properties.highlighted;
|
|
|
|
- if (highlighted != tab_strip->IsTabSelected(tab_index)) {
|
|
|
|
+ if (tab_strip && highlighted != tab_strip->IsTabSelected(tab_index)) {
|
|
|
|
tab_strip->ToggleSelectionAt(tab_index);
|
|
|
|
}
|
|
|
|
}
|
2024-10-24 17:53:43 +02:00
|
|
|
@@ -1629,7 +1629,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
2024-10-24 17:05:31 +02:00
|
|
|
kCannotUpdateMuteCaptured, base::NumberToString(tab_id))));
|
2024-04-27 03:21:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- if (params->update_properties.opener_tab_id) {
|
|
|
|
+ if (tab_strip && params->update_properties.opener_tab_id) {
|
|
|
|
int opener_id = *params->update_properties.opener_tab_id;
|
|
|
|
WebContents* opener_contents = nullptr;
|
|
|
|
if (opener_id == tab_id) {
|
2024-10-24 17:53:43 +02:00
|
|
|
@@ -1664,7 +1664,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
2024-09-27 16:15:44 +02:00
|
|
|
->SetAutoDiscardable(state);
|
2024-04-27 03:21:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- if (params->update_properties.pinned) {
|
|
|
|
+ if (tab_strip && params->update_properties.pinned) {
|
2024-09-27 16:15:44 +02:00
|
|
|
// Bug fix for crbug.com/1197888. Don't let the extension update the tab if
|
|
|
|
// the user is dragging tabs.
|
|
|
|
if (!ExtensionTabUtil::IsTabStripEditable()) {
|
2024-10-24 17:53:43 +02:00
|
|
|
@@ -1685,8 +1685,9 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
2024-09-27 16:15:44 +02:00
|
|
|
// Navigate the tab to a new location if the url is different.
|
|
|
|
if (params->update_properties.url) {
|
2024-04-27 03:21:18 +02:00
|
|
|
std::string updated_url = *params->update_properties.url;
|
|
|
|
- if (browser->profile()->IsIncognitoProfile() &&
|
|
|
|
- !IsURLAllowedInIncognito(GURL(updated_url), browser->profile())) {
|
|
|
|
+ auto* profile = Profile::FromBrowserContext(browser_context());
|
|
|
|
+ if (profile->IsIncognitoProfile() &&
|
|
|
|
+ !IsURLAllowedInIncognito(GURL(updated_url), profile)) {
|
|
|
|
return RespondNow(Error(ErrorUtils::FormatErrorMessage(
|
|
|
|
tabs_constants::kURLsNotAllowedInIncognitoError, updated_url)));
|
|
|
|
}
|
2024-10-24 17:53:43 +02:00
|
|
|
@@ -1700,7 +1701,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
2024-04-27 03:21:18 +02:00
|
|
|
return RespondNow(Error(std::move(error)));
|
|
|
|
}
|
|
|
|
|
|
|
|
- NotifyExtensionTelemetry(Profile::FromBrowserContext(browser_context()),
|
|
|
|
+ NotifyExtensionTelemetry(profile,
|
|
|
|
extension(), safe_browsing::TabsApiInfo::UPDATE,
|
2024-06-14 19:01:45 +02:00
|
|
|
current_url, updated_url, js_callstack());
|
2024-04-27 03:21:18 +02:00
|
|
|
}
|
|
|
|
diff --git chrome/browser/extensions/extension_tab_util.cc chrome/browser/extensions/extension_tab_util.cc
|
2024-10-24 17:05:31 +02:00
|
|
|
index a896cb1079d97..6681661f788f6 100644
|
2024-04-27 03:21:18 +02:00
|
|
|
--- chrome/browser/extensions/extension_tab_util.cc
|
|
|
|
+++ chrome/browser/extensions/extension_tab_util.cc
|
2024-09-27 16:15:44 +02:00
|
|
|
@@ -20,6 +20,7 @@
|
2024-04-27 03:21:18 +02:00
|
|
|
#include "base/strings/stringprintf.h"
|
|
|
|
#include "base/strings/utf_string_conversions.h"
|
|
|
|
#include "base/types/expected_macros.h"
|
|
|
|
+#include "cef/libcef/features/features.h"
|
|
|
|
#include "chrome/browser/browser_process.h"
|
2024-09-27 16:15:44 +02:00
|
|
|
#include "chrome/browser/extensions/browser_extension_window_controller.h"
|
2024-10-24 17:05:31 +02:00
|
|
|
#include "chrome/browser/extensions/chrome_extension_function_details.h"
|
|
|
|
@@ -73,6 +74,10 @@
|
2024-04-27 03:21:18 +02:00
|
|
|
#include "third_party/blink/public/common/features.h"
|
|
|
|
#include "url/gurl.h"
|
|
|
|
|
|
|
|
+#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;
|
2024-10-24 17:05:31 +02:00
|
|
|
@@ -696,6 +701,20 @@ bool ExtensionTabUtil::GetTabById(int tab_id,
|
2024-04-27 03:21:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (cef::GetAlloyTabById(tab_id, profile, include_incognito, contents)) {
|
|
|
|
+ // |tab_strip| and |tab_index| are tied to a specific Browser window, which
|
|
|
|
+ // doesn't exist for an Alloy style browser.
|
|
|
|
+ if (tab_strip) {
|
|
|
|
+ *tab_strip = nullptr;
|
|
|
|
+ }
|
|
|
|
+ if (tab_index) {
|
|
|
|
+ *tab_index = api::tabs::TAB_INDEX_NONE;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+#endif // BUILDFLAG(ENABLE_CEF)
|
|
|
|
+
|
|
|
|
if (base::FeatureList::IsEnabled(blink::features::kPrerender2InNewTab)) {
|
|
|
|
// 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
|
|
|
|
diff --git chrome/browser/ui/tab_helpers.h chrome/browser/ui/tab_helpers.h
|
2024-09-27 16:15:44 +02:00
|
|
|
index 63848c93738ce..0358e098c7339 100644
|
2024-04-27 03:21:18 +02:00
|
|
|
--- 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)
|
|
|
|
|
2024-09-27 16:15:44 +02:00
|
|
|
@@ -41,6 +42,10 @@ namespace tabs {
|
|
|
|
class TabModel;
|
|
|
|
} // namespace tabs
|
2024-04-27 03:21:18 +02:00
|
|
|
|
|
|
|
+#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.
|
2024-09-27 16:15:44 +02:00
|
|
|
@@ -79,6 +84,10 @@ class TabHelpers {
|
2024-04-27 03:21:18 +02:00
|
|
|
// 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".
|
2024-04-26 21:21:33 +02:00
|
|
|
diff --git chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc
|
2024-10-24 17:05:31 +02:00
|
|
|
index 74af36a74f108..a4e1885388d16 100644
|
2024-04-26 21:21:33 +02:00
|
|
|
--- chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc
|
|
|
|
+++ chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc
|
2024-10-24 17:05:31 +02:00
|
|
|
@@ -834,6 +834,10 @@ void DownloadToolbarButtonView::ShowPendingDownloadStartedAnimation() {
|
2024-04-26 21:21:33 +02:00
|
|
|
if (!gfx::Animation::ShouldRenderRichAnimation()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
+ if (!IsDrawn()) {
|
|
|
|
+ // Don't animate with a hidden download button.
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
content::WebContents* const web_contents =
|
|
|
|
browser_->tab_strip_model()->GetActiveWebContents();
|
|
|
|
if (!web_contents ||
|