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/views/extensions/browser_action_overflow_menu_contro
ller.h" | 5 #include "chrome/browser/ui/views/extensions/browser_action_overflow_menu_contro
ller.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
9 #include "chrome/browser/extensions/extension_context_menu_model.h" | 9 #include "chrome/browser/extensions/extension_context_menu_model.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 BrowserActionView* view = (*views_)[start_index_ + id - 1]; | 86 BrowserActionView* view = (*views_)[start_index_ + id - 1]; |
87 owner_->OnBrowserActionExecuted(view->button(), | 87 owner_->OnBrowserActionExecuted(view->button(), |
88 false); // inspect_with_devtools | 88 false); // inspect_with_devtools |
89 } | 89 } |
90 | 90 |
91 bool BrowserActionOverflowMenuController::ShowContextMenu( | 91 bool BrowserActionOverflowMenuController::ShowContextMenu( |
92 views::MenuItemView* source, | 92 views::MenuItemView* source, |
93 int id, | 93 int id, |
94 const gfx::Point& p, | 94 const gfx::Point& p, |
95 bool is_mouse_gesture) { | 95 bool is_mouse_gesture) { |
| 96 const Extension* extension = |
| 97 (*views_)[start_index_ + id - 1]->button()->extension(); |
| 98 if (!extension->ShowConfigureContextMenus()) |
| 99 return false; |
| 100 |
96 context_menu_contents_ = new ExtensionContextMenuModel( | 101 context_menu_contents_ = new ExtensionContextMenuModel( |
97 (*views_)[start_index_ + id - 1]->button()->extension(), | 102 extension, |
98 owner_->browser(), | 103 owner_->browser(), |
99 owner_); | 104 owner_); |
100 context_menu_menu_.reset(new views::Menu2(context_menu_contents_.get())); | 105 context_menu_menu_.reset(new views::Menu2(context_menu_contents_.get())); |
101 // This blocks until the user choses something or dismisses the menu. | 106 // This blocks until the user choses something or dismisses the menu. |
102 context_menu_menu_->RunContextMenuAt(p); | 107 context_menu_menu_->RunContextMenuAt(p); |
103 | 108 |
104 // The user is done with the context menu, so we can close the underlying | 109 // The user is done with the context menu, so we can close the underlying |
105 // menu. | 110 // menu. |
106 menu_->Cancel(); | 111 menu_->Cancel(); |
107 | 112 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 204 |
200 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( | 205 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( |
201 int id, size_t* index) { | 206 int id, size_t* index) { |
202 // The index of the view being dragged (GetCommand gives a 1-based index into | 207 // The index of the view being dragged (GetCommand gives a 1-based index into |
203 // the overflow menu). | 208 // the overflow menu). |
204 size_t view_index = owner_->VisibleBrowserActions() + id - 1; | 209 size_t view_index = owner_->VisibleBrowserActions() + id - 1; |
205 if (index) | 210 if (index) |
206 *index = view_index; | 211 *index = view_index; |
207 return owner_->GetBrowserActionViewAt(view_index); | 212 return owner_->GetBrowserActionViewAt(view_index); |
208 } | 213 } |
OLD | NEW |