| 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 8a4fe58cfee81f00386d9a361e93a1b0fe802271..f2b79c8620b4b5bc847b5de1e79f7dbd6686fed2 100644
|
| --- a/chrome/browser/ui/views/browser_action_view.cc
|
| +++ b/chrome/browser/ui/views/browser_action_view.cc
|
| @@ -62,7 +62,8 @@ 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 =
|
| + *action->GetIcon(tab_id, &button_->icon_factory()).ToImageSkia();
|
| if (!button_->IsEnabled(tab_id))
|
| icon = gfx::ImageSkiaOperations::CreateTransparentImage(icon, .25);
|
| return action->GetIconWithBadge(icon, tab_id, spacing);
|
| @@ -111,7 +112,7 @@ 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, 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();
|
| @@ -213,17 +199,8 @@ 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(browser_action_->default_icon_path(), image);
|
| -
|
| - // Call back to UpdateState() because a more specific icon might have been set
|
| - // while the load was outstanding.
|
| - UpdateState();
|
| -}
|
| -
|
| void BrowserActionButton::UpdateState() {
|
| +LOG(ERROR) << "update state";
|
| int tab_id = delegate_->GetCurrentTabId();
|
| if (tab_id < 0)
|
| return;
|
| @@ -237,8 +214,9 @@ void BrowserActionButton::UpdateState() {
|
| views::CustomButton::BS_PUSHED :
|
| views::CustomButton::BS_NORMAL);
|
| }
|
| -
|
| - gfx::ImageSkia icon = *browser_action()->GetIcon(tab_id).ToImageSkia();
|
| +LOG(ERROR) << "request icon";
|
| + gfx::ImageSkia icon =
|
| + *browser_action()->GetIcon(tab_id, &icon_factory_).ToImageSkia();
|
|
|
| if (!icon.isNull()) {
|
| if (!browser_action()->GetIsVisible(tab_id))
|
| @@ -307,6 +285,10 @@ void BrowserActionButton::Observe(int type,
|
| }
|
| }
|
|
|
| +void BrowserActionButton::OnIconUpdated() {
|
| + UpdateState();
|
| +}
|
| +
|
| bool BrowserActionButton::Activate() {
|
| if (!IsPopup())
|
| return true;
|
|
|