OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/extension_action_view_controller.h" | 5 #include "chrome/browser/ui/views/extensions/extension_action_view_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.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_toolbar_model.h" | 10 #include "chrome/browser/extensions/extension_toolbar_model.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 bool ExtensionActionViewController::ExecuteAction( | 72 bool ExtensionActionViewController::ExecuteAction( |
73 ExtensionPopup::ShowAction show_action, bool grant_tab_permissions) { | 73 ExtensionPopup::ShowAction show_action, bool grant_tab_permissions) { |
74 GURL popup_url; | 74 GURL popup_url; |
75 bool show_popup = false; | 75 bool show_popup = false; |
76 if (extension_action_->action_type() == ActionInfo::TYPE_BROWSER) { | 76 if (extension_action_->action_type() == ActionInfo::TYPE_BROWSER) { |
77 extensions::ExtensionToolbarModel* toolbar_model = | 77 extensions::ExtensionToolbarModel* toolbar_model = |
78 extensions::ExtensionToolbarModel::Get(browser_->profile()); | 78 extensions::ExtensionToolbarModel::Get(browser_->profile()); |
79 show_popup = toolbar_model->ExecuteBrowserAction( | 79 show_popup = toolbar_model->ExecuteBrowserAction( |
80 extension_, browser_, &popup_url, grant_tab_permissions) == | 80 extension_, browser_, &popup_url, grant_tab_permissions) == |
81 extensions::ExtensionToolbarModel::ACTION_SHOW_POPUP; | 81 ExtensionAction::ACTION_SHOW_POPUP; |
82 } else { // PageAction | 82 } else { // PageAction |
83 content::WebContents* web_contents = delegate_->GetCurrentWebContents(); | 83 content::WebContents* web_contents = delegate_->GetCurrentWebContents(); |
84 if (!web_contents) | 84 if (!web_contents) |
85 return false; | 85 return false; |
86 extensions::LocationBarController* controller = | 86 extensions::LocationBarController* controller = |
87 extensions::TabHelper::FromWebContents(web_contents)-> | 87 extensions::TabHelper::FromWebContents(web_contents)-> |
88 location_bar_controller(); | 88 location_bar_controller(); |
89 switch (controller->OnClicked(extension_action_)) { | 89 switch (controller->OnClicked(extension_action_)) { |
90 case extensions::LocationBarController::ACTION_NONE: | 90 case ExtensionAction::ACTION_NONE: |
91 break; | 91 break; |
92 case extensions::LocationBarController::ACTION_SHOW_POPUP: | 92 case ExtensionAction::ACTION_SHOW_POPUP: |
93 popup_url = extension_action_->GetPopupUrl(GetCurrentTabId()); | 93 popup_url = extension_action_->GetPopupUrl(GetCurrentTabId()); |
94 show_popup = true; | 94 show_popup = true; |
95 break; | 95 break; |
96 case extensions::LocationBarController::ACTION_SHOW_CONTEXT_MENU: | |
97 // We are never passing OnClicked a right-click button, so assume that | |
98 // we're never going to be asked to show a context menu. | |
99 // TODO(kalman): if this changes, update this class to pass the real | |
100 // mouse button through to the LocationBarController. | |
101 NOTREACHED(); | |
102 break; | |
103 } | 96 } |
104 } | 97 } |
105 | 98 |
106 if (show_popup && ShowPopupWithUrl(show_action, popup_url)) { | 99 if (show_popup && ShowPopupWithUrl(show_action, popup_url)) { |
107 delegate_->OnPopupShown(grant_tab_permissions); | 100 delegate_->OnPopupShown(grant_tab_permissions); |
108 return true; | 101 return true; |
109 } | 102 } |
110 | 103 |
111 return false; | 104 return false; |
112 } | 105 } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } | 329 } |
337 | 330 |
338 void ExtensionActionViewController::CleanupPopup(bool close_widget) { | 331 void ExtensionActionViewController::CleanupPopup(bool close_widget) { |
339 DCHECK(popup_); | 332 DCHECK(popup_); |
340 delegate_->CleanupPopup(); | 333 delegate_->CleanupPopup(); |
341 popup_->GetWidget()->RemoveObserver(this); | 334 popup_->GetWidget()->RemoveObserver(this); |
342 if (close_widget) | 335 if (close_widget) |
343 popup_->GetWidget()->Close(); | 336 popup_->GetWidget()->Close(); |
344 popup_ = NULL; | 337 popup_ = NULL; |
345 } | 338 } |
OLD | NEW |