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

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

Issue 9968076: Remove Inspect Popup command from browser actions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Views compile failure Created 8 years, 8 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
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return std::max((kButtonWidth + kButtonPadding) * icon_count - kButtonPadding, 82 return std::max((kButtonWidth + kButtonPadding) * icon_count - kButtonPadding,
83 0); 83 0);
84 } 84 }
85 85
86 } // namespace 86 } // namespace
87 87
88 using ui::SimpleMenuModel; 88 using ui::SimpleMenuModel;
89 89
90 class BrowserActionButton : public content::NotificationObserver, 90 class BrowserActionButton : public content::NotificationObserver,
91 public ImageLoadingTracker::Observer, 91 public ImageLoadingTracker::Observer,
92 public ExtensionContextMenuModel::PopupDelegate,
93 public MenuGtk::Delegate { 92 public MenuGtk::Delegate {
94 public: 93 public:
95 BrowserActionButton(BrowserActionsToolbarGtk* toolbar, 94 BrowserActionButton(BrowserActionsToolbarGtk* toolbar,
96 const Extension* extension, 95 const Extension* extension,
97 ThemeServiceGtk* theme_provider) 96 ThemeServiceGtk* theme_provider)
98 : toolbar_(toolbar), 97 : toolbar_(toolbar),
99 extension_(extension), 98 extension_(extension),
100 image_(NULL), 99 image_(NULL),
101 tracker_(this), 100 tracker_(this),
102 tab_specific_icon_(NULL), 101 tab_specific_icon_(NULL),
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } else { 233 } else {
235 return default_skbitmap_; 234 return default_skbitmap_;
236 } 235 }
237 } 236 }
238 237
239 MenuGtk* GetContextMenu() { 238 MenuGtk* GetContextMenu() {
240 if (!extension_->ShowConfigureContextMenus()) 239 if (!extension_->ShowConfigureContextMenus())
241 return NULL; 240 return NULL;
242 241
243 context_menu_model_ = 242 context_menu_model_ =
244 new ExtensionContextMenuModel(extension_, toolbar_->browser(), this); 243 new ExtensionContextMenuModel(extension_, toolbar_->browser());
245 context_menu_.reset( 244 context_menu_.reset(
246 new MenuGtk(this, context_menu_model_.get())); 245 new MenuGtk(this, context_menu_model_.get()));
247 return context_menu_.get(); 246 return context_menu_.get();
248 } 247 }
249 248
250 private: 249 private:
251 // MenuGtk::Delegate implementation. 250 // MenuGtk::Delegate implementation.
252 virtual void StoppedShowing() { 251 virtual void StoppedShowing() {
253 button_->UnsetPaintOverride(); 252 button_->UnsetPaintOverride();
254 253
255 // If the context menu was showing for the overflow menu, re-assert the 254 // If the context menu was showing for the overflow menu, re-assert the
256 // grab that was shadowed. 255 // grab that was shadowed.
257 if (toolbar_->overflow_menu_.get()) 256 if (toolbar_->overflow_menu_.get())
258 gtk_util::GrabAllInput(toolbar_->overflow_menu_->widget()); 257 gtk_util::GrabAllInput(toolbar_->overflow_menu_->widget());
259 } 258 }
260 259
261 virtual void CommandWillBeExecuted() { 260 virtual void CommandWillBeExecuted() {
262 // If the context menu was showing for the overflow menu, and a command 261 // If the context menu was showing for the overflow menu, and a command
263 // is executed, then stop showing the overflow menu. 262 // is executed, then stop showing the overflow menu.
264 if (toolbar_->overflow_menu_.get()) 263 if (toolbar_->overflow_menu_.get())
265 toolbar_->overflow_menu_->Cancel(); 264 toolbar_->overflow_menu_->Cancel();
266 } 265 }
267 266
268 // Returns true to prevent further processing of the event that caused us to 267 // Returns true to prevent further processing of the event that caused us to
269 // show the popup, or false to continue processing. 268 // show the popup, or false to continue processing.
270 bool ShowPopup(bool devtools) { 269 bool ShowPopup() {
271 ExtensionAction* browser_action = extension_->browser_action(); 270 ExtensionAction* browser_action = extension_->browser_action();
272 271
273 int tab_id = toolbar_->GetCurrentTabId(); 272 int tab_id = toolbar_->GetCurrentTabId();
274 if (tab_id < 0) { 273 if (tab_id < 0) {
275 NOTREACHED() << "No current tab."; 274 NOTREACHED() << "No current tab.";
276 return true; 275 return true;
277 } 276 }
278 277
279 if (browser_action->HasPopup(tab_id)) { 278 if (browser_action->HasPopup(tab_id)) {
280 ExtensionPopupGtk::Show( 279 ExtensionPopupGtk::Show(
281 browser_action->GetPopupUrl(tab_id), toolbar_->browser(), 280 browser_action->GetPopupUrl(tab_id), toolbar_->browser(), widget());
282 widget(), devtools);
283 return true; 281 return true;
284 } 282 }
285 283
286 return false; 284 return false;
287 } 285 }
288 286
289 // ExtensionContextMenuModel::PopupDelegate implementation.
290 virtual void InspectPopup(ExtensionAction* action) {
291 ShowPopup(true);
292 }
293
294 void SetImage(GdkPixbuf* image) { 287 void SetImage(GdkPixbuf* image) {
295 if (!image_) { 288 if (!image_) {
296 image_ = gtk_image_new_from_pixbuf(image); 289 image_ = gtk_image_new_from_pixbuf(image);
297 gtk_button_set_image(GTK_BUTTON(button()), image_); 290 gtk_button_set_image(GTK_BUTTON(button()), image_);
298 } else { 291 } else {
299 gtk_image_set_from_pixbuf(GTK_IMAGE(image_), image); 292 gtk_image_set_from_pixbuf(GTK_IMAGE(image_), image);
300 } 293 }
301 } 294 }
302 295
303 static gboolean OnButtonPress(GtkWidget* widget, 296 static gboolean OnButtonPress(GtkWidget* widget,
304 GdkEventButton* event, 297 GdkEventButton* event,
305 BrowserActionButton* action) { 298 BrowserActionButton* action) {
306 if (event->button != 3) 299 if (event->button != 3)
307 return FALSE; 300 return FALSE;
308 301
309 MenuGtk* menu = action->GetContextMenu(); 302 MenuGtk* menu = action->GetContextMenu();
310 if (!menu) 303 if (!menu)
311 return FALSE; 304 return FALSE;
312 305
313 action->button_->SetPaintOverride(GTK_STATE_ACTIVE); 306 action->button_->SetPaintOverride(GTK_STATE_ACTIVE);
314 menu->PopupForWidget(widget, event->button, event->time); 307 menu->PopupForWidget(widget, event->button, event->time);
315 308
316 return TRUE; 309 return TRUE;
317 } 310 }
318 311
319 static void OnClicked(GtkWidget* widget, BrowserActionButton* action) { 312 static void OnClicked(GtkWidget* widget, BrowserActionButton* action) {
320 if (action->ShowPopup(false)) 313 if (action->ShowPopup())
321 return; 314 return;
322 315
323 ExtensionService* service = 316 ExtensionService* service =
324 action->toolbar_->browser()->profile()->GetExtensionService(); 317 action->toolbar_->browser()->profile()->GetExtensionService();
325 service->browser_event_router()->BrowserActionExecuted( 318 service->browser_event_router()->BrowserActionExecuted(
326 action->toolbar_->browser()->profile(), action->extension_->id(), 319 action->toolbar_->browser()->profile(), action->extension_->id(),
327 action->toolbar_->browser()); 320 action->toolbar_->browser());
328 } 321 }
329 322
330 static gboolean OnExposeEvent(GtkWidget* widget, 323 static gboolean OnExposeEvent(GtkWidget* widget,
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 ExtensionAction* browser_action = extension->browser_action(); 782 ExtensionAction* browser_action = extension->browser_action();
790 783
791 int tab_id = GetCurrentTabId(); 784 int tab_id = GetCurrentTabId();
792 if (tab_id < 0) { 785 if (tab_id < 0) {
793 NOTREACHED() << "No current tab."; 786 NOTREACHED() << "No current tab.";
794 return; 787 return;
795 } 788 }
796 789
797 if (browser_action->HasPopup(tab_id)) { 790 if (browser_action->HasPopup(tab_id)) {
798 ExtensionPopupGtk::Show( 791 ExtensionPopupGtk::Show(
799 browser_action->GetPopupUrl(tab_id), browser(), 792 browser_action->GetPopupUrl(tab_id), browser(), chevron());
800 chevron(),
801 false);
802 } else { 793 } else {
803 ExtensionService* service = browser()->profile()->GetExtensionService(); 794 ExtensionService* service = browser()->profile()->GetExtensionService();
804 service->browser_event_router()->BrowserActionExecuted( 795 service->browser_event_router()->BrowserActionExecuted(
805 browser()->profile(), extension->id(), browser()); 796 browser()->profile(), extension->id(), browser());
806 } 797 }
807 } 798 }
808 799
809 void BrowserActionsToolbarGtk::StoppedShowing() { 800 void BrowserActionsToolbarGtk::StoppedShowing() {
810 overflow_button_->UnsetPaintOverride(); 801 overflow_button_->UnsetPaintOverride();
811 } 802 }
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1069
1079 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), 1070 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root),
1080 event->time); 1071 event->time);
1081 return TRUE; 1072 return TRUE;
1082 } 1073 }
1083 1074
1084 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { 1075 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) {
1085 if (!resize_animation_.is_animating()) 1076 if (!resize_animation_.is_animating())
1086 UpdateChevronVisibility(); 1077 UpdateChevronVisibility();
1087 } 1078 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698