Commit 39c650d9 authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Eliminate GlobalErrorWithStandardBubble::GetBubbleViewIcon().

TBR=xiaolingbao@chromium.org

Bug: 1056944
Change-Id: I4fe3c01989c6361868647fa4db2dac4c525aeb40
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2102646
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752082}
parent cbd847b5
...@@ -39,22 +39,12 @@ ...@@ -39,22 +39,12 @@
#include "extensions/browser/image_loader.h" #include "extensions/browser/image_loader.h"
#include "extensions/browser/notification_types.h" #include "extensions/browser/notification_types.h"
#include "extensions/browser/uninstall_reason.h" #include "extensions/browser/uninstall_reason.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/extension_icon_set.h" #include "extensions/common/extension_icon_set.h"
#include "extensions/common/manifest_handlers/icons_handler.h"
#include "extensions/common/permissions/permission_message.h" #include "extensions/common/permissions/permission_message.h"
#include "extensions/common/permissions/permissions_data.h" #include "extensions/common/permissions/permissions_data.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia_operations.h"
namespace {
static const int kIconSize = extension_misc::EXTENSION_ICON_SMALL;
} // namespace
// ExtensionDisabledGlobalError ----------------------------------------------- // ExtensionDisabledGlobalError -----------------------------------------------
...@@ -67,8 +57,7 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble, ...@@ -67,8 +57,7 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
public: public:
ExtensionDisabledGlobalError(ExtensionService* service, ExtensionDisabledGlobalError(ExtensionService* service,
const Extension* extension, const Extension* extension,
bool is_remote_install, bool is_remote_install);
const gfx::Image& icon);
~ExtensionDisabledGlobalError() override; ~ExtensionDisabledGlobalError() override;
// GlobalError: // GlobalError:
...@@ -77,7 +66,6 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble, ...@@ -77,7 +66,6 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
int MenuItemCommandID() override; int MenuItemCommandID() override;
base::string16 MenuItemLabel() override; base::string16 MenuItemLabel() override;
void ExecuteMenuItem(Browser* browser) override; void ExecuteMenuItem(Browser* browser) override;
gfx::Image GetBubbleViewIcon() override;
base::string16 GetBubbleViewTitle() override; base::string16 GetBubbleViewTitle() override;
std::vector<base::string16> GetBubbleViewMessages() override; std::vector<base::string16> GetBubbleViewMessages() override;
base::string16 GetBubbleViewAcceptButtonLabel() override; base::string16 GetBubbleViewAcceptButtonLabel() override;
...@@ -108,7 +96,6 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble, ...@@ -108,7 +96,6 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
ExtensionService* service_; ExtensionService* service_;
const Extension* extension_; const Extension* extension_;
bool is_remote_install_; bool is_remote_install_;
gfx::Image icon_;
// How the user responded to the error; used for metrics. // How the user responded to the error; used for metrics.
enum UserResponse { enum UserResponse {
...@@ -136,19 +123,11 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble, ...@@ -136,19 +123,11 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
ExtensionDisabledGlobalError::ExtensionDisabledGlobalError( ExtensionDisabledGlobalError::ExtensionDisabledGlobalError(
ExtensionService* service, ExtensionService* service,
const Extension* extension, const Extension* extension,
bool is_remote_install, bool is_remote_install)
const gfx::Image& icon)
: service_(service), : service_(service),
extension_(extension), extension_(extension),
is_remote_install_(is_remote_install), is_remote_install_(is_remote_install),
icon_(icon),
user_response_(IGNORED) { user_response_(IGNORED) {
if (icon_.IsEmpty()) {
icon_ = gfx::Image(gfx::ImageSkiaOperations::CreateResizedImage(
extension_->is_app() ? util::GetDefaultAppIcon()
: util::GetDefaultExtensionIcon(),
skia::ImageOperations::RESIZE_BEST, gfx::Size(kIconSize, kIconSize)));
}
registry_observer_.Add(ExtensionRegistry::Get(service->profile())); registry_observer_.Add(ExtensionRegistry::Get(service->profile()));
registrar_.Add(this, NOTIFICATION_EXTENSION_REMOVED, registrar_.Add(this, NOTIFICATION_EXTENSION_REMOVED,
content::Source<Profile>(service->profile())); content::Source<Profile>(service->profile()));
...@@ -188,10 +167,6 @@ void ExtensionDisabledGlobalError::ExecuteMenuItem(Browser* browser) { ...@@ -188,10 +167,6 @@ void ExtensionDisabledGlobalError::ExecuteMenuItem(Browser* browser) {
ShowBubbleView(browser); ShowBubbleView(browser);
} }
gfx::Image ExtensionDisabledGlobalError::GetBubbleViewIcon() {
return icon_;
}
base::string16 ExtensionDisabledGlobalError::GetBubbleViewTitle() { base::string16 ExtensionDisabledGlobalError::GetBubbleViewTitle() {
if (is_remote_install_) { if (is_remote_install_) {
return l10n_util::GetStringFUTF16( return l10n_util::GetStringFUTF16(
...@@ -347,33 +322,14 @@ void ExtensionDisabledGlobalError::RemoveGlobalError() { ...@@ -347,33 +322,14 @@ void ExtensionDisabledGlobalError::RemoveGlobalError() {
// Globals -------------------------------------------------------------------- // Globals --------------------------------------------------------------------
void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service, void AddExtensionDisabledError(ExtensionService* service,
const std::string& extension_id, const Extension* extension,
bool is_remote_install, bool is_remote_install) {
const gfx::Image& icon) {
if (!service.get())
return;
const ExtensionRegistry* registry =
ExtensionRegistry::Get(service->profile());
const Extension* extension = registry->GetInstalledExtension(extension_id);
if (extension) { if (extension) {
GlobalErrorServiceFactory::GetForProfile(service->profile()) GlobalErrorServiceFactory::GetForProfile(service->profile())
->AddGlobalError(std::make_unique<ExtensionDisabledGlobalError>( ->AddGlobalError(std::make_unique<ExtensionDisabledGlobalError>(
service.get(), extension, is_remote_install, icon)); service, extension, is_remote_install));
} }
} }
void AddExtensionDisabledError(ExtensionService* service,
const Extension* extension,
bool is_remote_install) {
ExtensionResource image = IconsInfo::GetIconResource(
extension, kIconSize, ExtensionIconSet::MATCH_BIGGER);
gfx::Size size(kIconSize, kIconSize);
ImageLoader::Get(service->profile())
->LoadImageAsync(extension, image, size,
base::BindOnce(&AddExtensionDisabledErrorWithIcon,
service->AsWeakPtr(), extension->id(),
is_remote_install));
}
} // namespace extensions } // namespace extensions
...@@ -119,7 +119,6 @@ class ExternalInstallBubbleAlert : public GlobalErrorWithStandardBubble { ...@@ -119,7 +119,6 @@ class ExternalInstallBubbleAlert : public GlobalErrorWithStandardBubble {
void ExecuteMenuItem(Browser* browser) override; void ExecuteMenuItem(Browser* browser) override;
// GlobalErrorWithStandardBubble implementation. // GlobalErrorWithStandardBubble implementation.
gfx::Image GetBubbleViewIcon() override;
base::string16 GetBubbleViewTitle() override; base::string16 GetBubbleViewTitle() override;
std::vector<base::string16> GetBubbleViewMessages() override; std::vector<base::string16> GetBubbleViewMessages() override;
base::string16 GetBubbleViewAcceptButtonLabel() override; base::string16 GetBubbleViewAcceptButtonLabel() override;
...@@ -224,17 +223,6 @@ void ExternalInstallBubbleAlert::ExecuteMenuItem(Browser* browser) { ...@@ -224,17 +223,6 @@ void ExternalInstallBubbleAlert::ExecuteMenuItem(Browser* browser) {
error_->DidOpenBubbleView(); error_->DidOpenBubbleView();
} }
gfx::Image ExternalInstallBubbleAlert::GetBubbleViewIcon() {
if (prompt_->icon().IsEmpty())
return GlobalErrorWithStandardBubble::GetBubbleViewIcon();
// Scale icon to a reasonable size.
return gfx::Image(gfx::ImageSkiaOperations::CreateResizedImage(
*prompt_->icon().ToImageSkia(),
skia::ImageOperations::RESIZE_BEST,
gfx::Size(extension_misc::EXTENSION_ICON_SMALL,
extension_misc::EXTENSION_ICON_SMALL)));
}
base::string16 ExternalInstallBubbleAlert::GetBubbleViewTitle() { base::string16 ExternalInstallBubbleAlert::GetBubbleViewTitle() {
return l10n_util::GetStringFUTF16( return l10n_util::GetStringFUTF16(
IDS_EXTENSION_EXTERNAL_INSTALL_ALERT_BUBBLE_TITLE, IDS_EXTENSION_EXTERNAL_INSTALL_ALERT_BUBBLE_TITLE,
......
...@@ -96,12 +96,6 @@ bool RecoveryInstallGlobalError::ShouldCloseOnDeactivate() const { ...@@ -96,12 +96,6 @@ bool RecoveryInstallGlobalError::ShouldCloseOnDeactivate() const {
return false; return false;
} }
gfx::Image RecoveryInstallGlobalError::GetBubbleViewIcon() {
// TODO(estade): there shouldn't be an icon in the bubble, but
// GlobalErrorBubbleView currently requires it. See crbug.com/673995
return MenuItemIcon();
}
base::string16 RecoveryInstallGlobalError::GetBubbleViewTitle() { base::string16 RecoveryInstallGlobalError::GetBubbleViewTitle() {
return l10n_util::GetStringUTF16(IDS_RECOVERY_BUBBLE_TITLE); return l10n_util::GetStringUTF16(IDS_RECOVERY_BUBBLE_TITLE);
} }
......
...@@ -37,7 +37,6 @@ class RecoveryInstallGlobalError : public GlobalErrorWithStandardBubble, ...@@ -37,7 +37,6 @@ class RecoveryInstallGlobalError : public GlobalErrorWithStandardBubble,
bool HasShownBubbleView() override; bool HasShownBubbleView() override;
void ShowBubbleView(Browser* browser) override; void ShowBubbleView(Browser* browser) override;
bool ShouldCloseOnDeactivate() const override; bool ShouldCloseOnDeactivate() const override;
gfx::Image GetBubbleViewIcon() override;
base::string16 GetBubbleViewTitle() override; base::string16 GetBubbleViewTitle() override;
std::vector<base::string16> GetBubbleViewMessages() override; std::vector<base::string16> GetBubbleViewMessages() override;
base::string16 GetBubbleViewAcceptButtonLabel() override; base::string16 GetBubbleViewAcceptButtonLabel() override;
......
...@@ -63,13 +63,6 @@ bool GlobalErrorWithStandardBubble::ShouldCloseOnDeactivate() const { ...@@ -63,13 +63,6 @@ bool GlobalErrorWithStandardBubble::ShouldCloseOnDeactivate() const {
return true; return true;
} }
gfx::Image GlobalErrorWithStandardBubble::GetBubbleViewIcon() {
// If you change this make sure to also change the menu icon and the app menu
// icon color.
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_INPUT_ALERT);
}
bool GlobalErrorWithStandardBubble::ShouldShowCloseButton() const { bool GlobalErrorWithStandardBubble::ShouldShowCloseButton() const {
return false; return false;
} }
......
...@@ -67,7 +67,6 @@ class GlobalErrorWithStandardBubble ...@@ -67,7 +67,6 @@ class GlobalErrorWithStandardBubble
~GlobalErrorWithStandardBubble() override; ~GlobalErrorWithStandardBubble() override;
// Override these methods to customize the contents of the error bubble: // Override these methods to customize the contents of the error bubble:
virtual gfx::Image GetBubbleViewIcon();
virtual base::string16 GetBubbleViewTitle() = 0; virtual base::string16 GetBubbleViewTitle() = 0;
virtual std::vector<base::string16> GetBubbleViewMessages() = 0; virtual std::vector<base::string16> GetBubbleViewMessages() = 0;
virtual base::string16 GetBubbleViewAcceptButtonLabel() = 0; virtual base::string16 GetBubbleViewAcceptButtonLabel() = 0;
......
...@@ -120,19 +120,6 @@ base::string16 GlobalErrorBubbleView::GetWindowTitle() const { ...@@ -120,19 +120,6 @@ base::string16 GlobalErrorBubbleView::GetWindowTitle() const {
return error_->GetBubbleViewTitle(); return error_->GetBubbleViewTitle();
} }
gfx::ImageSkia GlobalErrorBubbleView::GetWindowIcon() {
gfx::Image image;
if (error_) {
image = error_->GetBubbleViewIcon();
DCHECK(!image.IsEmpty());
}
return *image.ToImageSkia();
}
bool GlobalErrorBubbleView::ShouldShowWindowIcon() const {
return ChromeLayoutProvider::Get()->ShouldShowWindowIcon();
}
void GlobalErrorBubbleView::WindowClosing() { void GlobalErrorBubbleView::WindowClosing() {
if (error_) if (error_)
error_->BubbleViewDidClose(browser_); error_->BubbleViewDidClose(browser_);
......
...@@ -29,8 +29,6 @@ class GlobalErrorBubbleView : public views::BubbleDialogDelegateView, ...@@ -29,8 +29,6 @@ class GlobalErrorBubbleView : public views::BubbleDialogDelegateView,
// views::WidgetDelegate implementation. // views::WidgetDelegate implementation.
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
gfx::ImageSkia GetWindowIcon() override;
bool ShouldShowWindowIcon() const override;
void WindowClosing() override; void WindowClosing() override;
// views::BubbleDialogDelegateView implementation. // views::BubbleDialogDelegateView implementation.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment