Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: chrome/browser/extensions/extension_tab_helper.h

Issue 10388160: Only return the visible page actions from PageActionController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change ownership of extension stuff, revert change to extension_action_box Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/extensions/app_notify_channel_setup.h" 11 #include "chrome/browser/extensions/app_notify_channel_setup.h"
11 #include "chrome/browser/extensions/extension_function_dispatcher.h" 12 #include "chrome/browser/extensions/extension_function_dispatcher.h"
12 #include "chrome/browser/extensions/image_loading_tracker.h" 13 #include "chrome/browser/extensions/image_loading_tracker.h"
13 #include "chrome/browser/extensions/webstore_inline_installer.h" 14 #include "chrome/browser/extensions/webstore_inline_installer.h"
14 #include "chrome/common/web_apps.h" 15 #include "chrome/common/web_apps.h"
15 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 17 #include "third_party/skia/include/core/SkBitmap.h"
17 18
18 class Extension; 19 class Extension;
19 class ExtensionTabHelperDelegate; 20 class ExtensionTabHelperDelegate;
20 class TabContentsWrapper; 21 class TabContentsWrapper;
21 struct WebApplicationInfo; 22 struct WebApplicationInfo;
22 23
23 namespace content { 24 namespace content {
24 struct LoadCommittedDetails; 25 struct LoadCommittedDetails;
25 } 26 }
26 27
28 namespace extensions {
29 class ActionBoxController;
30 class ScriptExecutor;
31 }
32
27 // Per-tab extension helper. Also handles non-extension apps. 33 // Per-tab extension helper. Also handles non-extension apps.
28 class ExtensionTabHelper 34 class ExtensionTabHelper
29 : public content::WebContentsObserver, 35 : public content::WebContentsObserver,
30 public ExtensionFunctionDispatcher::Delegate, 36 public ExtensionFunctionDispatcher::Delegate,
31 public ImageLoadingTracker::Observer, 37 public ImageLoadingTracker::Observer,
32 public WebstoreInlineInstaller::Delegate, 38 public WebstoreInlineInstaller::Delegate,
33 public AppNotifyChannelSetup::Delegate, 39 public AppNotifyChannelSetup::Delegate,
34 public base::SupportsWeakPtr<ExtensionTabHelper> { 40 public base::SupportsWeakPtr<ExtensionTabHelper> {
35 public: 41 public:
42 class Observer {
43 public:
44 // Called when the page action state (such as visibility, title) changes.
45 virtual void OnPageActionStateChanged() = 0;
46
47 protected:
48 virtual ~Observer() {}
49 };
50
36 explicit ExtensionTabHelper(TabContentsWrapper* wrapper); 51 explicit ExtensionTabHelper(TabContentsWrapper* wrapper);
37 virtual ~ExtensionTabHelper(); 52 virtual ~ExtensionTabHelper();
38 53
39 // Copies the internal state from another ExtensionTabHelper. 54 // Copies the internal state from another ExtensionTabHelper.
40 void CopyStateFrom(const ExtensionTabHelper& source); 55 void CopyStateFrom(const ExtensionTabHelper& source);
41 56
42 ExtensionTabHelperDelegate* delegate() const { return delegate_; } 57 ExtensionTabHelperDelegate* delegate() const { return delegate_; }
43 void set_delegate(ExtensionTabHelperDelegate* d) { delegate_ = d; } 58 void set_delegate(ExtensionTabHelperDelegate* d) { delegate_ = d; }
44 59
45 // Call this after updating a page action to notify clients about the changes. 60 // Call this after updating a page action to notify clients about the changes.
46 void PageActionStateChanged(); 61 void PageActionStateChanged();
47 62
48 // Requests application info for the specified page. This is an asynchronous 63 // Requests application info for the specified page. This is an asynchronous
49 // request. The delegate is notified by way of OnDidGetApplicationInfo when 64 // request. The delegate is notified by way of OnDidGetApplicationInfo when
50 // the data is available. 65 // the data is available.
51 void GetApplicationInfo(int32 page_id); 66 void GetApplicationInfo(int32 page_id);
52 67
68 // Observer management.
69 void AddObserver(Observer* observer);
70 void RemoveObserver(Observer* observer);
71
53 // App extensions ------------------------------------------------------------ 72 // App extensions ------------------------------------------------------------
54 73
55 // Sets the extension denoting this as an app. If |extension| is non-null this 74 // Sets the extension denoting this as an app. If |extension| is non-null this
56 // tab becomes an app-tab. WebContents does not listen for unload events for 75 // tab becomes an app-tab. WebContents does not listen for unload events for
57 // the extension. It's up to consumers of WebContents to do that. 76 // the extension. It's up to consumers of WebContents to do that.
58 // 77 //
59 // NOTE: this should only be manipulated before the tab is added to a browser. 78 // NOTE: this should only be manipulated before the tab is added to a browser.
60 // TODO(sky): resolve if this is the right way to identify an app tab. If it 79 // TODO(sky): resolve if this is the right way to identify an app tab. If it
61 // is, than this should be passed in the constructor. 80 // is, than this should be passed in the constructor.
62 void SetExtensionApp(const Extension* extension); 81 void SetExtensionApp(const Extension* extension);
(...skipping 20 matching lines...) Expand all
83 SkBitmap* GetExtensionAppIcon(); 102 SkBitmap* GetExtensionAppIcon();
84 103
85 TabContentsWrapper* tab_contents_wrapper() { 104 TabContentsWrapper* tab_contents_wrapper() {
86 return wrapper_; 105 return wrapper_;
87 } 106 }
88 107
89 content::WebContents* web_contents() const { 108 content::WebContents* web_contents() const {
90 return content::WebContentsObserver::web_contents(); 109 return content::WebContentsObserver::web_contents();
91 } 110 }
92 111
112 extensions::ScriptExecutor* script_executor() {
113 return script_executor_.get();
114 }
115
116 extensions::ActionBoxController* action_box_controller() {
117 return action_box_controller_.get();
118 }
119
93 // Sets a non-extension app icon associated with WebContents and fires an 120 // Sets a non-extension app icon associated with WebContents and fires an
94 // INVALIDATE_TYPE_TITLE navigation state change to trigger repaint of title. 121 // INVALIDATE_TYPE_TITLE navigation state change to trigger repaint of title.
95 void SetAppIcon(const SkBitmap& app_icon); 122 void SetAppIcon(const SkBitmap& app_icon);
96 123
97 private: 124 private:
98 // content::WebContentsObserver overrides. 125 // content::WebContentsObserver overrides.
99 virtual void DidNavigateMainFrame( 126 virtual void DidNavigateMainFrame(
100 const content::LoadCommittedDetails& details, 127 const content::LoadCommittedDetails& details,
101 const content::FrameNavigateParams& params) OVERRIDE; 128 const content::FrameNavigateParams& params) OVERRIDE;
102 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 129 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 ExtensionFunctionDispatcher extension_function_dispatcher_; 192 ExtensionFunctionDispatcher extension_function_dispatcher_;
166 193
167 // Used for loading extension_app_icon_. 194 // Used for loading extension_app_icon_.
168 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_; 195 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_;
169 196
170 // Cached web app info data. 197 // Cached web app info data.
171 WebApplicationInfo web_app_info_; 198 WebApplicationInfo web_app_info_;
172 199
173 TabContentsWrapper* wrapper_; 200 TabContentsWrapper* wrapper_;
174 201
202 scoped_ptr<extensions::ScriptExecutor> script_executor_;
203
204 scoped_ptr<extensions::ActionBoxController> action_box_controller_;
205
206 ObserverList<Observer> observers_;
207
175 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper); 208 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper);
176 }; 209 };
177 210
178 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_ 211 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698