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/location_bar/page_action_image_view.h" | 5 #include "chrome/browser/ui/views/location_bar/page_action_image_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_icon_factory.h" | 10 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 const gfx::Point& point, | 152 const gfx::Point& point, |
153 ui::MenuSourceType source_type) { | 153 ui::MenuSourceType source_type) { |
154 const Extension* extension = extensions::ExtensionRegistry::Get( | 154 const Extension* extension = extensions::ExtensionRegistry::Get( |
155 owner_->profile())->enabled_extensions().GetByID( | 155 owner_->profile())->enabled_extensions().GetByID( |
156 page_action()->extension_id()); | 156 page_action()->extension_id()); |
157 if (!extension->ShowConfigureContextMenus()) | 157 if (!extension->ShowConfigureContextMenus()) |
158 return; | 158 return; |
159 | 159 |
160 scoped_refptr<ExtensionContextMenuModel> context_menu_model( | 160 scoped_refptr<ExtensionContextMenuModel> context_menu_model( |
161 new ExtensionContextMenuModel(extension, browser_, this)); | 161 new ExtensionContextMenuModel(extension, browser_, this)); |
162 menu_runner_.reset(new views::MenuRunner(context_menu_model.get())); | 162 menu_runner_.reset(new views::MenuRunner( |
| 163 context_menu_model.get(), |
| 164 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU)); |
163 gfx::Point screen_loc; | 165 gfx::Point screen_loc; |
164 views::View::ConvertPointToScreen(this, &screen_loc); | 166 views::View::ConvertPointToScreen(this, &screen_loc); |
165 if (menu_runner_->RunMenuAt( | 167 if (menu_runner_->RunMenuAt(GetWidget(), |
166 GetWidget(), | 168 NULL, |
167 NULL, | 169 gfx::Rect(screen_loc, size()), |
168 gfx::Rect(screen_loc, size()), | 170 views::MENU_ANCHOR_TOPLEFT, |
169 views::MENU_ANCHOR_TOPLEFT, | 171 source_type) == views::MenuRunner::MENU_DELETED) { |
170 source_type, | |
171 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == | |
172 views::MenuRunner::MENU_DELETED) { | |
173 return; | 172 return; |
174 } | 173 } |
175 } | 174 } |
176 | 175 |
177 bool PageActionImageView::AcceleratorPressed( | 176 bool PageActionImageView::AcceleratorPressed( |
178 const ui::Accelerator& accelerator) { | 177 const ui::Accelerator& accelerator) { |
179 DCHECK(visible()); // Should not have happened due to CanHandleAccelerator. | 178 DCHECK(visible()); // Should not have happened due to CanHandleAccelerator. |
180 | 179 |
181 const std::string extension_id = page_action()->extension_id(); | 180 const std::string extension_id = page_action()->extension_id(); |
182 const ui::AcceleratorManager::HandlerPriority priority = | 181 const ui::AcceleratorManager::HandlerPriority priority = |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 259 |
261 popup_ = ExtensionPopup::ShowPopup(popup_url, browser_, this, arrow, | 260 popup_ = ExtensionPopup::ShowPopup(popup_url, browser_, this, arrow, |
262 show_action); | 261 show_action); |
263 popup_->GetWidget()->AddObserver(this); | 262 popup_->GetWidget()->AddObserver(this); |
264 } | 263 } |
265 | 264 |
266 void PageActionImageView::HidePopup() { | 265 void PageActionImageView::HidePopup() { |
267 if (popup_) | 266 if (popup_) |
268 popup_->GetWidget()->Close(); | 267 popup_->GetWidget()->Close(); |
269 } | 268 } |
OLD | NEW |