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

Unified Diff: chrome/browser/ui/views/location_bar/page_action_image_view.cc

Issue 661493004: Add infrastructure for Chrome Actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sky's I Created 6 years, 2 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 bc0cc1c6173927f0b6d551d61c0611007d0be7d5..f60de16194395472b07db46f7df52caae769344a 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
@@ -8,6 +8,7 @@
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "extensions/browser/extension_registry.h"
@@ -26,16 +27,15 @@ PageActionImageView::PageActionImageView(LocationBarView* owner,
extensions::ExtensionRegistry::Get(browser->profile())->
enabled_extensions().GetByID(page_action->extension_id()),
browser,
- page_action,
- this)),
+ page_action)),
owner_(owner),
preview_enabled_(false) {
// There should be an associated focus manager so that we can safely register
// accelerators for commands.
DCHECK(GetFocusManagerForAccelerator());
SetAccessibilityFocusable(true);
+ view_controller_->SetDelegate(this);
view_controller_->RegisterCommand();
- set_context_menu_controller(view_controller_.get());
}
PageActionImageView::~PageActionImageView() {
@@ -87,8 +87,7 @@ void PageActionImageView::OnGestureEvent(ui::GestureEvent* event) {
}
void PageActionImageView::UpdateVisibility(content::WebContents* contents) {
- int tab_id = view_controller_->GetCurrentTabId();
-
+ int tab_id = SessionTabHelper::IdForTab(contents);
if (!contents ||
tab_id == -1 ||
(!preview_enabled_ && !extension_action()->GetIsVisible(tab_id))) {
@@ -101,7 +100,7 @@ void PageActionImageView::UpdateVisibility(content::WebContents* contents) {
SetTooltipText(base::UTF8ToUTF16(tooltip_));
// Set the image.
- gfx::Image icon = view_controller_->GetIcon(tab_id);
+ gfx::Image icon = view_controller_->GetIcon(contents);
if (!icon.IsEmpty())
SetImage(*icon.ToImageSkia());
@@ -111,7 +110,7 @@ void PageActionImageView::UpdateVisibility(content::WebContents* contents) {
void PageActionImageView::PaintChildren(gfx::Canvas* canvas,
const views::CullSet& cull_set) {
View::PaintChildren(canvas, cull_set);
- int tab_id = view_controller_->GetCurrentTabId();
+ int tab_id = SessionTabHelper::IdForTab(GetCurrentWebContents());
if (tab_id >= 0) {
view_controller_->extension_action()->PaintBadge(
canvas, GetLocalBounds(), tab_id);
@@ -119,7 +118,7 @@ void PageActionImageView::PaintChildren(gfx::Canvas* canvas,
}
void PageActionImageView::OnIconUpdated() {
- UpdateVisibility(GetCurrentWebContents());
+ UpdateVisibility(owner_->GetWebContents());
}
views::View* PageActionImageView::GetAsView() {
@@ -151,7 +150,7 @@ views::MenuButton* PageActionImageView::GetContextMenuButton() {
return NULL; // No menu button for page action views.
}
-content::WebContents* PageActionImageView::GetCurrentWebContents() {
+content::WebContents* PageActionImageView::GetCurrentWebContents() const {
return owner_->GetWebContents();
}

Powered by Google App Engine
This is Rietveld 408576698