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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "chrome/browser/extensions/extension_host_mac.h" | 39 #include "chrome/browser/extensions/extension_host_mac.h" |
40 #endif | 40 #endif |
41 | 41 |
42 using content::BrowserThread; | 42 using content::BrowserThread; |
43 using content::OpenURLParams; | 43 using content::OpenURLParams; |
44 using content::Referrer; | 44 using content::Referrer; |
45 using content::RenderViewHost; | 45 using content::RenderViewHost; |
46 using content::SiteInstance; | 46 using content::SiteInstance; |
47 using content::WebContents; | 47 using content::WebContents; |
48 using extensions::Extension; | 48 using extensions::Extension; |
| 49 using extensions::ExtensionHost; |
49 | 50 |
50 namespace { | 51 namespace { |
51 | 52 |
52 std::string GetExtensionID(RenderViewHost* render_view_host) { | 53 std::string GetExtensionID(RenderViewHost* render_view_host) { |
53 // This works for both apps and extensions because the site has been | 54 // This works for both apps and extensions because the site has been |
54 // normalized to the extension URL for apps. | 55 // normalized to the extension URL for apps. |
55 if (!render_view_host->GetSiteInstance()) | 56 if (!render_view_host->GetSiteInstance()) |
56 return ""; | 57 return ""; |
57 | 58 |
58 return render_view_host->GetSiteInstance()->GetSite().host(); | 59 return render_view_host->GetSiteInstance()->GetSite().host(); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 200 |
200 ExtensionHost* ExtensionProcessManager::CreateViewHost( | 201 ExtensionHost* ExtensionProcessManager::CreateViewHost( |
201 const Extension* extension, | 202 const Extension* extension, |
202 const GURL& url, | 203 const GURL& url, |
203 Browser* browser, | 204 Browser* browser, |
204 chrome::ViewType view_type) { | 205 chrome::ViewType view_type) { |
205 DCHECK(extension); | 206 DCHECK(extension); |
206 EnsureBrowserWhenRequired(browser, view_type); | 207 EnsureBrowserWhenRequired(browser, view_type); |
207 ExtensionHost* host = | 208 ExtensionHost* host = |
208 #if defined(OS_MACOSX) | 209 #if defined(OS_MACOSX) |
209 new ExtensionHostMac(extension, GetSiteInstanceForURL(url), url, | 210 new extensions::ExtensionHostMac( |
210 view_type); | 211 extension, GetSiteInstanceForURL(url), url, view_type); |
211 #else | 212 #else |
212 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, view_type); | 213 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, view_type); |
213 #endif | 214 #endif |
214 host->CreateView(browser); | 215 host->CreateView(browser); |
215 OnExtensionHostCreated(host, false); | 216 OnExtensionHostCreated(host, false); |
216 return host; | 217 return host; |
217 } | 218 } |
218 | 219 |
219 ExtensionHost* ExtensionProcessManager::CreateViewHost( | 220 ExtensionHost* ExtensionProcessManager::CreateViewHost( |
220 const GURL& url, Browser* browser, chrome::ViewType view_type) { | 221 const GURL& url, Browser* browser, chrome::ViewType view_type) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 // here. | 266 // here. |
266 if (extension->is_hosted_app()) | 267 if (extension->is_hosted_app()) |
267 return; | 268 return; |
268 | 269 |
269 // Don't create multiple background hosts for an extension. | 270 // Don't create multiple background hosts for an extension. |
270 if (GetBackgroundHostForExtension(extension->id())) | 271 if (GetBackgroundHostForExtension(extension->id())) |
271 return; | 272 return; |
272 | 273 |
273 ExtensionHost* host = | 274 ExtensionHost* host = |
274 #if defined(OS_MACOSX) | 275 #if defined(OS_MACOSX) |
275 new ExtensionHostMac(extension, GetSiteInstanceForURL(url), url, | 276 new extensions::ExtensionHostMac( |
276 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 277 extension, GetSiteInstanceForURL(url), url, |
| 278 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
277 #else | 279 #else |
278 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, | 280 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, |
279 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 281 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
280 #endif | 282 #endif |
281 | 283 |
282 host->CreateRenderViewSoon(); | 284 host->CreateRenderViewSoon(); |
283 OnExtensionHostCreated(host, true); | 285 OnExtensionHostCreated(host, true); |
284 } | 286 } |
285 | 287 |
286 void ExtensionProcessManager::OpenOptionsPage(const Extension* extension, | 288 void ExtensionProcessManager::OpenOptionsPage(const Extension* extension, |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 if (service && service->is_ready()) | 803 if (service && service->is_ready()) |
802 CreateBackgroundHostsForProfileStartup(this, service->extensions()); | 804 CreateBackgroundHostsForProfileStartup(this, service->extensions()); |
803 } | 805 } |
804 break; | 806 break; |
805 } | 807 } |
806 default: | 808 default: |
807 ExtensionProcessManager::Observe(type, source, details); | 809 ExtensionProcessManager::Observe(type, source, details); |
808 break; | 810 break; |
809 } | 811 } |
810 } | 812 } |
OLD | NEW |