OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 const SkBitmap& image = extension_->browser_action()->GetIcon( | 195 const SkBitmap& image = extension_->browser_action()->GetIcon( |
196 toolbar_->GetCurrentTabId()); | 196 toolbar_->GetCurrentTabId()); |
197 if (!image.isNull()) { | 197 if (!image.isNull()) { |
198 return image; | 198 return image; |
199 } else { | 199 } else { |
200 return default_skbitmap_; | 200 return default_skbitmap_; |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 MenuGtk* GetContextMenu() { | 204 MenuGtk* GetContextMenu() { |
| 205 if (!extension_->ShowConfigureContextMenus()) |
| 206 return NULL; |
| 207 |
205 context_menu_model_ = | 208 context_menu_model_ = |
206 new ExtensionContextMenuModel(extension_, toolbar_->browser(), this); | 209 new ExtensionContextMenuModel(extension_, toolbar_->browser(), this); |
207 context_menu_.reset( | 210 context_menu_.reset( |
208 new MenuGtk(this, context_menu_model_.get())); | 211 new MenuGtk(this, context_menu_model_.get())); |
209 return context_menu_.get(); | 212 return context_menu_.get(); |
210 } | 213 } |
211 | 214 |
212 private: | 215 private: |
213 // MenuGtk::Delegate implementation. | 216 // MenuGtk::Delegate implementation. |
214 virtual void StoppedShowing() { | 217 virtual void StoppedShowing() { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 gtk_image_set_from_pixbuf(GTK_IMAGE(image_), image); | 264 gtk_image_set_from_pixbuf(GTK_IMAGE(image_), image); |
262 } | 265 } |
263 } | 266 } |
264 | 267 |
265 static gboolean OnButtonPress(GtkWidget* widget, | 268 static gboolean OnButtonPress(GtkWidget* widget, |
266 GdkEvent* event, | 269 GdkEvent* event, |
267 BrowserActionButton* action) { | 270 BrowserActionButton* action) { |
268 if (event->button.button != 3) | 271 if (event->button.button != 3) |
269 return FALSE; | 272 return FALSE; |
270 | 273 |
| 274 MenuGtk* menu = action->GetContextMenu(); |
| 275 if (!menu) |
| 276 return FALSE; |
| 277 |
271 action->button_->SetPaintOverride(GTK_STATE_ACTIVE); | 278 action->button_->SetPaintOverride(GTK_STATE_ACTIVE); |
272 action->GetContextMenu()->Popup(widget, event); | 279 menu->Popup(widget, event); |
273 | 280 |
274 return TRUE; | 281 return TRUE; |
275 } | 282 } |
276 | 283 |
277 static void OnClicked(GtkWidget* widget, BrowserActionButton* action) { | 284 static void OnClicked(GtkWidget* widget, BrowserActionButton* action) { |
278 if (action->ShowPopup(false)) | 285 if (action->ShowPopup(false)) |
279 return; | 286 return; |
280 | 287 |
281 ExtensionService* service = | 288 ExtensionService* service = |
282 action->toolbar_->browser()->profile()->GetExtensionService(); | 289 action->toolbar_->browser()->profile()->GetExtensionService(); |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 item_index = model_->IncognitoIndexToOriginal(item_index); | 939 item_index = model_->IncognitoIndexToOriginal(item_index); |
933 | 940 |
934 const Extension* extension = model_->GetExtensionByIndex(item_index); | 941 const Extension* extension = model_->GetExtensionByIndex(item_index); |
935 ExtensionButtonMap::iterator it = extension_button_map_.find( | 942 ExtensionButtonMap::iterator it = extension_button_map_.find( |
936 extension->id()); | 943 extension->id()); |
937 if (it == extension_button_map_.end()) { | 944 if (it == extension_button_map_.end()) { |
938 NOTREACHED(); | 945 NOTREACHED(); |
939 return FALSE; | 946 return FALSE; |
940 } | 947 } |
941 | 948 |
942 it->second.get()->GetContextMenu()->PopupAsContext(event->time); | 949 MenuGtk* menu = it->second.get()->GetContextMenu(); |
| 950 if (!menu) |
| 951 return FALSE; |
| 952 |
| 953 menu->PopupAsContext(event->time); |
943 return TRUE; | 954 return TRUE; |
944 } | 955 } |
945 | 956 |
946 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 957 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
947 if (!resize_animation_.is_animating()) | 958 if (!resize_animation_.is_animating()) |
948 UpdateChevronVisibility(); | 959 UpdateChevronVisibility(); |
949 } | 960 } |
OLD | NEW |