| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // exists. Returns true if |command| was populated. | 79 // exists. Returns true if |command| was populated. |
| 80 bool GetExtensionCommand(extensions::Command* command); | 80 bool GetExtensionCommand(extensions::Command* command); |
| 81 | 81 |
| 82 const extensions::Extension* extension() const { return extension_.get(); } | 82 const extensions::Extension* extension() const { return extension_.get(); } |
| 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) { | |
| 90 icon_observer_ = icon_observer; | |
| 91 } | |
| 92 | |
| 93 std::unique_ptr<IconWithBadgeImageSource> GetIconImageSourceForTesting( | 89 std::unique_ptr<IconWithBadgeImageSource> GetIconImageSourceForTesting( |
| 94 content::WebContents* web_contents, | 90 content::WebContents* web_contents, |
| 95 const gfx::Size& size); | 91 const gfx::Size& size); |
| 96 | 92 |
| 97 private: | 93 private: |
| 98 // ExtensionActionIconFactory::Observer: | 94 // ExtensionActionIconFactory::Observer: |
| 99 void OnIconUpdated() override; | 95 void OnIconUpdated() override; |
| 100 | 96 |
| 101 // ExtensionHostObserver: | 97 // ExtensionHostObserver: |
| 102 void OnExtensionHostDestroyed(const extensions::ExtensionHost* host) override; | 98 void OnExtensionHostDestroyed(const extensions::ExtensionHost* host) override; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 174 |
| 179 // The delegate to handle platform-specific implementations. | 175 // The delegate to handle platform-specific implementations. |
| 180 std::unique_ptr<ExtensionActionPlatformDelegate> platform_delegate_; | 176 std::unique_ptr<ExtensionActionPlatformDelegate> platform_delegate_; |
| 181 | 177 |
| 182 // The object that will be used to get the browser action icon for us. | 178 // 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 | 179 // 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 | 180 // returned by the factory will be transparent), so we have to observe it for |
| 185 // updates to the icon. | 181 // updates to the icon. |
| 186 ExtensionActionIconFactory icon_factory_; | 182 ExtensionActionIconFactory icon_factory_; |
| 187 | 183 |
| 188 // An additional observer that we need to notify when the icon of the button | |
| 189 // has been updated. | |
| 190 ExtensionActionIconFactory::Observer* icon_observer_; | |
| 191 | |
| 192 // The associated ExtensionRegistry; cached for quick checking. | 184 // The associated ExtensionRegistry; cached for quick checking. |
| 193 extensions::ExtensionRegistry* extension_registry_; | 185 extensions::ExtensionRegistry* extension_registry_; |
| 194 | 186 |
| 195 ScopedObserver<extensions::ExtensionHost, extensions::ExtensionHostObserver> | 187 ScopedObserver<extensions::ExtensionHost, extensions::ExtensionHostObserver> |
| 196 popup_host_observer_; | 188 popup_host_observer_; |
| 197 | 189 |
| 198 base::WeakPtrFactory<ExtensionActionViewController> weak_factory_; | 190 base::WeakPtrFactory<ExtensionActionViewController> weak_factory_; |
| 199 | 191 |
| 200 DISALLOW_COPY_AND_ASSIGN(ExtensionActionViewController); | 192 DISALLOW_COPY_AND_ASSIGN(ExtensionActionViewController); |
| 201 }; | 193 }; |
| 202 | 194 |
| 203 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ | 195 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_ACTION_VIEW_CONTROLLER_H_ |
| OLD | NEW |