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 @@
#include "extensions/browser/image_loader.h"
#include "extensions/browser/notification_types.h"
#include "extensions/browser/uninstall_reason.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.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/permissions_data.h"
#include "ui/base/l10n/l10n_util.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 -----------------------------------------------
......@@ -67,8 +57,7 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
public:
ExtensionDisabledGlobalError(ExtensionService* service,
const Extension* extension,
bool is_remote_install,
const gfx::Image& icon);
bool is_remote_install);
~ExtensionDisabledGlobalError() override;
// GlobalError:
......@@ -77,7 +66,6 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
int MenuItemCommandID() override;
base::string16 MenuItemLabel() override;
void ExecuteMenuItem(Browser* browser) override;
gfx::Image GetBubbleViewIcon() override;
base::string16 GetBubbleViewTitle() override;
std::vector<base::string16> GetBubbleViewMessages() override;
base::string16 GetBubbleViewAcceptButtonLabel() override;
......@@ -108,7 +96,6 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
ExtensionService* service_;
const Extension* extension_;
bool is_remote_install_;
gfx::Image icon_;
// How the user responded to the error; used for metrics.
enum UserResponse {
......@@ -136,19 +123,11 @@ class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
ExtensionDisabledGlobalError::ExtensionDisabledGlobalError(
ExtensionService* service,
const Extension* extension,
bool is_remote_install,
const gfx::Image& icon)
bool is_remote_install)
: service_(service),
extension_(extension),
is_remote_install_(is_remote_install),
icon_(icon),
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()));
registrar_.Add(this, NOTIFICATION_EXTENSION_REMOVED,
content::Source<Profile>(service->profile()));
......@@ -188,10 +167,6 @@ void ExtensionDisabledGlobalError::ExecuteMenuItem(Browser* browser) {
ShowBubbleView(browser);
}
gfx::Image ExtensionDisabledGlobalError::GetBubbleViewIcon() {
return icon_;
}
base::string16 ExtensionDisabledGlobalError::GetBubbleViewTitle() {
if (is_remote_install_) {
return l10n_util::GetStringFUTF16(
......@@ -347,33 +322,14 @@ void ExtensionDisabledGlobalError::RemoveGlobalError() {
// Globals --------------------------------------------------------------------
void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service,
const std::string& extension_id,
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);
void AddExtensionDisabledError(ExtensionService* service,
const Extension* extension,
bool is_remote_install) {
if (extension) {
GlobalErrorServiceFactory::GetForProfile(service->profile())
->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
......@@ -119,7 +119,6 @@ class ExternalInstallBubbleAlert : public GlobalErrorWithStandardBubble {
void ExecuteMenuItem(Browser* browser) override;
// GlobalErrorWithStandardBubble implementation.
gfx::Image GetBubbleViewIcon() override;
base::string16 GetBubbleViewTitle() override;
std::vector<base::string16> GetBubbleViewMessages() override;
base::string16 GetBubbleViewAcceptButtonLabel() override;
......@@ -224,17 +223,6 @@ void ExternalInstallBubbleAlert::ExecuteMenuItem(Browser* browser) {
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() {
return l10n_util::GetStringFUTF16(
IDS_EXTENSION_EXTERNAL_INSTALL_ALERT_BUBBLE_TITLE,
......
......@@ -96,12 +96,6 @@ bool RecoveryInstallGlobalError::ShouldCloseOnDeactivate() const {
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() {
return l10n_util::GetStringUTF16(IDS_RECOVERY_BUBBLE_TITLE);
}
......
......@@ -37,7 +37,6 @@ class RecoveryInstallGlobalError : public GlobalErrorWithStandardBubble,
bool HasShownBubbleView() override;
void ShowBubbleView(Browser* browser) override;
bool ShouldCloseOnDeactivate() const override;
gfx::Image GetBubbleViewIcon() override;
base::string16 GetBubbleViewTitle() override;
std::vector<base::string16> GetBubbleViewMessages() override;
base::string16 GetBubbleViewAcceptButtonLabel() override;
......
......@@ -63,13 +63,6 @@ bool GlobalErrorWithStandardBubble::ShouldCloseOnDeactivate() const {
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 {
return false;
}
......
......@@ -67,7 +67,6 @@ class GlobalErrorWithStandardBubble
~GlobalErrorWithStandardBubble() override;
// Override these methods to customize the contents of the error bubble:
virtual gfx::Image GetBubbleViewIcon();
virtual base::string16 GetBubbleViewTitle() = 0;
virtual std::vector<base::string16> GetBubbleViewMessages() = 0;
virtual base::string16 GetBubbleViewAcceptButtonLabel() = 0;
......
......@@ -120,19 +120,6 @@ base::string16 GlobalErrorBubbleView::GetWindowTitle() const {
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() {
if (error_)
error_->BubbleViewDidClose(browser_);
......
......@@ -29,8 +29,6 @@ class GlobalErrorBubbleView : public views::BubbleDialogDelegateView,
// views::WidgetDelegate implementation.
base::string16 GetWindowTitle() const override;
gfx::ImageSkia GetWindowIcon() override;
bool ShouldShowWindowIcon() const override;
void WindowClosing() override;
// 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