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

Side by Side Diff: chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc

Issue 10700007: Page actions behave as disableable browser actions when script badges are enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" 5 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 SkBitmap image = extension_->browser_action()->GetIcon(tab_id); 230 SkBitmap image = extension_->browser_action()->GetIcon(tab_id);
231 if (!image.isNull()) { 231 if (!image.isNull()) {
232 GdkPixbuf* previous_gdk_icon = tab_specific_icon_; 232 GdkPixbuf* previous_gdk_icon = tab_specific_icon_;
233 tab_specific_icon_ = gfx::GdkPixbufFromSkBitmap(image); 233 tab_specific_icon_ = gfx::GdkPixbufFromSkBitmap(image);
234 SetImage(tab_specific_icon_); 234 SetImage(tab_specific_icon_);
235 if (previous_gdk_icon) 235 if (previous_gdk_icon)
236 g_object_unref(previous_gdk_icon); 236 g_object_unref(previous_gdk_icon);
237 } else if (default_icon_) { 237 } else if (default_icon_) {
238 SetImage(default_icon_); 238 SetImage(default_icon_);
239 } 239 }
240 bool enabled = extension_->browser_action()->GetIsVisible(tab_id);
241 gtk_widget_set_sensitive(button(), enabled ? TRUE : FALSE);
Evan Stade 2012/07/13 08:42:44 just enabled is fine.
Yoyo Zhou 2012/07/16 17:45:45 Done.
242
240 gtk_widget_queue_draw(button()); 243 gtk_widget_queue_draw(button());
241 } 244 }
242 245
243 SkBitmap GetIcon() { 246 SkBitmap GetIcon() {
244 const SkBitmap& image = extension_->browser_action()->GetIcon( 247 const SkBitmap& image = extension_->browser_action()->GetIcon(
245 toolbar_->GetCurrentTabId()); 248 toolbar_->GetCurrentTabId());
246 if (!image.isNull()) { 249 if (!image.isNull()) {
247 return image; 250 return image;
248 } else { 251 } else {
249 return default_skbitmap_; 252 return default_skbitmap_;
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 theme_service_->InitThemesFor(this); 577 theme_service_->InitThemesFor(this);
575 } 578 }
576 579
577 BrowserActionsToolbarGtk::~BrowserActionsToolbarGtk() { 580 BrowserActionsToolbarGtk::~BrowserActionsToolbarGtk() {
578 if (model_) 581 if (model_)
579 model_->RemoveObserver(this); 582 model_->RemoveObserver(this);
580 button_hbox_.Destroy(); 583 button_hbox_.Destroy();
581 hbox_.Destroy(); 584 hbox_.Destroy();
582 } 585 }
583 586
584 int BrowserActionsToolbarGtk::GetCurrentTabId() { 587 int BrowserActionsToolbarGtk::GetCurrentTabId() const {
585 TabContents* active_tab = chrome::GetActiveTabContents(browser_); 588 TabContents* active_tab = chrome::GetActiveTabContents(browser_);
586 if (!active_tab) 589 if (!active_tab)
587 return -1; 590 return -1;
588 591
589 return active_tab->restore_tab_helper()->session_id().id(); 592 return active_tab->restore_tab_helper()->session_id().id();
590 } 593 }
591 594
592 void BrowserActionsToolbarGtk::Update() { 595 void BrowserActionsToolbarGtk::Update() {
593 for (ExtensionButtonMap::iterator iter = extension_button_map_.begin(); 596 for (ExtensionButtonMap::iterator iter = extension_button_map_.begin();
594 iter != extension_button_map_.end(); ++iter) { 597 iter != extension_button_map_.end(); ++iter) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 void BrowserActionsToolbarGtk::AnimationEnded(const ui::Animation* animation) { 784 void BrowserActionsToolbarGtk::AnimationEnded(const ui::Animation* animation) {
782 gtk_widget_set_size_request(button_hbox_.get(), desired_width_, -1); 785 gtk_widget_set_size_request(button_hbox_.get(), desired_width_, -1);
783 UpdateChevronVisibility(); 786 UpdateChevronVisibility();
784 } 787 }
785 788
786 bool BrowserActionsToolbarGtk::IsCommandIdChecked(int command_id) const { 789 bool BrowserActionsToolbarGtk::IsCommandIdChecked(int command_id) const {
787 return false; 790 return false;
788 } 791 }
789 792
790 bool BrowserActionsToolbarGtk::IsCommandIdEnabled(int command_id) const { 793 bool BrowserActionsToolbarGtk::IsCommandIdEnabled(int command_id) const {
791 return true; 794 const Extension* extension = model_->GetExtensionByIndex(command_id);
795 return extension->browser_action()->GetIsVisible(GetCurrentTabId());
792 } 796 }
793 797
794 bool BrowserActionsToolbarGtk::GetAcceleratorForCommandId( 798 bool BrowserActionsToolbarGtk::GetAcceleratorForCommandId(
795 int command_id, 799 int command_id,
796 ui::Accelerator* accelerator) { 800 ui::Accelerator* accelerator) {
797 return false; 801 return false;
798 } 802 }
799 803
800 void BrowserActionsToolbarGtk::ExecuteCommand(int command_id) { 804 void BrowserActionsToolbarGtk::ExecuteCommand(int command_id) {
801 const Extension* extension = model_->GetExtensionByIndex(command_id); 805 const Extension* extension = model_->GetExtensionByIndex(command_id);
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1087
1084 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), 1088 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root),
1085 event->time); 1089 event->time);
1086 return TRUE; 1090 return TRUE;
1087 } 1091 }
1088 1092
1089 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { 1093 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) {
1090 if (!resize_animation_.is_animating()) 1094 if (!resize_animation_.is_animating())
1091 UpdateChevronVisibility(); 1095 UpdateChevronVisibility();
1092 } 1096 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698