OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/extensions/browser_action_overflow_menu_controlle
r.h" | 5 #include "chrome/browser/views/extensions/browser_action_overflow_menu_controlle
r.h" |
6 | 6 |
7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/profile.h" |
10 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
11 #include "chrome/browser/views/browser_actions_container.h" | 12 #include "chrome/browser/views/browser_actions_container.h" |
12 #include "chrome/browser/views/extensions/browser_action_drag_data.h" | 13 #include "chrome/browser/views/extensions/browser_action_drag_data.h" |
13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
14 #include "views/controls/menu/menu_item_view.h" | 15 #include "views/controls/menu/menu_item_view.h" |
15 | 16 |
16 BrowserActionOverflowMenuController::BrowserActionOverflowMenuController( | 17 BrowserActionOverflowMenuController::BrowserActionOverflowMenuController( |
17 BrowserActionsContainer* owner, | 18 BrowserActionsContainer* owner, |
18 views::MenuButton* menu_button, | 19 views::MenuButton* menu_button, |
19 const std::vector<BrowserActionView*>& views, | 20 const std::vector<BrowserActionView*>& views, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 74 } |
74 return true; | 75 return true; |
75 } | 76 } |
76 | 77 |
77 void BrowserActionOverflowMenuController::CancelMenu() { | 78 void BrowserActionOverflowMenuController::CancelMenu() { |
78 menu_->Cancel(); | 79 menu_->Cancel(); |
79 } | 80 } |
80 | 81 |
81 void BrowserActionOverflowMenuController::ExecuteCommand(int id) { | 82 void BrowserActionOverflowMenuController::ExecuteCommand(int id) { |
82 BrowserActionView* view = (*views_)[start_index_ + id - 1]; | 83 BrowserActionView* view = (*views_)[start_index_ + id - 1]; |
83 owner_->OnBrowserActionExecuted(view->button()); | 84 owner_->OnBrowserActionExecuted(view->button(), |
| 85 false); // inspect_with_devtools |
84 } | 86 } |
85 | 87 |
86 bool BrowserActionOverflowMenuController::ShowContextMenu( | 88 bool BrowserActionOverflowMenuController::ShowContextMenu( |
87 views::MenuItemView* source, | 89 views::MenuItemView* source, |
88 int id, | 90 int id, |
89 const gfx::Point& p, | 91 const gfx::Point& p, |
90 bool is_mouse_gesture) { | 92 bool is_mouse_gesture) { |
91 // This blocks until the user choses something or dismisses the menu. | 93 // This blocks until the user choses something or dismisses the menu. |
92 owner_->GetContextMenu()->Run( | 94 owner_->GetContextMenu()->Run( |
93 (*views_)[start_index_ + id - 1]->button()->extension(), p); | 95 (*views_)[start_index_ + id - 1]->button()->extension(), |
| 96 (*views_)[start_index_ + id - 1]->button()->extension()->browser_action(), |
| 97 owner_, |
| 98 owner_->profile()->GetPrefs(), |
| 99 p); |
94 | 100 |
95 // The user is done with the context menu, so we can close the underlying | 101 // The user is done with the context menu, so we can close the underlying |
96 // menu. | 102 // menu. |
97 menu_->Cancel(); | 103 menu_->Cancel(); |
98 | 104 |
99 return true; | 105 return true; |
100 } | 106 } |
101 | 107 |
102 void BrowserActionOverflowMenuController::DropMenuClosed( | 108 void BrowserActionOverflowMenuController::DropMenuClosed( |
103 views::MenuItemView* menu) { | 109 views::MenuItemView* menu) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 196 |
191 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( | 197 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( |
192 int id, size_t* index) { | 198 int id, size_t* index) { |
193 // The index of the view being dragged (GetCommand gives a 1-based index into | 199 // The index of the view being dragged (GetCommand gives a 1-based index into |
194 // the overflow menu). | 200 // the overflow menu). |
195 size_t view_index = owner_->VisibleBrowserActions() + id - 1; | 201 size_t view_index = owner_->VisibleBrowserActions() + id - 1; |
196 if (index) | 202 if (index) |
197 *index = view_index; | 203 *index = view_index; |
198 return owner_->GetBrowserActionViewAt(view_index); | 204 return owner_->GetBrowserActionViewAt(view_index); |
199 } | 205 } |
OLD | NEW |