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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 204 |
204 ExtensionHost* ExtensionProcessManager::CreateViewHost( | 205 ExtensionHost* ExtensionProcessManager::CreateViewHost( |
205 const Extension* extension, | 206 const Extension* extension, |
206 const GURL& url, | 207 const GURL& url, |
207 Browser* browser, | 208 Browser* browser, |
208 chrome::ViewType view_type) { | 209 chrome::ViewType view_type) { |
209 DCHECK(extension); | 210 DCHECK(extension); |
210 EnsureBrowserWhenRequired(browser, view_type); | 211 EnsureBrowserWhenRequired(browser, view_type); |
211 ExtensionHost* host = | 212 ExtensionHost* host = |
212 #if defined(OS_MACOSX) | 213 #if defined(OS_MACOSX) |
213 new ExtensionHostMac(extension, GetSiteInstanceForURL(url), url, | 214 new extensions::ExtensionHostMac( |
214 view_type); | 215 extension, GetSiteInstanceForURL(url), url, view_type); |
215 #else | 216 #else |
216 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, view_type); | 217 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, view_type); |
217 #endif | 218 #endif |
218 host->CreateView(browser); | 219 host->CreateView(browser); |
219 OnExtensionHostCreated(host, false); | 220 OnExtensionHostCreated(host, false); |
220 return host; | 221 return host; |
221 } | 222 } |
222 | 223 |
223 ExtensionHost* ExtensionProcessManager::CreateViewHost( | 224 ExtensionHost* ExtensionProcessManager::CreateViewHost( |
224 const GURL& url, Browser* browser, chrome::ViewType view_type) { | 225 const GURL& url, Browser* browser, chrome::ViewType view_type) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 // here. | 270 // here. |
270 if (extension->is_hosted_app()) | 271 if (extension->is_hosted_app()) |
271 return; | 272 return; |
272 | 273 |
273 // Don't create multiple background hosts for an extension. | 274 // Don't create multiple background hosts for an extension. |
274 if (GetBackgroundHostForExtension(extension->id())) | 275 if (GetBackgroundHostForExtension(extension->id())) |
275 return; | 276 return; |
276 | 277 |
277 ExtensionHost* host = | 278 ExtensionHost* host = |
278 #if defined(OS_MACOSX) | 279 #if defined(OS_MACOSX) |
279 new ExtensionHostMac(extension, GetSiteInstanceForURL(url), url, | 280 new extensions::ExtensionHostMac( |
280 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 281 extension, GetSiteInstanceForURL(url), url, |
| 282 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
281 #else | 283 #else |
282 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, | 284 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, |
283 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 285 chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
284 #endif | 286 #endif |
285 | 287 |
286 host->CreateRenderViewSoon(); | 288 host->CreateRenderViewSoon(); |
287 OnExtensionHostCreated(host, true); | 289 OnExtensionHostCreated(host, true); |
288 } | 290 } |
289 | 291 |
290 void ExtensionProcessManager::OpenOptionsPage(const Extension* extension, | 292 void ExtensionProcessManager::OpenOptionsPage(const Extension* extension, |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 if (service && service->is_ready()) | 807 if (service && service->is_ready()) |
806 CreateBackgroundHostsForProfileStartup(this, service->extensions()); | 808 CreateBackgroundHostsForProfileStartup(this, service->extensions()); |
807 } | 809 } |
808 break; | 810 break; |
809 } | 811 } |
810 default: | 812 default: |
811 ExtensionProcessManager::Observe(type, source, details); | 813 ExtensionProcessManager::Observe(type, source, details); |
812 break; | 814 break; |
813 } | 815 } |
814 } | 816 } |
OLD | NEW |