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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 9146028: Define the public interface for content browser SiteInstance. This interface is implemented by th... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months 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 #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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "chrome/common/render_messages.h" 66 #include "chrome/common/render_messages.h"
67 #include "chrome/common/url_constants.h" 67 #include "chrome/common/url_constants.h"
68 #include "content/browser/browser_url_handler.h" 68 #include "content/browser/browser_url_handler.h"
69 #include "content/browser/child_process_security_policy.h" 69 #include "content/browser/child_process_security_policy.h"
70 #include "content/browser/gpu/gpu_data_manager.h" 70 #include "content/browser/gpu/gpu_data_manager.h"
71 #include "content/browser/gpu/gpu_process_host.h" 71 #include "content/browser/gpu/gpu_process_host.h"
72 #include "content/browser/plugin_process_host.h" 72 #include "content/browser/plugin_process_host.h"
73 #include "content/browser/renderer_host/render_view_host.h" 73 #include "content/browser/renderer_host/render_view_host.h"
74 #include "content/browser/renderer_host/resource_dispatcher_host.h" 74 #include "content/browser/renderer_host/resource_dispatcher_host.h"
75 #include "content/browser/resource_context.h" 75 #include "content/browser/resource_context.h"
76 #include "content/browser/site_instance.h"
77 #include "content/browser/ssl/ssl_cert_error_handler.h" 76 #include "content/browser/ssl/ssl_cert_error_handler.h"
78 #include "content/browser/ssl/ssl_client_auth_handler.h" 77 #include "content/browser/ssl/ssl_client_auth_handler.h"
79 #include "content/browser/worker_host/worker_process_host.h" 78 #include "content/browser/worker_host/worker_process_host.h"
80 #include "content/public/browser/browser_main_parts.h" 79 #include "content/public/browser/browser_main_parts.h"
81 #include "content/public/browser/render_process_host.h" 80 #include "content/public/browser/render_process_host.h"
81 #include "content/public/browser/site_instance.h"
82 #include "content/public/browser/web_contents.h" 82 #include "content/public/browser/web_contents.h"
83 #include "content/public/browser/web_contents_view.h" 83 #include "content/public/browser/web_contents_view.h"
84 #include "grit/generated_resources.h" 84 #include "grit/generated_resources.h"
85 #include "grit/ui_resources.h" 85 #include "grit/ui_resources.h"
86 #include "net/base/cookie_monster.h" 86 #include "net/base/cookie_monster.h"
87 #include "net/base/cookie_options.h" 87 #include "net/base/cookie_options.h"
88 #include "net/base/network_change_notifier.h" 88 #include "net/base/network_change_notifier.h"
89 #include "ui/base/l10n/l10n_util.h" 89 #include "ui/base/l10n/l10n_util.h"
90 #include "ui/base/resource/resource_bundle.h" 90 #include "ui/base/resource/resource_bundle.h"
91 #include "webkit/glue/webpreferences.h" 91 #include "webkit/glue/webpreferences.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 #elif defined(OS_MACOSX) 316 #elif defined(OS_MACOSX)
317 return tab_contents_view_mac::CreateWebContentsView(web_contents); 317 return tab_contents_view_mac::CreateWebContentsView(web_contents);
318 #else 318 #else
319 #error Need to create your platform WebContentsView here. 319 #error Need to create your platform WebContentsView here.
320 #endif 320 #endif
321 } 321 }
322 322
323 void ChromeContentBrowserClient::RenderViewHostCreated( 323 void ChromeContentBrowserClient::RenderViewHostCreated(
324 RenderViewHost* render_view_host) { 324 RenderViewHost* render_view_host) {
325 325
326 SiteInstance* site_instance = render_view_host->site_instance(); 326 content::SiteInstance* site_instance = render_view_host->site_instance();
327 Profile* profile = Profile::FromBrowserContext( 327 Profile* profile = Profile::FromBrowserContext(
328 site_instance->GetBrowserContext()); 328 site_instance->GetBrowserContext());
329 329
330 new ChromeRenderViewHostObserver(render_view_host, 330 new ChromeRenderViewHostObserver(render_view_host,
331 profile->GetNetworkPredictor()); 331 profile->GetNetworkPredictor());
332 new ExtensionMessageHandler(render_view_host); 332 new ExtensionMessageHandler(render_view_host);
333 } 333 }
334 334
335 void ChromeContentBrowserClient::RenderProcessHostCreated( 335 void ChromeContentBrowserClient::RenderProcessHostCreated(
336 content::RenderProcessHost* host) { 336 content::RenderProcessHost* host) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 if (privilege_required == PRIV_ISOLATED) 476 if (privilege_required == PRIV_ISOLATED)
477 return IsIsolatedAppInProcess(site_url, process_host, process_map, service); 477 return IsIsolatedAppInProcess(site_url, process_host, process_map, service);
478 478
479 // Otherwise, just make sure the process privilege matches the privilege 479 // Otherwise, just make sure the process privilege matches the privilege
480 // required by the site. 480 // required by the site.
481 return GetProcessPrivilege(process_host, process_map, service) == 481 return GetProcessPrivilege(process_host, process_map, service) ==
482 privilege_required; 482 privilege_required;
483 } 483 }
484 484
485 void ChromeContentBrowserClient::SiteInstanceGotProcess( 485 void ChromeContentBrowserClient::SiteInstanceGotProcess(
486 SiteInstance* site_instance) { 486 content::SiteInstance* site_instance) {
487 CHECK(site_instance->HasProcess()); 487 CHECK(site_instance->HasProcess());
488 488
489 Profile* profile = Profile::FromBrowserContext( 489 Profile* profile = Profile::FromBrowserContext(
490 site_instance->GetBrowserContext()); 490 site_instance->GetBrowserContext());
491 ExtensionService* service = profile->GetExtensionService(); 491 ExtensionService* service = profile->GetExtensionService();
492 if (!service) 492 if (!service)
493 return; 493 return;
494 494
495 const Extension* extension = 495 const Extension* extension =
496 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo( 496 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(
497 site_instance->site())); 497 site_instance->GetSite()));
498 if (!extension) 498 if (!extension)
499 return; 499 return;
500 500
501 service->process_map()->Insert(extension->id(), 501 service->process_map()->Insert(extension->id(),
502 site_instance->GetProcess()->GetID(), 502 site_instance->GetProcess()->GetID(),
503 site_instance->id()); 503 site_instance->GetId());
504 BrowserThread::PostTask( 504 BrowserThread::PostTask(
505 BrowserThread::IO, FROM_HERE, 505 BrowserThread::IO, FROM_HERE,
506 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess, 506 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess,
507 profile->GetExtensionInfoMap(), 507 profile->GetExtensionInfoMap(),
508 extension->id(), 508 extension->id(),
509 site_instance->GetProcess()->GetID(), 509 site_instance->GetProcess()->GetID(),
510 site_instance->id())); 510 site_instance->GetId()));
511 } 511 }
512 512
513 void ChromeContentBrowserClient::SiteInstanceDeleting( 513 void ChromeContentBrowserClient::SiteInstanceDeleting(
514 SiteInstance* site_instance) { 514 content::SiteInstance* site_instance) {
515 if (!site_instance->HasProcess()) 515 if (!site_instance->HasProcess())
516 return; 516 return;
517 517
518 Profile* profile = Profile::FromBrowserContext( 518 Profile* profile = Profile::FromBrowserContext(
519 site_instance->GetBrowserContext()); 519 site_instance->GetBrowserContext());
520 ExtensionService* service = profile->GetExtensionService(); 520 ExtensionService* service = profile->GetExtensionService();
521 if (!service) 521 if (!service)
522 return; 522 return;
523 523
524 const Extension* extension = 524 const Extension* extension =
525 service->extensions()->GetExtensionOrAppByURL( 525 service->extensions()->GetExtensionOrAppByURL(
526 ExtensionURLInfo(site_instance->site())); 526 ExtensionURLInfo(site_instance->GetSite()));
527 if (!extension) 527 if (!extension)
528 return; 528 return;
529 529
530 service->process_map()->Remove(extension->id(), 530 service->process_map()->Remove(extension->id(),
531 site_instance->GetProcess()->GetID(), 531 site_instance->GetProcess()->GetID(),
532 site_instance->id()); 532 site_instance->GetId());
533 BrowserThread::PostTask( 533 BrowserThread::PostTask(
534 BrowserThread::IO, FROM_HERE, 534 BrowserThread::IO, FROM_HERE,
535 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, 535 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
536 profile->GetExtensionInfoMap(), 536 profile->GetExtensionInfoMap(),
537 extension->id(), 537 extension->id(),
538 site_instance->GetProcess()->GetID(), 538 site_instance->GetProcess()->GetID(),
539 site_instance->id())); 539 site_instance->GetId()));
540 } 540 }
541 541
542 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( 542 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
543 const GURL& current_url, 543 const GURL& current_url,
544 const GURL& new_url) { 544 const GURL& new_url) {
545 if (current_url.is_empty()) { 545 if (current_url.is_empty()) {
546 // Always choose a new process when navigating to extension URLs. The 546 // Always choose a new process when navigating to extension URLs. The
547 // process grouping logic will combine all of a given extension's pages 547 // process grouping logic will combine all of a given extension's pages
548 // into the same process. 548 // into the same process.
549 if (new_url.SchemeIs(chrome::kExtensionScheme)) 549 if (new_url.SchemeIs(chrome::kExtensionScheme))
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 rvh->process()->GetID())) { 1350 rvh->process()->GetID())) {
1351 web_prefs.loads_images_automatically = true; 1351 web_prefs.loads_images_automatically = true;
1352 web_prefs.javascript_enabled = true; 1352 web_prefs.javascript_enabled = true;
1353 } 1353 }
1354 1354
1355 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); 1355 web_prefs.is_online = !net::NetworkChangeNotifier::IsOffline();
1356 1356
1357 ExtensionService* service = profile->GetExtensionService(); 1357 ExtensionService* service = profile->GetExtensionService();
1358 if (service) { 1358 if (service) {
1359 const Extension* extension = service->extensions()->GetByID( 1359 const Extension* extension = service->extensions()->GetByID(
1360 rvh->site_instance()->site().host()); 1360 rvh->site_instance()->GetSite().host());
1361 extension_webkit_preferences::SetPreferences( 1361 extension_webkit_preferences::SetPreferences(
1362 extension, rvh->delegate()->GetRenderViewType(), &web_prefs); 1362 extension, rvh->delegate()->GetRenderViewType(), &web_prefs);
1363 } 1363 }
1364 1364
1365 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) { 1365 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) {
1366 web_prefs.allow_scripts_to_close_windows = true; 1366 web_prefs.allow_scripts_to_close_windows = true;
1367 } else if (rvh->delegate()->GetRenderViewType() == 1367 } else if (rvh->delegate()->GetRenderViewType() ==
1368 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { 1368 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) {
1369 // Disable all kinds of acceleration for background pages. 1369 // Disable all kinds of acceleration for background pages.
1370 // See http://crbug.com/96005 and http://crbug.com/96006 1370 // See http://crbug.com/96005 and http://crbug.com/96006
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 #if defined(USE_NSS) 1482 #if defined(USE_NSS)
1483 crypto::CryptoModuleBlockingPasswordDelegate* 1483 crypto::CryptoModuleBlockingPasswordDelegate*
1484 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1484 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1485 const GURL& url) { 1485 const GURL& url) {
1486 return browser::NewCryptoModuleBlockingDialogDelegate( 1486 return browser::NewCryptoModuleBlockingDialogDelegate(
1487 browser::kCryptoModulePasswordKeygen, url.host()); 1487 browser::kCryptoModulePasswordKeygen, url.host());
1488 } 1488 }
1489 #endif 1489 #endif
1490 1490
1491 } // namespace chrome 1491 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698