Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Unified Diff: chrome/browser/ui/views/browser_action_view.cc

Issue 10905005: Change browser/page action default icon defined in manifest to support hidpi. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable unittest on android Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/browser_action_view.cc
diff --git a/chrome/browser/ui/views/browser_action_view.cc b/chrome/browser/ui/views/browser_action_view.cc
index 2d8ac71a5a86f8dc8fcf8512b408b21eb46b9042..f7774ccbba5c32efd7f3b571d4c19d8ca83a15a0 100644
--- a/chrome/browser/ui/views/browser_action_view.cc
+++ b/chrome/browser/ui/views/browser_action_view.cc
@@ -62,7 +62,7 @@ gfx::ImageSkia BrowserActionView::GetIconWithBadge() {
const ExtensionAction* action = button_->extension()->browser_action();
gfx::Size spacing(0, ToolbarView::kVertSpacing);
- gfx::ImageSkia icon = *action->GetIcon(tab_id).ToImageSkia();
+ gfx::ImageSkia icon = *button_->icon_factory().GetIcon(tab_id).ToImageSkia();
if (!button_->IsEnabled(tab_id))
icon = gfx::ImageSkiaOperations::CreateTransparentImage(icon, .25);
return action->GetIconWithBadge(icon, tab_id, spacing);
@@ -111,7 +111,8 @@ BrowserActionButton::BrowserActionButton(const Extension* extension,
browser_(browser),
browser_action_(extension->browser_action()),
extension_(extension),
- ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ icon_factory_(extension, extension->browser_action(), this)),
delegate_(delegate),
context_menu_(NULL),
called_registered_extension_command_(false) {
@@ -145,21 +146,6 @@ void BrowserActionButton::Destroy() {
void BrowserActionButton::ViewHierarchyChanged(
bool is_add, View* parent, View* child) {
- if (is_add && child == this) {
- // The Browser Action API does not allow the default icon path to be
- // changed at runtime, so we can load this now and cache it.
- std::string relative_path = browser_action_->default_icon_path();
- if (!relative_path.empty()) {
- // LoadImage is not guaranteed to be synchronous, so we might see the
- // callback OnImageLoaded execute immediately. It (through UpdateState)
- // expects parent() to return the owner for this button, so this
- // function is as early as we can start this request.
- tracker_.LoadImage(extension_, extension_->GetResource(relative_path),
- gfx::Size(Extension::kBrowserActionIconMaxSize,
- Extension::kBrowserActionIconMaxSize),
- ImageLoadingTracker::DONT_CACHE);
- }
- }
if (is_add && !called_registered_extension_command_ && GetFocusManager()) {
MaybeRegisterExtensionCommand();
@@ -214,16 +200,6 @@ void BrowserActionButton::ShowContextMenuForView(View* source,
context_menu_ = NULL;
}
-void BrowserActionButton::OnImageLoaded(const gfx::Image& image,
- const std::string& extension_id,
- int index) {
- browser_action_->CacheIcon(image);
-
- // Call back to UpdateState() because a more specific icon might have been set
- // while the load was outstanding.
- UpdateState();
-}
-
void BrowserActionButton::UpdateState() {
int tab_id = delegate_->GetCurrentTabId();
if (tab_id < 0)
@@ -239,7 +215,7 @@ void BrowserActionButton::UpdateState() {
views::CustomButton::BS_NORMAL);
}
- gfx::ImageSkia icon = *browser_action()->GetIcon(tab_id).ToImageSkia();
+ gfx::ImageSkia icon = *icon_factory_.GetIcon(tab_id).ToImageSkia();
if (!icon.isNull()) {
if (!browser_action()->GetIsVisible(tab_id))
@@ -308,6 +284,10 @@ void BrowserActionButton::Observe(int type,
}
}
+void BrowserActionButton::OnIconUpdated() {
+ UpdateState();
+}
+
bool BrowserActionButton::Activate() {
if (!IsPopup())
return true;
« no previous file with comments | « chrome/browser/ui/views/browser_action_view.h ('k') | chrome/browser/ui/views/browser_actions_container_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698