OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/extensions/chrome_content_browser_client_extensions_par
t.h" | 5 #include "chrome/browser/extensions/chrome_content_browser_client_extensions_par
t.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 return false; | 366 return false; |
367 } | 367 } |
368 return true; | 368 return true; |
369 } | 369 } |
370 | 370 |
371 // static | 371 // static |
372 bool ChromeContentBrowserClientExtensionsPart::CanCommitURL( | 372 bool ChromeContentBrowserClientExtensionsPart::CanCommitURL( |
373 content::RenderProcessHost* process_host, const GURL& url) { | 373 content::RenderProcessHost* process_host, const GURL& url) { |
374 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 374 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
375 | 375 |
376 // We need to let most extension URLs commit in any process, since this can | 376 // Hosted app URLs may load in any process (e.g., in an iframe). However, the |
377 // be allowed due to web_accessible_resources. Most hosted app URLs may also | 377 // Chrome Web Store, and other extensions should never be requested outside |
378 // load in any process (e.g., in an iframe). However, the Chrome Web Store | 378 // their process. |
379 // cannot be loaded in iframes and should never be requested outside its | |
380 // process. | |
381 ExtensionRegistry* registry = | 379 ExtensionRegistry* registry = |
382 ExtensionRegistry::Get(process_host->GetBrowserContext()); | 380 ExtensionRegistry::Get(process_host->GetBrowserContext()); |
383 if (!registry) | 381 if (!registry) |
384 return true; | 382 return true; |
385 | 383 |
386 const Extension* new_extension = | 384 const Extension* new_extension = |
387 registry->enabled_extensions().GetExtensionOrAppByURL(url); | 385 registry->enabled_extensions().GetExtensionOrAppByURL(url); |
388 if (new_extension && new_extension->is_hosted_app() && | 386 if (!new_extension) |
389 new_extension->id() == kWebStoreAppId && | 387 return true; |
390 !ProcessMap::Get(process_host->GetBrowserContext()) | 388 |
391 ->Contains(new_extension->id(), process_host->GetID())) { | 389 if (new_extension->id() == kWebStoreAppId) |
392 return false; | 390 DCHECK(new_extension->is_hosted_app()); |
393 } | 391 if (new_extension->is_hosted_app() && new_extension->id() != kWebStoreAppId) |
394 return true; | 392 return true; |
| 393 |
| 394 return ProcessMap::Get(process_host->GetBrowserContext()) |
| 395 ->Contains(new_extension->id(), process_host->GetID()); |
395 } | 396 } |
396 | 397 |
397 // static | 398 // static |
398 bool ChromeContentBrowserClientExtensionsPart::IsSuitableHost( | 399 bool ChromeContentBrowserClientExtensionsPart::IsSuitableHost( |
399 Profile* profile, | 400 Profile* profile, |
400 content::RenderProcessHost* process_host, | 401 content::RenderProcessHost* process_host, |
401 const GURL& site_url) { | 402 const GURL& site_url) { |
402 DCHECK(profile); | 403 DCHECK(profile); |
403 | 404 |
404 ExtensionRegistry* registry = ExtensionRegistry::Get(profile); | 405 ExtensionRegistry* registry = ExtensionRegistry::Get(profile); |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 command_line->AppendSwitch(switches::kExtensionProcess); | 881 command_line->AppendSwitch(switches::kExtensionProcess); |
881 } | 882 } |
882 } | 883 } |
883 | 884 |
884 void ChromeContentBrowserClientExtensionsPart::ResourceDispatcherHostCreated() { | 885 void ChromeContentBrowserClientExtensionsPart::ResourceDispatcherHostCreated() { |
885 content::ResourceDispatcherHost::Get()->RegisterInterceptor( | 886 content::ResourceDispatcherHost::Get()->RegisterInterceptor( |
886 "Origin", kExtensionScheme, base::Bind(&OnHttpHeaderReceived)); | 887 "Origin", kExtensionScheme, base::Bind(&OnHttpHeaderReceived)); |
887 } | 888 } |
888 | 889 |
889 } // namespace extensions | 890 } // namespace extensions |
OLD | NEW |