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 "chrome/browser/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #include "chrome/common/render_messages.h" | 65 #include "chrome/common/render_messages.h" |
66 #include "chrome/common/url_constants.h" | 66 #include "chrome/common/url_constants.h" |
67 #include "content/browser/browser_url_handler.h" | 67 #include "content/browser/browser_url_handler.h" |
68 #include "content/browser/child_process_security_policy.h" | 68 #include "content/browser/child_process_security_policy.h" |
69 #include "content/browser/gpu/gpu_data_manager.h" | 69 #include "content/browser/gpu/gpu_data_manager.h" |
70 #include "content/browser/gpu/gpu_process_host.h" | 70 #include "content/browser/gpu/gpu_process_host.h" |
71 #include "content/browser/plugin_process_host.h" | 71 #include "content/browser/plugin_process_host.h" |
72 #include "content/browser/renderer_host/render_view_host.h" | 72 #include "content/browser/renderer_host/render_view_host.h" |
73 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 73 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
74 #include "content/browser/resource_context.h" | 74 #include "content/browser/resource_context.h" |
75 #include "content/browser/site_instance.h" | |
76 #include "content/browser/ssl/ssl_cert_error_handler.h" | 75 #include "content/browser/ssl/ssl_cert_error_handler.h" |
77 #include "content/browser/ssl/ssl_client_auth_handler.h" | 76 #include "content/browser/ssl/ssl_client_auth_handler.h" |
78 #include "content/browser/worker_host/worker_process_host.h" | 77 #include "content/browser/worker_host/worker_process_host.h" |
79 #include "content/public/browser/browser_main_parts.h" | 78 #include "content/public/browser/browser_main_parts.h" |
80 #include "content/public/browser/render_process_host.h" | 79 #include "content/public/browser/render_process_host.h" |
| 80 #include "content/public/browser/site_instance.h" |
81 #include "content/public/browser/web_contents.h" | 81 #include "content/public/browser/web_contents.h" |
82 #include "content/public/browser/web_contents_view.h" | 82 #include "content/public/browser/web_contents_view.h" |
83 #include "grit/generated_resources.h" | 83 #include "grit/generated_resources.h" |
84 #include "grit/ui_resources.h" | 84 #include "grit/ui_resources.h" |
85 #include "net/base/cookie_monster.h" | 85 #include "net/base/cookie_monster.h" |
86 #include "net/base/cookie_options.h" | 86 #include "net/base/cookie_options.h" |
87 #include "net/base/network_change_notifier.h" | 87 #include "net/base/network_change_notifier.h" |
88 #include "ui/base/l10n/l10n_util.h" | 88 #include "ui/base/l10n/l10n_util.h" |
89 #include "ui/base/resource/resource_bundle.h" | 89 #include "ui/base/resource/resource_bundle.h" |
90 #include "webkit/glue/webpreferences.h" | 90 #include "webkit/glue/webpreferences.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 #elif defined(OS_MACOSX) | 127 #elif defined(OS_MACOSX) |
128 #include "chrome/browser/tab_contents/moving_to_content/tab_contents_view_mac.h" | 128 #include "chrome/browser/tab_contents/moving_to_content/tab_contents_view_mac.h" |
129 #endif | 129 #endif |
130 | 130 |
131 #if defined(USE_NSS) | 131 #if defined(USE_NSS) |
132 #include "chrome/browser/ui/crypto_module_password_dialog.h" | 132 #include "chrome/browser/ui/crypto_module_password_dialog.h" |
133 #endif | 133 #endif |
134 | 134 |
135 using content::AccessTokenStore; | 135 using content::AccessTokenStore; |
136 using content::BrowserThread; | 136 using content::BrowserThread; |
| 137 using content::SiteInstance; |
137 using content::WebContents; | 138 using content::WebContents; |
138 | 139 |
139 namespace { | 140 namespace { |
140 | 141 |
141 // Handles rewriting Web UI URLs. | 142 // Handles rewriting Web UI URLs. |
142 bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { | 143 bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { |
143 if (!ChromeWebUIFactory::GetInstance()->UseWebUIForURL(browser_context, *url)) | 144 if (!ChromeWebUIFactory::GetInstance()->UseWebUIForURL(browser_context, *url)) |
144 return false; | 145 return false; |
145 | 146 |
146 // Special case the new tab page. In older versions of Chrome, the new tab | 147 // Special case the new tab page. In older versions of Chrome, the new tab |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 CHECK(site_instance->HasProcess()); | 480 CHECK(site_instance->HasProcess()); |
480 | 481 |
481 Profile* profile = Profile::FromBrowserContext( | 482 Profile* profile = Profile::FromBrowserContext( |
482 site_instance->GetBrowserContext()); | 483 site_instance->GetBrowserContext()); |
483 ExtensionService* service = profile->GetExtensionService(); | 484 ExtensionService* service = profile->GetExtensionService(); |
484 if (!service) | 485 if (!service) |
485 return; | 486 return; |
486 | 487 |
487 const Extension* extension = | 488 const Extension* extension = |
488 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo( | 489 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo( |
489 site_instance->site())); | 490 site_instance->GetSite())); |
490 if (!extension) | 491 if (!extension) |
491 return; | 492 return; |
492 | 493 |
493 service->process_map()->Insert(extension->id(), | 494 service->process_map()->Insert(extension->id(), |
494 site_instance->GetProcess()->GetID(), | 495 site_instance->GetProcess()->GetID(), |
495 site_instance->id()); | 496 site_instance->GetId()); |
496 BrowserThread::PostTask( | 497 BrowserThread::PostTask( |
497 BrowserThread::IO, FROM_HERE, | 498 BrowserThread::IO, FROM_HERE, |
498 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess, | 499 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess, |
499 profile->GetExtensionInfoMap(), | 500 profile->GetExtensionInfoMap(), |
500 extension->id(), | 501 extension->id(), |
501 site_instance->GetProcess()->GetID(), | 502 site_instance->GetProcess()->GetID(), |
502 site_instance->id())); | 503 site_instance->GetId())); |
503 } | 504 } |
504 | 505 |
505 void ChromeContentBrowserClient::SiteInstanceDeleting( | 506 void ChromeContentBrowserClient::SiteInstanceDeleting( |
506 SiteInstance* site_instance) { | 507 SiteInstance* site_instance) { |
507 if (!site_instance->HasProcess()) | 508 if (!site_instance->HasProcess()) |
508 return; | 509 return; |
509 | 510 |
510 Profile* profile = Profile::FromBrowserContext( | 511 Profile* profile = Profile::FromBrowserContext( |
511 site_instance->GetBrowserContext()); | 512 site_instance->GetBrowserContext()); |
512 ExtensionService* service = profile->GetExtensionService(); | 513 ExtensionService* service = profile->GetExtensionService(); |
513 if (!service) | 514 if (!service) |
514 return; | 515 return; |
515 | 516 |
516 const Extension* extension = | 517 const Extension* extension = |
517 service->extensions()->GetExtensionOrAppByURL( | 518 service->extensions()->GetExtensionOrAppByURL( |
518 ExtensionURLInfo(site_instance->site())); | 519 ExtensionURLInfo(site_instance->GetSite())); |
519 if (!extension) | 520 if (!extension) |
520 return; | 521 return; |
521 | 522 |
522 service->process_map()->Remove(extension->id(), | 523 service->process_map()->Remove(extension->id(), |
523 site_instance->GetProcess()->GetID(), | 524 site_instance->GetProcess()->GetID(), |
524 site_instance->id()); | 525 site_instance->GetId()); |
525 BrowserThread::PostTask( | 526 BrowserThread::PostTask( |
526 BrowserThread::IO, FROM_HERE, | 527 BrowserThread::IO, FROM_HERE, |
527 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, | 528 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, |
528 profile->GetExtensionInfoMap(), | 529 profile->GetExtensionInfoMap(), |
529 extension->id(), | 530 extension->id(), |
530 site_instance->GetProcess()->GetID(), | 531 site_instance->GetProcess()->GetID(), |
531 site_instance->id())); | 532 site_instance->GetId())); |
532 } | 533 } |
533 | 534 |
534 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( | 535 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( |
535 const GURL& current_url, | 536 const GURL& current_url, |
536 const GURL& new_url) { | 537 const GURL& new_url) { |
537 if (current_url.is_empty()) { | 538 if (current_url.is_empty()) { |
538 // Always choose a new process when navigating to extension URLs. The | 539 // Always choose a new process when navigating to extension URLs. The |
539 // process grouping logic will combine all of a given extension's pages | 540 // process grouping logic will combine all of a given extension's pages |
540 // into the same process. | 541 // into the same process. |
541 if (new_url.SchemeIs(chrome::kExtensionScheme)) | 542 if (new_url.SchemeIs(chrome::kExtensionScheme)) |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 rvh->process()->GetID())) { | 1341 rvh->process()->GetID())) { |
1341 web_prefs.loads_images_automatically = true; | 1342 web_prefs.loads_images_automatically = true; |
1342 web_prefs.javascript_enabled = true; | 1343 web_prefs.javascript_enabled = true; |
1343 } | 1344 } |
1344 | 1345 |
1345 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); | 1346 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); |
1346 | 1347 |
1347 ExtensionService* service = profile->GetExtensionService(); | 1348 ExtensionService* service = profile->GetExtensionService(); |
1348 if (service) { | 1349 if (service) { |
1349 const Extension* extension = service->extensions()->GetByID( | 1350 const Extension* extension = service->extensions()->GetByID( |
1350 rvh->site_instance()->site().host()); | 1351 rvh->site_instance()->GetSite().host()); |
1351 extension_webkit_preferences::SetPreferences( | 1352 extension_webkit_preferences::SetPreferences( |
1352 extension, rvh->delegate()->GetRenderViewType(), &web_prefs); | 1353 extension, rvh->delegate()->GetRenderViewType(), &web_prefs); |
1353 } | 1354 } |
1354 | 1355 |
1355 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) { | 1356 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) { |
1356 web_prefs.allow_scripts_to_close_windows = true; | 1357 web_prefs.allow_scripts_to_close_windows = true; |
1357 } else if (rvh->delegate()->GetRenderViewType() == | 1358 } else if (rvh->delegate()->GetRenderViewType() == |
1358 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { | 1359 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { |
1359 // Disable all kinds of acceleration for background pages. | 1360 // Disable all kinds of acceleration for background pages. |
1360 // See http://crbug.com/96005 and http://crbug.com/96006 | 1361 // See http://crbug.com/96005 and http://crbug.com/96006 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 #if defined(USE_NSS) | 1473 #if defined(USE_NSS) |
1473 crypto::CryptoModuleBlockingPasswordDelegate* | 1474 crypto::CryptoModuleBlockingPasswordDelegate* |
1474 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 1475 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
1475 const GURL& url) { | 1476 const GURL& url) { |
1476 return browser::NewCryptoModuleBlockingDialogDelegate( | 1477 return browser::NewCryptoModuleBlockingDialogDelegate( |
1477 browser::kCryptoModulePasswordKeygen, url.host()); | 1478 browser::kCryptoModulePasswordKeygen, url.host()); |
1478 } | 1479 } |
1479 #endif | 1480 #endif |
1480 | 1481 |
1481 } // namespace chrome | 1482 } // namespace chrome |
OLD | NEW |