mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			182 lines
		
	
	
		
			7.7 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			182 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 f61ec524109fe..92ca490728855 100644
 | |
| --- chrome/browser/extensions/api/chrome_extensions_api_client.cc
 | |
| +++ chrome/browser/extensions/api/chrome_extensions_api_client.cc
 | |
| @@ -15,6 +15,7 @@
 | |
|  #include "base/strings/string_util.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/chrome_device_permissions_prompt.h"
 | |
|  #include "chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.h"
 | |
| @@ -86,6 +87,10 @@
 | |
|  #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
 | |
| +
 | |
|  #if BUILDFLAG(ENABLE_PRINTING)
 | |
|  #include "chrome/browser/printing/printing_init.h"
 | |
|  #endif
 | |
| @@ -309,7 +314,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
 | |
|  }
 | |
|  
 | |
|  WebViewGuestDelegate* ChromeExtensionsAPIClient::CreateWebViewGuestDelegate(
 | |
| diff --git chrome/browser/extensions/api/tabs/tabs_api.cc chrome/browser/extensions/api/tabs/tabs_api.cc
 | |
| index d19671bad0e0d..639a1737a0ef5 100644
 | |
| --- chrome/browser/extensions/api/tabs/tabs_api.cc
 | |
| +++ chrome/browser/extensions/api/tabs/tabs_api.cc
 | |
| @@ -1674,7 +1674,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
 | |
|        return RespondNow(Error(ExtensionTabUtil::kTabStripNotEditableError));
 | |
|      }
 | |
|  
 | |
| -    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());
 | |
|      }
 | |
| @@ -1688,7 +1688,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
 | |
|      }
 | |
|  
 | |
|      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);
 | |
|      }
 | |
|    }
 | |
| @@ -1700,7 +1700,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
 | |
|          kCannotUpdateMuteCaptured, base::NumberToString(tab_id))));
 | |
|    }
 | |
|  
 | |
| -  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) {
 | |
| @@ -1735,7 +1735,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
 | |
|          ->SetAutoDiscardable(state);
 | |
|    }
 | |
|  
 | |
| -  if (params->update_properties.pinned) {
 | |
| +  if (tab_strip && params->update_properties.pinned) {
 | |
|      // Bug fix for crbug.com/1197888. Don't let the extension update the tab if
 | |
|      // the user is dragging tabs.
 | |
|      if (!ExtensionTabUtil::IsTabStripEditable()) {
 | |
| @@ -1756,7 +1756,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 (browser->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)));
 | |
| @@ -1771,7 +1772,7 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
 | |
|        return RespondNow(Error(std::move(error)));
 | |
|      }
 | |
|  
 | |
| -    NotifyExtensionTelemetry(Profile::FromBrowserContext(browser_context()),
 | |
| +    NotifyExtensionTelemetry(profile,
 | |
|                               extension(), safe_browsing::TabsApiInfo::UPDATE,
 | |
|                               current_url, updated_url, js_callstack());
 | |
|    }
 | |
| diff --git chrome/browser/extensions/extension_tab_util.cc chrome/browser/extensions/extension_tab_util.cc
 | |
| index 8a2e378aac255..456c542044eb3 100644
 | |
| --- chrome/browser/extensions/extension_tab_util.cc
 | |
| +++ chrome/browser/extensions/extension_tab_util.cc
 | |
| @@ -38,6 +38,7 @@
 | |
|  #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"  // nogncheck
 | |
|  #include "chrome/browser/extensions/browser_extension_window_controller.h"
 | |
|  #include "chrome/browser/extensions/chrome_extension_function_details.h"
 | |
| @@ -84,6 +85,10 @@
 | |
|  #include "url/url_constants.h"
 | |
|  #endif
 | |
|  
 | |
| +#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;
 | |
| @@ -735,6 +740,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  // 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
 | |
| index 63848c93738ce..0358e098c7339 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.
 | |
| @@ -79,6 +84,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".
 | |
| diff --git chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc
 | |
| index 767a3b368e93d..d206384a0e20c 100644
 | |
| --- chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc
 | |
| +++ chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc
 | |
| @@ -820,6 +820,10 @@ void DownloadToolbarButtonView::ShowPendingDownloadStartedAnimation() {
 | |
|    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 ||
 |