OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
9 #include "chrome/browser/extensions/extension_browser_event_router.h" | 9 #include "chrome/browser/extensions/extension_browser_event_router.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 ExecuteAction(1, false); | 145 ExecuteAction(1, false); |
146 return true; | 146 return true; |
147 } | 147 } |
148 return false; | 148 return false; |
149 } | 149 } |
150 | 150 |
151 void PageActionImageView::ShowContextMenu(const gfx::Point& p, | 151 void PageActionImageView::ShowContextMenu(const gfx::Point& p, |
152 bool is_mouse_gesture) { | 152 bool is_mouse_gesture) { |
153 const Extension* extension = profile_->GetExtensionService()-> | 153 const Extension* extension = profile_->GetExtensionService()-> |
154 GetExtensionById(page_action()->extension_id(), false); | 154 GetExtensionById(page_action()->extension_id(), false); |
| 155 if (!extension->ShowConfigureContextMenus()) |
| 156 return; |
| 157 |
155 Browser* browser = BrowserView::GetBrowserViewForNativeWindow( | 158 Browser* browser = BrowserView::GetBrowserViewForNativeWindow( |
156 platform_util::GetTopLevel(GetWidget()->GetNativeView()))->browser(); | 159 platform_util::GetTopLevel(GetWidget()->GetNativeView()))->browser(); |
157 context_menu_contents_ = | 160 context_menu_contents_ = |
158 new ExtensionContextMenuModel(extension, browser, this); | 161 new ExtensionContextMenuModel(extension, browser, this); |
159 context_menu_menu_.reset(new views::Menu2(context_menu_contents_.get())); | 162 context_menu_menu_.reset(new views::Menu2(context_menu_contents_.get())); |
160 context_menu_menu_->RunContextMenuAt(p); | 163 context_menu_menu_->RunContextMenuAt(p); |
161 } | 164 } |
162 | 165 |
163 void PageActionImageView::OnImageLoaded( | 166 void PageActionImageView::OnImageLoaded( |
164 SkBitmap* image, ExtensionResource resource, int index) { | 167 SkBitmap* image, ExtensionResource resource, int index) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 void PageActionImageView::ExtensionPopupIsClosing(ExtensionPopup* popup) { | 241 void PageActionImageView::ExtensionPopupIsClosing(ExtensionPopup* popup) { |
239 DCHECK_EQ(popup_, popup); | 242 DCHECK_EQ(popup_, popup); |
240 // ExtensionPopup is ref-counted, so we don't need to delete it. | 243 // ExtensionPopup is ref-counted, so we don't need to delete it. |
241 popup_ = NULL; | 244 popup_ = NULL; |
242 } | 245 } |
243 | 246 |
244 void PageActionImageView::HidePopup() { | 247 void PageActionImageView::HidePopup() { |
245 if (popup_) | 248 if (popup_) |
246 popup_->Close(); | 249 popup_->Close(); |
247 } | 250 } |
OLD | NEW |