| 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_browser_event_router.h" | 8 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_tab_util.h" | 10 #include "chrome/browser/extensions/extension_tab_util.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 154 } |
| 155 | 155 |
| 156 void PageActionImageView::ShowContextMenu(const gfx::Point& p, | 156 void PageActionImageView::ShowContextMenu(const gfx::Point& p, |
| 157 bool is_mouse_gesture) { | 157 bool is_mouse_gesture) { |
| 158 const Extension* extension = owner_->profile()->GetExtensionService()-> | 158 const Extension* extension = owner_->profile()->GetExtensionService()-> |
| 159 GetExtensionById(page_action()->extension_id(), false); | 159 GetExtensionById(page_action()->extension_id(), false); |
| 160 if (!extension->ShowConfigureContextMenus()) | 160 if (!extension->ShowConfigureContextMenus()) |
| 161 return; | 161 return; |
| 162 | 162 |
| 163 scoped_refptr<ExtensionContextMenuModel> context_menu_model( | 163 scoped_refptr<ExtensionContextMenuModel> context_menu_model( |
| 164 new ExtensionContextMenuModel(extension, browser_, this)); | 164 new ExtensionContextMenuModel(extension, browser_)); |
| 165 views::MenuModelAdapter menu_model_adapter(context_menu_model.get()); | 165 views::MenuModelAdapter menu_model_adapter(context_menu_model.get()); |
| 166 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu())); | 166 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu())); |
| 167 gfx::Point screen_loc; | 167 gfx::Point screen_loc; |
| 168 views::View::ConvertPointToScreen(this, &screen_loc); | 168 views::View::ConvertPointToScreen(this, &screen_loc); |
| 169 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()), | 169 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()), |
| 170 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) == | 170 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) == |
| 171 views::MenuRunner::MENU_DELETED) | 171 views::MenuRunner::MENU_DELETED) |
| 172 return; | 172 return; |
| 173 } | 173 } |
| 174 | 174 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 if (iter != page_action_icons_.end()) | 251 if (iter != page_action_icons_.end()) |
| 252 icon = iter->second; | 252 icon = iter->second; |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 if (!icon.isNull()) | 255 if (!icon.isNull()) |
| 256 SetImage(&icon); | 256 SetImage(&icon); |
| 257 | 257 |
| 258 SetVisible(true); | 258 SetVisible(true); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void PageActionImageView::InspectPopup(ExtensionAction* action) { | |
| 262 ExecuteAction(1, // Left-click. | |
| 263 true); // |inspect_with_devtools|. | |
| 264 } | |
| 265 | |
| 266 void PageActionImageView::OnWidgetClosing(views::Widget* widget) { | 261 void PageActionImageView::OnWidgetClosing(views::Widget* widget) { |
| 267 DCHECK_EQ(popup_->GetWidget(), widget); | 262 DCHECK_EQ(popup_->GetWidget(), widget); |
| 268 popup_->GetWidget()->RemoveObserver(this); | 263 popup_->GetWidget()->RemoveObserver(this); |
| 269 popup_ = NULL; | 264 popup_ = NULL; |
| 270 } | 265 } |
| 271 | 266 |
| 272 void PageActionImageView::Observe(int type, | 267 void PageActionImageView::Observe(int type, |
| 273 const content::NotificationSource& source, | 268 const content::NotificationSource& source, |
| 274 const content::NotificationDetails& details) { | 269 const content::NotificationDetails& details) { |
| 275 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNLOADED, type); | 270 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNLOADED, type); |
| 276 const Extension* unloaded_extension = | 271 const Extension* unloaded_extension = |
| 277 content::Details<UnloadedExtensionInfo>(details)->extension; | 272 content::Details<UnloadedExtensionInfo>(details)->extension; |
| 278 if (page_action_ == unloaded_extension ->page_action()) | 273 if (page_action_ == unloaded_extension ->page_action()) |
| 279 owner_->UpdatePageActions(); | 274 owner_->UpdatePageActions(); |
| 280 } | 275 } |
| 281 | 276 |
| 282 void PageActionImageView::HidePopup() { | 277 void PageActionImageView::HidePopup() { |
| 283 if (popup_) | 278 if (popup_) |
| 284 popup_->GetWidget()->Close(); | 279 popup_->GetWidget()->Close(); |
| 285 } | 280 } |
| OLD | NEW |