| 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/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_browser_event_router.h" | 10 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 11 #include "chrome/browser/extensions/extension_context_menu_model.h" | 11 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/extensions/extension_tab_helper.h" | 13 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 14 #include "chrome/browser/extensions/extension_tab_util.h" | 14 #include "chrome/browser/extensions/extension_tab_util.h" |
| 15 #include "chrome/browser/extensions/location_bar_controller.h" | 15 #include "chrome/browser/extensions/location_bar_controller.h" |
| 16 #include "chrome/browser/platform_util.h" | 16 #include "chrome/browser/platform_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser_list.h" | 18 #include "chrome/browser/ui/browser_list.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 20 #include "chrome/browser/ui/views/frame/browser_view.h" | 20 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 21 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 21 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 23 #include "chrome/common/extensions/extension.h" | 23 #include "chrome/common/extensions/extension.h" |
| 24 #include "chrome/common/extensions/extension_action.h" | 24 #include "chrome/common/extensions/extension_action.h" |
| 25 #include "chrome/common/extensions/extension_manifest_constants.h" | 25 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 26 #include "chrome/common/extensions/extension_resource.h" | 26 #include "chrome/common/extensions/extension_resource.h" |
| 27 #include "content/public/browser/notification_details.h" | 27 #include "content/public/browser/notification_details.h" |
| 28 #include "content/public/browser/notification_source.h" | 28 #include "content/public/browser/notification_source.h" |
| 29 #include "ui/base/accessibility/accessible_view_state.h" | 29 #include "ui/base/accessibility/accessible_view_state.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 PageActionImageView::~PageActionImageView() { | 86 PageActionImageView::~PageActionImageView() { |
| 87 if (keybinding_.get() && owner_->GetFocusManager()) | 87 if (keybinding_.get() && owner_->GetFocusManager()) |
| 88 owner_->GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); | 88 owner_->GetFocusManager()->UnregisterAccelerator(*keybinding_.get(), this); |
| 89 | 89 |
| 90 if (popup_) | 90 if (popup_) |
| 91 popup_->GetWidget()->RemoveObserver(this); | 91 popup_->GetWidget()->RemoveObserver(this); |
| 92 HidePopup(); | 92 HidePopup(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void PageActionImageView::ExecuteAction(int button) { | 95 void PageActionImageView::ExecuteAction(int button) { |
| 96 TabContentsWrapper* tab_contents = owner_->GetTabContentsWrapper(); | 96 TabContents* tab_contents = owner_->GetTabContents(); |
| 97 if (!tab_contents) | 97 if (!tab_contents) |
| 98 return; | 98 return; |
| 99 | 99 |
| 100 LocationBarController* controller = | 100 LocationBarController* controller = |
| 101 tab_contents->extension_tab_helper()->location_bar_controller(); | 101 tab_contents->extension_tab_helper()->location_bar_controller(); |
| 102 | 102 |
| 103 // 1 is left click. | 103 // 1 is left click. |
| 104 switch (controller->OnClicked(page_action_->extension_id(), 1)) { | 104 switch (controller->OnClicked(page_action_->extension_id(), 1)) { |
| 105 case LocationBarController::ACTION_NONE: | 105 case LocationBarController::ACTION_NONE: |
| 106 break; | 106 break; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 const Extension* unloaded_extension = | 293 const Extension* unloaded_extension = |
| 294 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; | 294 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; |
| 295 if (page_action_ == unloaded_extension ->page_action()) | 295 if (page_action_ == unloaded_extension ->page_action()) |
| 296 owner_->UpdatePageActions(); | 296 owner_->UpdatePageActions(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void PageActionImageView::HidePopup() { | 299 void PageActionImageView::HidePopup() { |
| 300 if (popup_) | 300 if (popup_) |
| 301 popup_->GetWidget()->Close(); | 301 popup_->GetWidget()->Close(); |
| 302 } | 302 } |
| OLD | NEW |