| OLD | NEW |
| 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/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/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_action.h" | 9 #include "chrome/browser/extensions/extension_action.h" |
| 10 #include "chrome/browser/extensions/extension_action_manager.h" | 10 #include "chrome/browser/extensions/extension_action_manager.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 icon_updaters_.clear(); | 130 icon_updaters_.clear(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 bool BrowserActionOverflowMenuController::IsCommandEnabled(int id) const { | 133 bool BrowserActionOverflowMenuController::IsCommandEnabled(int id) const { |
| 134 BrowserActionView* view = (*views_)[start_index_ + id - 1]; | 134 BrowserActionView* view = (*views_)[start_index_ + id - 1]; |
| 135 return view->button()->IsEnabled(owner_->GetCurrentTabId()); | 135 return view->button()->IsEnabled(owner_->GetCurrentTabId()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void BrowserActionOverflowMenuController::ExecuteCommand(int id) { | 138 void BrowserActionOverflowMenuController::ExecuteCommand(int id) { |
| 139 BrowserActionView* view = (*views_)[start_index_ + id - 1]; | 139 BrowserActionView* view = (*views_)[start_index_ + id - 1]; |
| 140 owner_->OnBrowserActionExecuted(view->button()); | 140 view->button()->ExecuteBrowserAction(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool BrowserActionOverflowMenuController::ShowContextMenu( | 143 bool BrowserActionOverflowMenuController::ShowContextMenu( |
| 144 views::MenuItemView* source, | 144 views::MenuItemView* source, |
| 145 int id, | 145 int id, |
| 146 const gfx::Point& p, | 146 const gfx::Point& p, |
| 147 ui::MenuSourceType source_type) { | 147 ui::MenuSourceType source_type) { |
| 148 const extensions::Extension* extension = | 148 BrowserActionButton* button = (*views_)[start_index_ + id - 1]->button(); |
| 149 (*views_)[start_index_ + id - 1]->button()->extension(); | 149 if (!button->extension()->ShowConfigureContextMenus()) |
| 150 if (!extension->ShowConfigureContextMenus()) | |
| 151 return false; | 150 return false; |
| 152 | 151 |
| 153 scoped_refptr<ExtensionContextMenuModel> context_menu_contents = | 152 scoped_refptr<ExtensionContextMenuModel> context_menu_contents = |
| 154 new ExtensionContextMenuModel(extension, browser_, owner_); | 153 new ExtensionContextMenuModel(button->extension(), browser_, button); |
| 155 views::MenuRunner context_menu_runner(context_menu_contents.get(), | 154 views::MenuRunner context_menu_runner(context_menu_contents.get(), |
| 156 views::MenuRunner::HAS_MNEMONICS | | 155 views::MenuRunner::HAS_MNEMONICS | |
| 157 views::MenuRunner::IS_NESTED | | 156 views::MenuRunner::IS_NESTED | |
| 158 views::MenuRunner::CONTEXT_MENU); | 157 views::MenuRunner::CONTEXT_MENU); |
| 159 | 158 |
| 160 // We can ignore the result as we delete ourself. | 159 // We can ignore the result as we delete ourself. |
| 161 // This blocks until the user choses something or dismisses the menu. | 160 // This blocks until the user choses something or dismisses the menu. |
| 162 ignore_result(context_menu_runner.RunMenuAt(menu_button_->GetWidget(), | 161 ignore_result(context_menu_runner.RunMenuAt(menu_button_->GetWidget(), |
| 163 NULL, | 162 NULL, |
| 164 gfx::Rect(p, gfx::Size()), | 163 gfx::Rect(p, gfx::Size()), |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 258 |
| 260 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( | 259 BrowserActionView* BrowserActionOverflowMenuController::ViewForId( |
| 261 int id, size_t* index) { | 260 int id, size_t* index) { |
| 262 // The index of the view being dragged (GetCommand gives a 1-based index into | 261 // The index of the view being dragged (GetCommand gives a 1-based index into |
| 263 // the overflow menu). | 262 // the overflow menu). |
| 264 size_t view_index = owner_->VisibleBrowserActions() + id - 1; | 263 size_t view_index = owner_->VisibleBrowserActions() + id - 1; |
| 265 if (index) | 264 if (index) |
| 266 *index = view_index; | 265 *index = view_index; |
| 267 return owner_->GetBrowserActionViewAt(view_index); | 266 return owner_->GetBrowserActionViewAt(view_index); |
| 268 } | 267 } |
| OLD | NEW |