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

Unified Diff: chrome/browser/ui/views/location_bar/page_action_image_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/location_bar/page_action_image_view.cc
diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.cc b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
index f44eb239f0240f26580de450d65ad0725fe8b8f0..f0ef3b37267ed8a1e4e8586d556a5abb7d7dbff0 100644
--- a/chrome/browser/ui/views/location_bar/page_action_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
@@ -7,6 +7,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/api/commands/command_service.h"
#include "chrome/browser/extensions/api/commands/command_service_factory.h"
+#include "chrome/browser/extensions/extension_action_icon_factory.h"
#include "chrome/browser/extensions/extension_context_menu_model.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
@@ -43,7 +44,6 @@ PageActionImageView::PageActionImageView(LocationBarView* owner,
: owner_(owner),
page_action_(page_action),
browser_(browser),
- ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)),
current_tab_id_(-1),
preview_enabled_(false),
popup_(NULL),
@@ -55,13 +55,8 @@ PageActionImageView::PageActionImageView(LocationBarView* owner,
GetExtensionById(page_action->extension_id(), false);
DCHECK(extension);
- std::string path = page_action_->default_icon_path();
- if (!path.empty()) {
- tracker_.LoadImage(extension, extension->GetResource(path),
- gfx::Size(Extension::kPageActionIconMaxSize,
- Extension::kPageActionIconMaxSize),
- ImageLoadingTracker::DONT_CACHE);
- }
+ icon_factory_.reset(
+ new ExtensionActionIconFactory(extension, page_action, this));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
content::Source<Profile>(
@@ -188,17 +183,6 @@ bool PageActionImageView::OnKeyPressed(const ui::KeyEvent& event) {
return false;
}
-void PageActionImageView::OnImageLoaded(const gfx::Image& image,
- const std::string& extension_id,
- int index) {
- page_action_->CacheIcon(image);
-
- // During object construction owner_ will be NULL.
- TabContents* tab_contents = owner_ ? owner_->GetTabContents() : NULL;
- if (tab_contents)
- UpdateVisibility(tab_contents->web_contents(), current_url_);
-}
-
void PageActionImageView::ShowContextMenuForView(View* source,
const gfx::Point& point) {
const Extension* extension = owner_->profile()->GetExtensionService()->
@@ -251,7 +235,7 @@ void PageActionImageView::UpdateVisibility(WebContents* contents,
SetTooltipText(UTF8ToUTF16(tooltip_));
// Set the image.
- gfx::Image icon = page_action_->GetIcon(current_tab_id_);
+ gfx::Image icon = icon_factory_->GetIcon(current_tab_id_);
if (!icon.IsEmpty())
SetImage(*icon.ToImageSkia());
@@ -274,16 +258,20 @@ void PageActionImageView::Observe(int type,
DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNLOADED, type);
const Extension* unloaded_extension =
content::Details<extensions::UnloadedExtensionInfo>(details)->extension;
- if (page_action_ == unloaded_extension ->page_action())
+ if (page_action_ == unloaded_extension->page_action())
owner_->UpdatePageActions();
}
-void PageActionImageView::OnIconChanged() {
+void PageActionImageView::OnIconUpdated() {
TabContents* tab_contents = owner_->GetTabContents();
if (tab_contents)
UpdateVisibility(tab_contents->web_contents(), current_url_);
}
+void PageActionImageView::OnIconChanged() {
+ OnIconUpdated();
+}
+
void PageActionImageView::ShowPopupWithURL(
const GURL& popup_url,
ExtensionPopup::ShowAction show_action) {
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.h ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698