| 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 // Per-tab extension helper. Also handles non-extension apps. | 34 // Per-tab extension helper. Also handles non-extension apps. |
| 35 class ExtensionTabHelper | 35 class ExtensionTabHelper |
| 36 : public content::WebContentsObserver, | 36 : public content::WebContentsObserver, |
| 37 public ExtensionFunctionDispatcher::Delegate, | 37 public ExtensionFunctionDispatcher::Delegate, |
| 38 public ImageLoadingTracker::Observer, | 38 public ImageLoadingTracker::Observer, |
| 39 public WebstoreInlineInstaller::Delegate, | 39 public WebstoreInlineInstaller::Delegate, |
| 40 public AppNotifyChannelSetup::Delegate, | 40 public AppNotifyChannelSetup::Delegate, |
| 41 public base::SupportsWeakPtr<ExtensionTabHelper> { | 41 public base::SupportsWeakPtr<ExtensionTabHelper> { |
| 42 public: | 42 public: |
| 43 class Observer { | |
| 44 public: | |
| 45 // Called when the page action state (such as visibility, title) changes. | |
| 46 virtual void OnPageActionStateChanged() = 0; | |
| 47 | |
| 48 protected: | |
| 49 virtual ~Observer() {} | |
| 50 }; | |
| 51 | |
| 52 explicit ExtensionTabHelper(TabContentsWrapper* wrapper); | 43 explicit ExtensionTabHelper(TabContentsWrapper* wrapper); |
| 53 virtual ~ExtensionTabHelper(); | 44 virtual ~ExtensionTabHelper(); |
| 54 | 45 |
| 55 // Copies the internal state from another ExtensionTabHelper. | 46 // Copies the internal state from another ExtensionTabHelper. |
| 56 void CopyStateFrom(const ExtensionTabHelper& source); | 47 void CopyStateFrom(const ExtensionTabHelper& source); |
| 57 | 48 |
| 58 ExtensionTabHelperDelegate* delegate() const { return delegate_; } | 49 ExtensionTabHelperDelegate* delegate() const { return delegate_; } |
| 59 void set_delegate(ExtensionTabHelperDelegate* d) { delegate_ = d; } | 50 void set_delegate(ExtensionTabHelperDelegate* d) { delegate_ = d; } |
| 60 | 51 |
| 61 // Call this after updating a page action to notify clients about the changes. | 52 // Call this after updating a page action to notify clients about the changes. |
| 62 void PageActionStateChanged(); | 53 void PageActionStateChanged(); |
| 63 | 54 |
| 64 // Requests application info for the specified page. This is an asynchronous | 55 // Requests application info for the specified page. This is an asynchronous |
| 65 // request. The delegate is notified by way of OnDidGetApplicationInfo when | 56 // request. The delegate is notified by way of OnDidGetApplicationInfo when |
| 66 // the data is available. | 57 // the data is available. |
| 67 void GetApplicationInfo(int32 page_id); | 58 void GetApplicationInfo(int32 page_id); |
| 68 | 59 |
| 69 // Observer management. | |
| 70 void AddObserver(Observer* observer); | |
| 71 void RemoveObserver(Observer* observer); | |
| 72 | |
| 73 // App extensions ------------------------------------------------------------ | 60 // App extensions ------------------------------------------------------------ |
| 74 | 61 |
| 75 // Sets the extension denoting this as an app. If |extension| is non-null this | 62 // Sets the extension denoting this as an app. If |extension| is non-null this |
| 76 // tab becomes an app-tab. WebContents does not listen for unload events for | 63 // tab becomes an app-tab. WebContents does not listen for unload events for |
| 77 // the extension. It's up to consumers of WebContents to do that. | 64 // the extension. It's up to consumers of WebContents to do that. |
| 78 // | 65 // |
| 79 // NOTE: this should only be manipulated before the tab is added to a browser. | 66 // NOTE: this should only be manipulated before the tab is added to a browser. |
| 80 // TODO(sky): resolve if this is the right way to identify an app tab. If it | 67 // TODO(sky): resolve if this is the right way to identify an app tab. If it |
| 81 // is, than this should be passed in the constructor. | 68 // is, than this should be passed in the constructor. |
| 82 void SetExtensionApp(const extensions::Extension* extension); | 69 void SetExtensionApp(const extensions::Extension* extension); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // script_badge_controller will have a value, depending on whether the action | 192 // script_badge_controller will have a value, depending on whether the action |
| 206 // box is turned on. | 193 // box is turned on. |
| 207 scoped_ptr<extensions::ScriptExecutor> script_executor_; | 194 scoped_ptr<extensions::ScriptExecutor> script_executor_; |
| 208 scoped_ptr<extensions::ActionBoxController> action_box_controller_; | 195 scoped_ptr<extensions::ActionBoxController> action_box_controller_; |
| 209 scoped_ptr<extensions::ScriptBadgeController> script_badge_controller_; | 196 scoped_ptr<extensions::ScriptBadgeController> script_badge_controller_; |
| 210 | 197 |
| 211 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper); | 198 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper); |
| 212 }; | 199 }; |
| 213 | 200 |
| 214 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ | 201 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ |
| OLD | NEW |