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

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: 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..3c88f786bd9a32cae447c1621b8f52f622fd8570 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"
@@ -87,8 +88,7 @@ void PageActionImageView::OnGestureEvent(ui::GestureEvent* event) {
}
void PageActionImageView::UpdateVisibility(content::WebContents* contents) {
- int tab_id = view_controller_->GetCurrentTabId();
-
+ int tab_id = GetCurrentTabId();
if (!contents ||
tab_id == -1 ||
(!preview_enabled_ && !extension_action()->GetIsVisible(tab_id))) {
@@ -111,7 +111,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 = GetCurrentTabId();
if (tab_id >= 0) {
view_controller_->extension_action()->PaintBadge(
canvas, GetLocalBounds(), tab_id);
@@ -119,7 +119,7 @@ void PageActionImageView::PaintChildren(gfx::Canvas* canvas,
}
void PageActionImageView::OnIconUpdated() {
- UpdateVisibility(GetCurrentWebContents());
+ UpdateVisibility(owner_->GetWebContents());
}
views::View* PageActionImageView::GetAsView() {
@@ -151,8 +151,9 @@ views::MenuButton* PageActionImageView::GetContextMenuButton() {
return NULL; // No menu button for page action views.
}
-content::WebContents* PageActionImageView::GetCurrentWebContents() {
- return owner_->GetWebContents();
+int PageActionImageView::GetCurrentTabId() const {
+ content::WebContents* web_contents = owner_->GetWebContents();
+ return web_contents ? SessionTabHelper::IdForTab(web_contents) : -1;
}
void PageActionImageView::HideActivePopup() {

Powered by Google App Engine
This is Rietveld 408576698