| 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/utf_string_conversions.h" | 7 #include "base/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/api/commands/command_service_factory.h" | 9 #include "chrome/browser/extensions/api/commands/command_service_factory.h" |
| 10 #include "chrome/browser/extensions/extension_context_menu_model.h" | 10 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // Reconstructs the menu every time because the menu's contents are dynamic. | 196 // Reconstructs the menu every time because the menu's contents are dynamic. |
| 197 scoped_refptr<ExtensionContextMenuModel> context_menu_contents_( | 197 scoped_refptr<ExtensionContextMenuModel> context_menu_contents_( |
| 198 new ExtensionContextMenuModel(extension(), browser_, delegate_)); | 198 new ExtensionContextMenuModel(extension(), browser_, delegate_)); |
| 199 views::MenuModelAdapter menu_model_adapter(context_menu_contents_.get()); | 199 views::MenuModelAdapter menu_model_adapter(context_menu_contents_.get()); |
| 200 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu())); | 200 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu())); |
| 201 | 201 |
| 202 context_menu_ = menu_runner_->GetMenu(); | 202 context_menu_ = menu_runner_->GetMenu(); |
| 203 gfx::Point screen_loc; | 203 gfx::Point screen_loc; |
| 204 views::View::ConvertPointToScreen(this, &screen_loc); | 204 views::View::ConvertPointToScreen(this, &screen_loc); |
| 205 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()), | 205 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()), |
| 206 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) == | 206 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS | |
| 207 views::MenuRunner::MENU_DELETED) { | 207 views::MenuRunner::CONTEXT_MENU) == |
| 208 views::MenuRunner::MENU_DELETED) { |
| 208 return; | 209 return; |
| 209 } | 210 } |
| 210 | 211 |
| 211 menu_runner_.reset(); | 212 menu_runner_.reset(); |
| 212 SetButtonNotPushed(); | 213 SetButtonNotPushed(); |
| 213 context_menu_ = NULL; | 214 context_menu_ = NULL; |
| 214 } | 215 } |
| 215 | 216 |
| 216 void BrowserActionButton::OnImageLoaded(const gfx::Image& image, | 217 void BrowserActionButton::OnImageLoaded(const gfx::Image& image, |
| 217 const std::string& extension_id, | 218 const std::string& extension_id, |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 411 |
| 411 extensions::Command browser_action_command; | 412 extensions::Command browser_action_command; |
| 412 if (!only_if_active || !command_service->GetBrowserActionCommand( | 413 if (!only_if_active || !command_service->GetBrowserActionCommand( |
| 413 extension_->id(), | 414 extension_->id(), |
| 414 extensions::CommandService::ACTIVE_ONLY, | 415 extensions::CommandService::ACTIVE_ONLY, |
| 415 &browser_action_command, | 416 &browser_action_command, |
| 416 NULL)) { | 417 NULL)) { |
| 417 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); | 418 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); |
| 418 } | 419 } |
| 419 } | 420 } |
| OLD | NEW |