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 #ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 Browser* browser() { return browser_; } | 83 Browser* browser() { return browser_; } |
84 ExtensionAction* extension_action() { return extension_action_; } | 84 ExtensionAction* extension_action() { return extension_action_; } |
85 const ExtensionAction* extension_action() const { return extension_action_; } | 85 const ExtensionAction* extension_action() const { return extension_action_; } |
86 ToolbarActionViewDelegate* view_delegate() { return view_delegate_; } | 86 ToolbarActionViewDelegate* view_delegate() { return view_delegate_; } |
87 bool is_showing_popup() const { return popup_host_ != nullptr; } | 87 bool is_showing_popup() const { return popup_host_ != nullptr; } |
88 | 88 |
89 void set_icon_observer(ExtensionActionIconFactory::Observer* icon_observer) { | 89 void set_icon_observer(ExtensionActionIconFactory::Observer* icon_observer) { |
90 icon_observer_ = icon_observer; | 90 icon_observer_ = icon_observer; |
91 } | 91 } |
92 | 92 |
93 scoped_ptr<IconWithBadgeImageSource> GetIconImageSourceForTesting( | 93 std::unique_ptr<IconWithBadgeImageSource> GetIconImageSourceForTesting( |
94 content::WebContents* web_contents, | 94 content::WebContents* web_contents, |
95 const gfx::Size& size); | 95 const gfx::Size& size); |
96 | 96 |
97 private: | 97 private: |
98 // ExtensionActionIconFactory::Observer: | 98 // ExtensionActionIconFactory::Observer: |
99 void OnIconUpdated() override; | 99 void OnIconUpdated() override; |
100 | 100 |
101 // ExtensionHostObserver: | 101 // ExtensionHostObserver: |
102 void OnExtensionHostDestroyed(const extensions::ExtensionHost* host) override; | 102 void OnExtensionHostDestroyed(const extensions::ExtensionHost* host) override; |
103 | 103 |
(...skipping 19 matching lines...) Expand all Loading... |
123 // permissions should be given to the extension; this is only true if the | 123 // permissions should be given to the extension; this is only true if the |
124 // popup is opened through a user action. | 124 // popup is opened through a user action. |
125 // The popup may not be shown synchronously if the extension is hidden and | 125 // The popup may not be shown synchronously if the extension is hidden and |
126 // first needs to slide itself out. | 126 // first needs to slide itself out. |
127 // Returns true if a popup will be shown. | 127 // Returns true if a popup will be shown. |
128 bool TriggerPopupWithUrl(PopupShowAction show_action, | 128 bool TriggerPopupWithUrl(PopupShowAction show_action, |
129 const GURL& popup_url, | 129 const GURL& popup_url, |
130 bool grant_tab_permissions); | 130 bool grant_tab_permissions); |
131 | 131 |
132 // Shows the popup with the given |host|. | 132 // Shows the popup with the given |host|. |
133 void ShowPopup(scoped_ptr<extensions::ExtensionViewHost> host, | 133 void ShowPopup(std::unique_ptr<extensions::ExtensionViewHost> host, |
134 bool grant_tab_permissions, | 134 bool grant_tab_permissions, |
135 PopupShowAction show_action); | 135 PopupShowAction show_action); |
136 | 136 |
137 // Handles cleanup after the popup closes. | 137 // Handles cleanup after the popup closes. |
138 void OnPopupClosed(); | 138 void OnPopupClosed(); |
139 | 139 |
140 // Returns the image source for the icon. | 140 // Returns the image source for the icon. |
141 scoped_ptr<IconWithBadgeImageSource> GetIconImageSource( | 141 std::unique_ptr<IconWithBadgeImageSource> GetIconImageSource( |
142 content::WebContents* web_contents, | 142 content::WebContents* web_contents, |
143 const gfx::Size& size); | 143 const gfx::Size& size); |
144 | 144 |
145 // Returns true if this extension has a page action and that page action wants | 145 // Returns true if this extension has a page action and that page action wants |
146 // to run on the given |web_contents|. | 146 // to run on the given |web_contents|. |
147 bool PageActionWantsToRun(content::WebContents* web_contents) const; | 147 bool PageActionWantsToRun(content::WebContents* web_contents) const; |
148 | 148 |
149 // Returns true if this extension has been blocked on the given | 149 // Returns true if this extension has been blocked on the given |
150 // |web_contents|. | 150 // |web_contents|. |
151 bool HasBeenBlocked(content::WebContents* web_contents) const; | 151 bool HasBeenBlocked(content::WebContents* web_contents) const; |
(...skipping 12 matching lines...) Expand all Loading... |
164 // page action without the toolbar redesign turned on. | 164 // page action without the toolbar redesign turned on. |
165 // TODO(devlin): Would this be better behind a delegate interface? On the one | 165 // TODO(devlin): Would this be better behind a delegate interface? On the one |
166 // hand, it's odd for this class to know about ToolbarActionsBar, but on the | 166 // hand, it's odd for this class to know about ToolbarActionsBar, but on the |
167 // other, yet-another-delegate-class might just confuse things. | 167 // other, yet-another-delegate-class might just confuse things. |
168 ToolbarActionsBar* toolbar_actions_bar_; | 168 ToolbarActionsBar* toolbar_actions_bar_; |
169 | 169 |
170 // The extension popup's host if the popup is visible; null otherwise. | 170 // The extension popup's host if the popup is visible; null otherwise. |
171 extensions::ExtensionViewHost* popup_host_; | 171 extensions::ExtensionViewHost* popup_host_; |
172 | 172 |
173 // The context menu model for the extension. | 173 // The context menu model for the extension. |
174 scoped_ptr<extensions::ExtensionContextMenuModel> context_menu_model_; | 174 std::unique_ptr<extensions::ExtensionContextMenuModel> context_menu_model_; |
175 | 175 |
176 // Our view delegate. | 176 // Our view delegate. |
177 ToolbarActionViewDelegate* view_delegate_; | 177 ToolbarActionViewDelegate* view_delegate_; |
178 | 178 |
179 // The delegate to handle platform-specific implementations. | 179 // The delegate to handle platform-specific implementations. |
180 scoped_ptr<ExtensionActionPlatformDelegate> platform_delegate_; | 180 std::unique_ptr<ExtensionActionPlatformDelegate> platform_delegate_; |
181 | 181 |
182 // The object that will be used to get the browser action icon for us. | 182 // The object that will be used to get the browser action icon for us. |
183 // It may load the icon asynchronously (in which case the initial icon | 183 // It may load the icon asynchronously (in which case the initial icon |
184 // returned by the factory will be transparent), so we have to observe it for | 184 // returned by the factory will be transparent), so we have to observe it for |
185 // updates to the icon. | 185 // updates to the icon. |
186 ExtensionActionIconFactory icon_factory_; | 186 ExtensionActionIconFactory icon_factory_; |
187 | 187 |
188 // An additional observer that we need to notify when the icon of the button | 188 // An additional observer that we need to notify when the icon of the button |
189 // has been updated. | 189 // has been updated. |
190 ExtensionActionIconFactory::Observer* icon_observer_; | 190 ExtensionActionIconFactory::Observer* icon_observer_; |
191 | 191 |
192 // The associated ExtensionRegistry; cached for quick checking. | 192 // The associated ExtensionRegistry; cached for quick checking. |
193 extensions::ExtensionRegistry* extension_registry_; | 193 extensions::ExtensionRegistry* extension_registry_; |
194 | 194 |
195 ScopedObserver<extensions::ExtensionHost, extensions::ExtensionHostObserver> | 195 ScopedObserver<extensions::ExtensionHost, extensions::ExtensionHostObserver> |
196 popup_host_observer_; | 196 popup_host_observer_; |
197 | 197 |
198 base::WeakPtrFactory<ExtensionActionViewController> weak_factory_; | 198 base::WeakPtrFactory<ExtensionActionViewController> weak_factory_; |
199 | 199 |
200 DISALLOW_COPY_AND_ASSIGN(ExtensionActionViewController); | 200 DISALLOW_COPY_AND_ASSIGN(ExtensionActionViewController); |
201 }; | 201 }; |
202 | 202 |
203 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ | 203 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ |
OLD | NEW |