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/browser_action_view.h" | 5 #include "chrome/browser/ui/views/browser_action_view.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/api/commands/command_service.h" | 8 #include "chrome/browser/extensions/api/commands/command_service.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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 void BrowserActionButton::GetAccessibleState(ui::AccessibleViewState* state) { | 168 void BrowserActionButton::GetAccessibleState(ui::AccessibleViewState* state) { |
169 views::MenuButton::GetAccessibleState(state); | 169 views::MenuButton::GetAccessibleState(state); |
170 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | 170 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; |
171 } | 171 } |
172 | 172 |
173 void BrowserActionButton::ButtonPressed(views::Button* sender, | 173 void BrowserActionButton::ButtonPressed(views::Button* sender, |
174 const ui::Event& event) { | 174 const ui::Event& event) { |
175 delegate_->OnBrowserActionExecuted(this); | 175 delegate_->OnBrowserActionExecuted(this); |
176 } | 176 } |
177 | 177 |
178 void BrowserActionButton::ShowContextMenuForView(View* source, | 178 void BrowserActionButton::ShowContextMenuForView( |
179 const gfx::Point& point) { | 179 View* source, |
| 180 const gfx::Point& point, |
| 181 ui::ContextMenuSourceType source_type) { |
180 if (!extension()->ShowConfigureContextMenus()) | 182 if (!extension()->ShowConfigureContextMenus()) |
181 return; | 183 return; |
182 | 184 |
183 SetButtonPushed(); | 185 SetButtonPushed(); |
184 | 186 |
185 // Reconstructs the menu every time because the menu's contents are dynamic. | 187 // Reconstructs the menu every time because the menu's contents are dynamic. |
186 scoped_refptr<ExtensionContextMenuModel> context_menu_contents_( | 188 scoped_refptr<ExtensionContextMenuModel> context_menu_contents_( |
187 new ExtensionContextMenuModel(extension(), browser_, delegate_)); | 189 new ExtensionContextMenuModel(extension(), browser_, delegate_)); |
188 menu_runner_.reset(new views::MenuRunner(context_menu_contents_.get())); | 190 menu_runner_.reset(new views::MenuRunner(context_menu_contents_.get())); |
189 | 191 |
190 context_menu_ = menu_runner_->GetMenu(); | 192 context_menu_ = menu_runner_->GetMenu(); |
191 gfx::Point screen_loc; | 193 gfx::Point screen_loc; |
192 views::View::ConvertPointToScreen(this, &screen_loc); | 194 views::View::ConvertPointToScreen(this, &screen_loc); |
193 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()), | 195 if (menu_runner_->RunContextMenuAt(GetWidget(), NULL, |
194 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS | | 196 gfx::Rect(screen_loc, size()), |
| 197 source_type, views::MenuRunner::HAS_MNEMONICS | |
195 views::MenuRunner::CONTEXT_MENU) == | 198 views::MenuRunner::CONTEXT_MENU) == |
196 views::MenuRunner::MENU_DELETED) { | 199 views::MenuRunner::MENU_DELETED) { |
197 return; | 200 return; |
198 } | 201 } |
199 | 202 |
200 menu_runner_.reset(); | 203 menu_runner_.reset(); |
201 SetButtonNotPushed(); | 204 SetButtonNotPushed(); |
202 context_menu_ = NULL; | 205 context_menu_ = NULL; |
203 } | 206 } |
204 | 207 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 extensions::Command browser_action_command; | 406 extensions::Command browser_action_command; |
404 if (!only_if_active || !command_service->GetBrowserActionCommand( | 407 if (!only_if_active || !command_service->GetBrowserActionCommand( |
405 extension_->id(), | 408 extension_->id(), |
406 extensions::CommandService::ACTIVE_ONLY, | 409 extensions::CommandService::ACTIVE_ONLY, |
407 &browser_action_command, | 410 &browser_action_command, |
408 NULL)) { | 411 NULL)) { |
409 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); | 412 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); |
410 keybinding_.reset(NULL); | 413 keybinding_.reset(NULL); |
411 } | 414 } |
412 } | 415 } |
OLD | NEW |