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

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

Issue 57923009: Move ExtensionProcessManager to src/extensions, part 3 - remove Browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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_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/callback.h" 12 #include "base/callback.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/time/time.h" 16 #include "base/time/time.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 #include "extensions/common/view_type.h" 19 #include "extensions/common/view_type.h"
20 20
21 class Browser;
22 class GURL; 21 class GURL;
23 22
24 namespace content { 23 namespace content {
25 class BrowserContext; 24 class BrowserContext;
26 class DevToolsAgentHost; 25 class DevToolsAgentHost;
27 class RenderViewHost; 26 class RenderViewHost;
28 class SiteInstance; 27 class SiteInstance;
29 }; 28 };
30 29
31 namespace extensions { 30 namespace extensions {
(...skipping 12 matching lines...) Expand all
44 static ExtensionProcessManager* Create(content::BrowserContext* context); 43 static ExtensionProcessManager* Create(content::BrowserContext* context);
45 virtual ~ExtensionProcessManager(); 44 virtual ~ExtensionProcessManager();
46 45
47 const ExtensionHostSet& background_hosts() const { 46 const ExtensionHostSet& background_hosts() const {
48 return background_hosts_; 47 return background_hosts_;
49 } 48 }
50 49
51 typedef std::set<content::RenderViewHost*> ViewSet; 50 typedef std::set<content::RenderViewHost*> ViewSet;
52 const ViewSet GetAllViews() const; 51 const ViewSet GetAllViews() const;
53 52
54 // Creates a new ExtensionHost with its associated view, grouping it in the
55 // appropriate SiteInstance (and therefore process) based on the URL and
56 // profile.
57 virtual extensions::ExtensionHost* CreateViewHost(
58 const extensions::Extension* extension,
59 const GURL& url,
60 Browser* browser,
61 extensions::ViewType view_type);
62 extensions::ExtensionHost* CreateViewHost(const GURL& url,
63 Browser* browser,
64 extensions::ViewType view_type);
65 extensions::ExtensionHost* CreatePopupHost(
66 const extensions::Extension* extension,
67 const GURL& url,
68 Browser* browser);
69 extensions::ExtensionHost* CreatePopupHost(const GURL& url, Browser* browser);
70 extensions::ExtensionHost* CreateDialogHost(const GURL& url);
71 extensions::ExtensionHost* CreateInfobarHost(
72 const extensions::Extension* extension,
73 const GURL& url,
74 Browser* browser);
75 extensions::ExtensionHost* CreateInfobarHost(const GURL& url,
76 Browser* browser);
77
78 // Creates a new UI-less extension instance. Like CreateViewHost, but not 53 // Creates a new UI-less extension instance. Like CreateViewHost, but not
79 // displayed anywhere. 54 // displayed anywhere.
80 virtual extensions::ExtensionHost* CreateBackgroundHost( 55 virtual extensions::ExtensionHost* CreateBackgroundHost(
81 const extensions::Extension* extension, 56 const extensions::Extension* extension,
82 const GURL& url); 57 const GURL& url);
83 58
84 // Gets the ExtensionHost for the background page for an extension, or NULL if 59 // Gets the ExtensionHost for the background page for an extension, or NULL if
85 // the extension isn't running or doesn't have a background page. 60 // the extension isn't running or doesn't have a background page.
86 extensions::ExtensionHost* GetBackgroundHostForExtension( 61 extensions::ExtensionHost* GetBackgroundHostForExtension(
87 const std::string& extension_id); 62 const std::string& extension_id);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 void CancelSuspend(const extensions::Extension* extension); 111 void CancelSuspend(const extensions::Extension* extension);
137 112
138 // If |defer| is true background host creation is to be deferred until this is 113 // If |defer| is true background host creation is to be deferred until this is
139 // called again with |defer| set to false, at which point all deferred 114 // called again with |defer| set to false, at which point all deferred
140 // background hosts will be created. Defaults to false. 115 // background hosts will be created. Defaults to false.
141 void DeferBackgroundHostCreation(bool defer); 116 void DeferBackgroundHostCreation(bool defer);
142 117
143 // Ensures background hosts are loaded for a new browser window. 118 // Ensures background hosts are loaded for a new browser window.
144 void OnBrowserWindowReady(); 119 void OnBrowserWindowReady();
145 120
121 // Called just after |host| is created so it can be registered in our lists.
122 void OnExtensionHostCreated(extensions::ExtensionHost* host,
123 bool is_background);
124
146 // Gets the BrowserContext associated with site_instance_ and all other 125 // Gets the BrowserContext associated with site_instance_ and all other
147 // related SiteInstances. 126 // related SiteInstances.
148 content::BrowserContext* GetBrowserContext() const; 127 content::BrowserContext* GetBrowserContext() const;
149 128
150 protected: 129 protected:
151 // If |context| is incognito pass the master context as |original_context|. 130 // If |context| is incognito pass the master context as |original_context|.
152 // Otherwise pass the same context for both. 131 // Otherwise pass the same context for both.
153 ExtensionProcessManager(content::BrowserContext* context, 132 ExtensionProcessManager(content::BrowserContext* context,
154 content::BrowserContext* original_context); 133 content::BrowserContext* original_context);
155 134
156 // Called just after |host| is created so it can be registered in our lists.
157 void OnExtensionHostCreated(extensions::ExtensionHost* host,
158 bool is_background);
159
160 // Called on browser shutdown to close our extension hosts. 135 // Called on browser shutdown to close our extension hosts.
161 void CloseBackgroundHosts(); 136 void CloseBackgroundHosts();
162 137
163 // content::NotificationObserver: 138 // content::NotificationObserver:
164 virtual void Observe(int type, 139 virtual void Observe(int type,
165 const content::NotificationSource& source, 140 const content::NotificationSource& source,
166 const content::NotificationDetails& details) OVERRIDE; 141 const content::NotificationDetails& details) OVERRIDE;
167 142
168 // Load all background pages once the profile data is ready and the pages 143 // Load all background pages once the profile data is ready and the pages
169 // should be loaded. 144 // should be loaded.
(...skipping 15 matching lines...) Expand all
185 // Extra information we keep for each extension's background page. 160 // Extra information we keep for each extension's background page.
186 struct BackgroundPageData; 161 struct BackgroundPageData;
187 typedef std::string ExtensionId; 162 typedef std::string ExtensionId;
188 typedef std::map<ExtensionId, BackgroundPageData> BackgroundPageDataMap; 163 typedef std::map<ExtensionId, BackgroundPageData> BackgroundPageDataMap;
189 typedef std::map<content::RenderViewHost*, 164 typedef std::map<content::RenderViewHost*,
190 extensions::ViewType> ExtensionRenderViews; 165 extensions::ViewType> ExtensionRenderViews;
191 166
192 // Close the given |host| iff it's a background page. 167 // Close the given |host| iff it's a background page.
193 void CloseBackgroundHost(extensions::ExtensionHost* host); 168 void CloseBackgroundHost(extensions::ExtensionHost* host);
194 169
195 // Ensure browser object is not null except for certain situations.
196 void EnsureBrowserWhenRequired(Browser* browser,
197 extensions::ViewType view_type);
198
199 // These are called when the extension transitions between idle and active. 170 // These are called when the extension transitions between idle and active.
200 // They control the process of closing the background page when idle. 171 // They control the process of closing the background page when idle.
201 void OnLazyBackgroundPageIdle(const std::string& extension_id, 172 void OnLazyBackgroundPageIdle(const std::string& extension_id,
202 int sequence_id); 173 int sequence_id);
203 void OnLazyBackgroundPageActive(const std::string& extension_id); 174 void OnLazyBackgroundPageActive(const std::string& extension_id);
204 void CloseLazyBackgroundPageNow(const std::string& extension_id, 175 void CloseLazyBackgroundPageNow(const std::string& extension_id,
205 int sequence_id); 176 int sequence_id);
206 177
207 // Potentially registers a RenderViewHost, if it is associated with an 178 // Potentially registers a RenderViewHost, if it is associated with an
208 // extension. Does nothing if this is not an extension renderer. 179 // extension. Does nothing if this is not an extension renderer.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 bool startup_background_hosts_created_; 213 bool startup_background_hosts_created_;
243 214
244 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_; 215 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_;
245 216
246 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_; 217 base::WeakPtrFactory<ExtensionProcessManager> weak_ptr_factory_;
247 218
248 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); 219 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager);
249 }; 220 };
250 221
251 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 222 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698