OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/browser_action_view.h" | 5 #include "chrome/browser/ui/views/toolbar/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/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/extensions/api/commands/command_service.h" | 9 #include "chrome/browser/extensions/api/commands/command_service.h" |
10 #include "chrome/browser/extensions/extension_action.h" | 10 #include "chrome/browser/extensions/extension_action.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "extensions/common/manifest_constants.h" | 21 #include "extensions/common/manifest_constants.h" |
22 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
23 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
24 #include "ui/accessibility/ax_view_state.h" | 24 #include "ui/accessibility/ax_view_state.h" |
25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
27 #include "ui/events/event.h" | 27 #include "ui/events/event.h" |
28 #include "ui/gfx/image/image_skia.h" | 28 #include "ui/gfx/image/image_skia.h" |
29 #include "ui/gfx/image/image_skia_operations.h" | 29 #include "ui/gfx/image/image_skia_operations.h" |
30 #include "ui/gfx/image/image_skia_source.h" | 30 #include "ui/gfx/image/image_skia_source.h" |
| 31 #include "ui/views/controls/menu/menu_item_view.h" |
31 #include "ui/views/controls/menu/menu_runner.h" | 32 #include "ui/views/controls/menu/menu_runner.h" |
32 | 33 |
33 using extensions::Extension; | 34 using extensions::Extension; |
34 | 35 |
35 //////////////////////////////////////////////////////////////////////////////// | 36 //////////////////////////////////////////////////////////////////////////////// |
36 // BrowserActionView | 37 // BrowserActionView |
37 | 38 |
38 bool BrowserActionView::Delegate::NeedToShowMultipleIconStates() const { | 39 bool BrowserActionView::Delegate::NeedToShowMultipleIconStates() const { |
39 return true; | 40 return true; |
40 } | 41 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 SetButtonPushed(); | 180 SetButtonPushed(); |
180 | 181 |
181 // Reconstructs the menu every time because the menu's contents are dynamic. | 182 // Reconstructs the menu every time because the menu's contents are dynamic. |
182 scoped_refptr<ExtensionContextMenuModel> context_menu_contents_( | 183 scoped_refptr<ExtensionContextMenuModel> context_menu_contents_( |
183 new ExtensionContextMenuModel(extension(), browser_, delegate_)); | 184 new ExtensionContextMenuModel(extension(), browser_, delegate_)); |
184 menu_runner_.reset(new views::MenuRunner(context_menu_contents_.get())); | 185 menu_runner_.reset(new views::MenuRunner(context_menu_contents_.get())); |
185 | 186 |
186 context_menu_ = menu_runner_->GetMenu(); | 187 context_menu_ = menu_runner_->GetMenu(); |
187 gfx::Point screen_loc; | 188 gfx::Point screen_loc; |
188 views::View::ConvertPointToScreen(this, &screen_loc); | 189 views::View::ConvertPointToScreen(this, &screen_loc); |
189 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()), | 190 if (menu_runner_->RunMenuAt( |
190 views::MenuItemView::TOPLEFT, source_type, | 191 GetWidget(), |
| 192 NULL, |
| 193 gfx::Rect(screen_loc, size()), |
| 194 views::MENU_ANCHOR_TOPLEFT, |
| 195 source_type, |
191 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == | 196 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == |
192 views::MenuRunner::MENU_DELETED) { | 197 views::MenuRunner::MENU_DELETED) { |
193 return; | 198 return; |
194 } | 199 } |
195 | 200 |
196 menu_runner_.reset(); | 201 menu_runner_.reset(); |
197 SetButtonNotPushed(); | 202 SetButtonNotPushed(); |
198 context_menu_ = NULL; | 203 context_menu_ = NULL; |
199 } | 204 } |
200 | 205 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 extensions::Command browser_action_command; | 420 extensions::Command browser_action_command; |
416 if (!only_if_active || !command_service->GetBrowserActionCommand( | 421 if (!only_if_active || !command_service->GetBrowserActionCommand( |
417 extension_->id(), | 422 extension_->id(), |
418 extensions::CommandService::ACTIVE_ONLY, | 423 extensions::CommandService::ACTIVE_ONLY, |
419 &browser_action_command, | 424 &browser_action_command, |
420 NULL)) { | 425 NULL)) { |
421 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); | 426 GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); |
422 keybinding_.reset(NULL); | 427 keybinding_.reset(NULL); |
423 } | 428 } |
424 } | 429 } |
OLD | NEW |