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

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

Issue 10824030: Move ExtensionHost into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq Created 8 years, 4 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
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_PROCESS_MANAGER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "chrome/common/view_type.h" 16 #include "chrome/common/view_type.h"
17 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
19 19
20 class Browser; 20 class Browser;
21 class ExtensionHost;
22 class GURL; 21 class GURL;
23 class Profile; 22 class Profile;
24 23
25 namespace content { 24 namespace content {
26 class RenderViewHost; 25 class RenderViewHost;
27 class SiteInstance; 26 class SiteInstance;
28 }; 27 };
29 28
30 namespace extensions { 29 namespace extensions {
31 class Extension; 30 class Extension;
31 class ExtensionHost;
32 } 32 }
33 33
34 // Manages dynamic state of running Chromium extensions. There is one instance 34 // Manages dynamic state of running Chromium extensions. There is one instance
35 // of this class per Profile. OTR Profiles have a separate instance that keeps 35 // of this class per Profile. OTR Profiles have a separate instance that keeps
36 // track of split-mode extensions only. 36 // track of split-mode extensions only.
37 class ExtensionProcessManager : public content::NotificationObserver { 37 class ExtensionProcessManager : public content::NotificationObserver {
38 public: 38 public:
39 typedef std::set<ExtensionHost*> ExtensionHostSet; 39 typedef std::set<extensions::ExtensionHost*> ExtensionHostSet;
40 typedef ExtensionHostSet::const_iterator const_iterator; 40 typedef ExtensionHostSet::const_iterator const_iterator;
41 41
42 static ExtensionProcessManager* Create(Profile* profile); 42 static ExtensionProcessManager* Create(Profile* profile);
43 virtual ~ExtensionProcessManager(); 43 virtual ~ExtensionProcessManager();
44 44
45 const ExtensionHostSet& background_hosts() const { 45 const ExtensionHostSet& background_hosts() const {
46 return background_hosts_; 46 return background_hosts_;
47 } 47 }
48 48
49 typedef std::set<content::RenderViewHost*> ViewSet; 49 typedef std::set<content::RenderViewHost*> ViewSet;
50 const ViewSet GetAllViews() const; 50 const ViewSet GetAllViews() const;
51 51
52 // Creates a new ExtensionHost with its associated view, grouping it in the 52 // Creates a new ExtensionHost with its associated view, grouping it in the
53 // appropriate SiteInstance (and therefore process) based on the URL and 53 // appropriate SiteInstance (and therefore process) based on the URL and
54 // profile. 54 // profile.
55 virtual ExtensionHost* CreateViewHost(const extensions::Extension* extension, 55 virtual extensions::ExtensionHost* CreateViewHost(
56 const GURL& url, 56 const extensions::Extension* extension,
57 Browser* browser, 57 const GURL& url,
58 chrome::ViewType view_type); 58 Browser* browser,
59 ExtensionHost* CreateViewHost(const GURL& url, 59 chrome::ViewType view_type);
60 extensions::ExtensionHost* CreateViewHost(const GURL& url,
60 Browser* browser, 61 Browser* browser,
61 chrome::ViewType view_type); 62 chrome::ViewType view_type);
62 ExtensionHost* CreatePopupHost(const extensions::Extension* extension, 63 extensions::ExtensionHost* CreatePopupHost(
63 const GURL& url, 64 const extensions::Extension* extension,
64 Browser* browser); 65 const GURL& url,
65 ExtensionHost* CreatePopupHost(const GURL& url, Browser* browser); 66 Browser* browser);
66 ExtensionHost* CreateDialogHost(const GURL& url); 67 extensions::ExtensionHost* CreatePopupHost(const GURL& url, Browser* browser);
67 ExtensionHost* CreateInfobarHost(const extensions::Extension* extension, 68 extensions::ExtensionHost* CreateDialogHost(const GURL& url);
68 const GURL& url, 69 extensions::ExtensionHost* CreateInfobarHost(
69 Browser* browser); 70 const extensions::Extension* extension,
70 ExtensionHost* CreateInfobarHost(const GURL& url, 71 const GURL& url,
71 Browser* browser); 72 Browser* browser);
73 extensions::ExtensionHost* CreateInfobarHost(const GURL& url,
74 Browser* browser);
72 75
73 // Open the extension's options page. 76 // Open the extension's options page.
74 void OpenOptionsPage(const extensions::Extension* extension, 77 void OpenOptionsPage(const extensions::Extension* extension,
75 Browser* browser); 78 Browser* browser);
76 79
77 // Creates a new UI-less extension instance. Like CreateViewHost, but not 80 // Creates a new UI-less extension instance. Like CreateViewHost, but not
78 // displayed anywhere. 81 // displayed anywhere.
79 virtual void CreateBackgroundHost(const extensions::Extension* extension, 82 virtual void CreateBackgroundHost(const extensions::Extension* extension,
80 const GURL& url); 83 const GURL& url);
81 84
82 // Gets the ExtensionHost for the background page for an extension, or NULL if 85 // Gets the ExtensionHost for the background page for an extension, or NULL if
83 // the extension isn't running or doesn't have a background page. 86 // the extension isn't running or doesn't have a background page.
84 ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id); 87 extensions::ExtensionHost* GetBackgroundHostForExtension(
88 const std::string& extension_id);
85 89
86 // Returns the SiteInstance that the given URL belongs to. 90 // Returns the SiteInstance that the given URL belongs to.
87 // TODO(aa): This only returns correct results for extensions and packaged 91 // TODO(aa): This only returns correct results for extensions and packaged
88 // apps, not hosted apps. 92 // apps, not hosted apps.
89 virtual content::SiteInstance* GetSiteInstanceForURL(const GURL& url); 93 virtual content::SiteInstance* GetSiteInstanceForURL(const GURL& url);
90 94
91 // Registers a RenderViewHost as hosting a given extension. 95 // Registers a RenderViewHost as hosting a given extension.
92 void RegisterRenderViewHost(content::RenderViewHost* render_view_host, 96 void RegisterRenderViewHost(content::RenderViewHost* render_view_host,
93 const extensions::Extension* extension); 97 const extensions::Extension* extension);
94 98
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 void OnNetworkRequestDone(content::RenderViewHost* render_view_host); 137 void OnNetworkRequestDone(content::RenderViewHost* render_view_host);
134 138
135 // Prevents |extension|'s background page from being closed and sends the 139 // Prevents |extension|'s background page from being closed and sends the
136 // onSuspendCanceled() event to it. 140 // onSuspendCanceled() event to it.
137 void CancelSuspend(const extensions::Extension* extension); 141 void CancelSuspend(const extensions::Extension* extension);
138 142
139 protected: 143 protected:
140 explicit ExtensionProcessManager(Profile* profile); 144 explicit ExtensionProcessManager(Profile* profile);
141 145
142 // Called just after |host| is created so it can be registered in our lists. 146 // Called just after |host| is created so it can be registered in our lists.
143 void OnExtensionHostCreated(ExtensionHost* host, bool is_background); 147 void OnExtensionHostCreated(extensions::ExtensionHost* host,
148 bool is_background);
144 149
145 // Called on browser shutdown to close our extension hosts. 150 // Called on browser shutdown to close our extension hosts.
146 void CloseBackgroundHosts(); 151 void CloseBackgroundHosts();
147 152
148 // content::NotificationObserver: 153 // content::NotificationObserver:
149 virtual void Observe(int type, 154 virtual void Observe(int type,
150 const content::NotificationSource& source, 155 const content::NotificationSource& source,
151 const content::NotificationDetails& details) OVERRIDE; 156 const content::NotificationDetails& details) OVERRIDE;
152 157
153 // Gets the profile associated with site_instance_ and all other 158 // Gets the profile associated with site_instance_ and all other
(...skipping 17 matching lines...) Expand all
171 typedef std::map<ExtensionId, BackgroundPageData> BackgroundPageDataMap; 176 typedef std::map<ExtensionId, BackgroundPageData> BackgroundPageDataMap;
172 177
173 // Contains all extension-related RenderViewHost instances for all extensions. 178 // Contains all extension-related RenderViewHost instances for all extensions.
174 // We also keep a cache of the host's view type, because that information 179 // We also keep a cache of the host's view type, because that information
175 // is not accessible at registration/deregistration time. 180 // is not accessible at registration/deregistration time.
176 typedef std::map<content::RenderViewHost*, 181 typedef std::map<content::RenderViewHost*,
177 chrome::ViewType> ExtensionRenderViews; 182 chrome::ViewType> ExtensionRenderViews;
178 ExtensionRenderViews all_extension_views_; 183 ExtensionRenderViews all_extension_views_;
179 184
180 // Close the given |host| iff it's a background page. 185 // Close the given |host| iff it's a background page.
181 void CloseBackgroundHost(ExtensionHost* host); 186 void CloseBackgroundHost(extensions::ExtensionHost* host);
182 187
183 // Ensure browser object is not null except for certain situations. 188 // Ensure browser object is not null except for certain situations.
184 void EnsureBrowserWhenRequired(Browser* browser, 189 void EnsureBrowserWhenRequired(Browser* browser,
185 chrome::ViewType view_type); 190 chrome::ViewType view_type);
186 191
187 // These are called when the extension transitions between idle and active. 192 // These are called when the extension transitions between idle and active.
188 // They control the process of closing the background page when idle. 193 // They control the process of closing the background page when idle.
189 void OnLazyBackgroundPageIdle(const std::string& extension_id, 194 void OnLazyBackgroundPageIdle(const std::string& extension_id,
190 int sequence_id); 195 int sequence_id);
191 void OnLazyBackgroundPageActive(const std::string& extension_id); 196 void OnLazyBackgroundPageActive(const std::string& extension_id);
(...skipping 17 matching lines...) Expand all
209 // The time to delay between sending a ShouldUnload message and 214 // The time to delay between sending a ShouldUnload message and
210 // sending a Unload message; read from command-line switch. 215 // sending a Unload message; read from command-line switch.
211 base::TimeDelta event_page_unloading_time_; 216 base::TimeDelta event_page_unloading_time_;
212 217
213 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_; 218 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_;
214 219
215 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); 220 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager);
216 }; 221 };
217 222
218 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 223 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_management_browsertest.cc ('k') | chrome/browser/extensions/extension_process_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698