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

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

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for initial review. Created 8 years, 9 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 <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 #elif defined(OS_ANDROID) 353 #elif defined(OS_ANDROID)
354 return new WebContentsViewAndroid(web_contents); 354 return new WebContentsViewAndroid(web_contents);
355 #else 355 #else
356 #error Need to create your platform WebContentsView here. 356 #error Need to create your platform WebContentsView here.
357 #endif 357 #endif
358 } 358 }
359 359
360 void ChromeContentBrowserClient::RenderViewHostCreated( 360 void ChromeContentBrowserClient::RenderViewHostCreated(
361 RenderViewHost* render_view_host) { 361 RenderViewHost* render_view_host) {
362 362
363 SiteInstance* site_instance = render_view_host->site_instance(); 363 SiteInstance* site_instance = render_view_host->GetSiteInstance();
364 Profile* profile = Profile::FromBrowserContext( 364 Profile* profile = Profile::FromBrowserContext(
365 site_instance->GetBrowserContext()); 365 site_instance->GetBrowserContext());
366 366
367 new ChromeRenderViewHostObserver(render_view_host, 367 new ChromeRenderViewHostObserver(render_view_host,
368 profile->GetNetworkPredictor()); 368 profile->GetNetworkPredictor());
369 new ExtensionMessageHandler(render_view_host); 369 new ExtensionMessageHandler(render_view_host);
370 370
371 if (render_view_host->delegate()->GetRenderViewType() == 371 if (render_view_host->GetDelegate()->GetRenderViewType() ==
372 content::VIEW_TYPE_INTERSTITIAL_PAGE) { 372 content::VIEW_TYPE_INTERSTITIAL_PAGE) {
373 render_view_host->Send(new ChromeViewMsg_SetAsInterstitial( 373 render_view_host->Send(new ChromeViewMsg_SetAsInterstitial(
374 render_view_host->routing_id())); 374 render_view_host->GetRoutingID()));
375 } 375 }
376 } 376 }
377 377
378 void ChromeContentBrowserClient::RenderProcessHostCreated( 378 void ChromeContentBrowserClient::RenderProcessHostCreated(
379 content::RenderProcessHost* host) { 379 content::RenderProcessHost* host) {
380 int id = host->GetID(); 380 int id = host->GetID();
381 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); 381 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
382 host->GetChannel()->AddFilter(new ChromeRenderMessageFilter( 382 host->GetChannel()->AddFilter(new ChromeRenderMessageFilter(
383 id, profile, profile->GetRequestContextForRenderProcess(id))); 383 id, profile, profile->GetRequestContextForRenderProcess(id)));
384 host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile)); 384 host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile));
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 int callback_context, 1081 int callback_context,
1082 int render_process_id, 1082 int render_process_id,
1083 int render_view_id) { 1083 int render_view_id) {
1084 RenderViewHost* rvh = RenderViewHost::FromID( 1084 RenderViewHost* rvh = RenderViewHost::FromID(
1085 render_process_id, render_view_id); 1085 render_process_id, render_view_id);
1086 if (!rvh) { 1086 if (!rvh) {
1087 NOTREACHED(); 1087 NOTREACHED();
1088 return; 1088 return;
1089 } 1089 }
1090 1090
1091 content::RenderProcessHost* process = rvh->process(); 1091 content::RenderProcessHost* process = rvh->GetProcess();
1092 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 1092 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
1093 DesktopNotificationService* service = 1093 DesktopNotificationService* service =
1094 DesktopNotificationServiceFactory::GetForProfile(profile); 1094 DesktopNotificationServiceFactory::GetForProfile(profile);
1095 service->RequestPermission( 1095 service->RequestPermission(
1096 source_origin, render_process_id, render_view_id, callback_context, 1096 source_origin, render_process_id, render_view_id, callback_context,
1097 tab_util::GetWebContentsByID(render_process_id, render_view_id)); 1097 tab_util::GetWebContentsByID(render_process_id, render_view_id));
1098 } 1098 }
1099 1099
1100 WebKit::WebNotificationPresenter::Permission 1100 WebKit::WebNotificationPresenter::Permission
1101 ChromeContentBrowserClient::CheckDesktopNotificationPermission( 1101 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
(...skipping 19 matching lines...) Expand all
1121 int render_process_id, 1121 int render_process_id,
1122 int render_view_id, 1122 int render_view_id,
1123 bool worker) { 1123 bool worker) {
1124 RenderViewHost* rvh = RenderViewHost::FromID( 1124 RenderViewHost* rvh = RenderViewHost::FromID(
1125 render_process_id, render_view_id); 1125 render_process_id, render_view_id);
1126 if (!rvh) { 1126 if (!rvh) {
1127 NOTREACHED(); 1127 NOTREACHED();
1128 return; 1128 return;
1129 } 1129 }
1130 1130
1131 content::RenderProcessHost* process = rvh->process(); 1131 content::RenderProcessHost* process = rvh->GetProcess();
1132 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 1132 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
1133 DesktopNotificationService* service = 1133 DesktopNotificationService* service =
1134 DesktopNotificationServiceFactory::GetForProfile(profile); 1134 DesktopNotificationServiceFactory::GetForProfile(profile);
1135 service->ShowDesktopNotification( 1135 service->ShowDesktopNotification(
1136 params, render_process_id, render_view_id, 1136 params, render_process_id, render_view_id,
1137 worker ? DesktopNotificationService::WorkerNotification : 1137 worker ? DesktopNotificationService::WorkerNotification :
1138 DesktopNotificationService::PageNotification); 1138 DesktopNotificationService::PageNotification);
1139 } 1139 }
1140 1140
1141 void ChromeContentBrowserClient::CancelDesktopNotification( 1141 void ChromeContentBrowserClient::CancelDesktopNotification(
1142 int render_process_id, 1142 int render_process_id,
1143 int render_view_id, 1143 int render_view_id,
1144 int notification_id) { 1144 int notification_id) {
1145 RenderViewHost* rvh = RenderViewHost::FromID( 1145 RenderViewHost* rvh = RenderViewHost::FromID(
1146 render_process_id, render_view_id); 1146 render_process_id, render_view_id);
1147 if (!rvh) { 1147 if (!rvh) {
1148 NOTREACHED(); 1148 NOTREACHED();
1149 return; 1149 return;
1150 } 1150 }
1151 1151
1152 content::RenderProcessHost* process = rvh->process(); 1152 content::RenderProcessHost* process = rvh->GetProcess();
1153 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 1153 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
1154 DesktopNotificationService* service = 1154 DesktopNotificationService* service =
1155 DesktopNotificationServiceFactory::GetForProfile(profile); 1155 DesktopNotificationServiceFactory::GetForProfile(profile);
1156 service->CancelDesktopNotification( 1156 service->CancelDesktopNotification(
1157 render_process_id, render_view_id, notification_id); 1157 render_process_id, render_view_id, notification_id);
1158 } 1158 }
1159 1159
1160 bool ChromeContentBrowserClient::CanCreateWindow( 1160 bool ChromeContentBrowserClient::CanCreateWindow(
1161 const GURL& source_origin, 1161 const GURL& source_origin,
1162 WindowContainerType container_type, 1162 WindowContainerType container_type,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 } 1211 }
1212 1212
1213 bool ChromeContentBrowserClient::IsFastShutdownPossible() { 1213 bool ChromeContentBrowserClient::IsFastShutdownPossible() {
1214 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 1214 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
1215 return !browser_command_line.HasSwitch(switches::kChromeFrame); 1215 return !browser_command_line.HasSwitch(switches::kChromeFrame);
1216 } 1216 }
1217 1217
1218 void ChromeContentBrowserClient::OverrideWebkitPrefs( 1218 void ChromeContentBrowserClient::OverrideWebkitPrefs(
1219 RenderViewHost* rvh, WebPreferences* web_prefs) { 1219 RenderViewHost* rvh, WebPreferences* web_prefs) {
1220 Profile* profile = Profile::FromBrowserContext( 1220 Profile* profile = Profile::FromBrowserContext(
1221 rvh->process()->GetBrowserContext()); 1221 rvh->GetProcess()->GetBrowserContext());
1222 PrefService* prefs = profile->GetPrefs(); 1222 PrefService* prefs = profile->GetPrefs();
1223 1223
1224 web_prefs->standard_font_family = 1224 web_prefs->standard_font_family =
1225 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalStandardFontFamily)); 1225 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalStandardFontFamily));
1226 web_prefs->fixed_font_family = 1226 web_prefs->fixed_font_family =
1227 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFixedFontFamily)); 1227 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFixedFontFamily));
1228 web_prefs->serif_font_family = 1228 web_prefs->serif_font_family =
1229 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSerifFontFamily)); 1229 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSerifFontFamily));
1230 web_prefs->sans_serif_font_family = 1230 web_prefs->sans_serif_font_family =
1231 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily)); 1231 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 if (web_prefs->default_encoding.empty()) { 1331 if (web_prefs->default_encoding.empty()) {
1332 prefs->ClearPref(prefs::kGlobalDefaultCharset); 1332 prefs->ClearPref(prefs::kGlobalDefaultCharset);
1333 web_prefs->default_encoding = 1333 web_prefs->default_encoding =
1334 prefs->GetString(prefs::kGlobalDefaultCharset); 1334 prefs->GetString(prefs::kGlobalDefaultCharset);
1335 } 1335 }
1336 DCHECK(!web_prefs->default_encoding.empty()); 1336 DCHECK(!web_prefs->default_encoding.empty());
1337 1337
1338 ExtensionService* service = profile->GetExtensionService(); 1338 ExtensionService* service = profile->GetExtensionService();
1339 if (service) { 1339 if (service) {
1340 const Extension* extension = service->extensions()->GetByID( 1340 const Extension* extension = service->extensions()->GetByID(
1341 rvh->site_instance()->GetSite().host()); 1341 rvh->GetSiteInstance()->GetSite().host());
1342 extension_webkit_preferences::SetPreferences( 1342 extension_webkit_preferences::SetPreferences(
1343 extension, rvh->delegate()->GetRenderViewType(), web_prefs); 1343 extension, rvh->GetDelegate()->GetRenderViewType(), web_prefs);
1344 } 1344 }
1345 1345
1346 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) { 1346 if (rvh->GetDelegate()->GetRenderViewType() ==
1347 chrome::VIEW_TYPE_NOTIFICATION) {
1347 web_prefs->allow_scripts_to_close_windows = true; 1348 web_prefs->allow_scripts_to_close_windows = true;
1348 } else if (rvh->delegate()->GetRenderViewType() == 1349 } else if (rvh->GetDelegate()->GetRenderViewType() ==
1349 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { 1350 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) {
1350 // Disable all kinds of acceleration for background pages. 1351 // Disable all kinds of acceleration for background pages.
1351 // See http://crbug.com/96005 and http://crbug.com/96006 1352 // See http://crbug.com/96005 and http://crbug.com/96006
1352 web_prefs->force_compositing_mode = false; 1353 web_prefs->force_compositing_mode = false;
1353 web_prefs->accelerated_compositing_enabled = false; 1354 web_prefs->accelerated_compositing_enabled = false;
1354 web_prefs->accelerated_2d_canvas_enabled = false; 1355 web_prefs->accelerated_2d_canvas_enabled = false;
1355 web_prefs->accelerated_video_enabled = false; 1356 web_prefs->accelerated_video_enabled = false;
1356 web_prefs->accelerated_painting_enabled = false; 1357 web_prefs->accelerated_painting_enabled = false;
1357 web_prefs->accelerated_plugins_enabled = false; 1358 web_prefs->accelerated_plugins_enabled = false;
1358 } 1359 }
1359 } 1360 }
1360 1361
1361 void ChromeContentBrowserClient::UpdateInspectorSetting( 1362 void ChromeContentBrowserClient::UpdateInspectorSetting(
1362 RenderViewHost* rvh, const std::string& key, const std::string& value) { 1363 RenderViewHost* rvh, const std::string& key, const std::string& value) {
1363 content::BrowserContext* browser_context = 1364 content::BrowserContext* browser_context =
1364 rvh->process()->GetBrowserContext(); 1365 rvh->GetProcess()->GetBrowserContext();
1365 DictionaryPrefUpdate update( 1366 DictionaryPrefUpdate update(
1366 Profile::FromBrowserContext(browser_context)->GetPrefs(), 1367 Profile::FromBrowserContext(browser_context)->GetPrefs(),
1367 prefs::kWebKitInspectorSettings); 1368 prefs::kWebKitInspectorSettings);
1368 DictionaryValue* inspector_settings = update.Get(); 1369 DictionaryValue* inspector_settings = update.Get();
1369 inspector_settings->SetWithoutPathExpansion(key, 1370 inspector_settings->SetWithoutPathExpansion(key,
1370 Value::CreateStringValue(value)); 1371 Value::CreateStringValue(value));
1371 } 1372 }
1372 1373
1373 void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) { 1374 void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) {
1374 content::BrowserContext* browser_context = 1375 content::BrowserContext* browser_context =
1375 rvh->process()->GetBrowserContext(); 1376 rvh->GetProcess()->GetBrowserContext();
1376 Profile::FromBrowserContext(browser_context)->GetPrefs()-> 1377 Profile::FromBrowserContext(browser_context)->GetPrefs()->
1377 ClearPref(prefs::kWebKitInspectorSettings); 1378 ClearPref(prefs::kWebKitInspectorSettings);
1378 } 1379 }
1379 1380
1380 void ChromeContentBrowserClient::BrowserURLHandlerCreated( 1381 void ChromeContentBrowserClient::BrowserURLHandlerCreated(
1381 BrowserURLHandler* handler) { 1382 BrowserURLHandler* handler) {
1382 // Add the default URL handlers. 1383 // Add the default URL handlers.
1383 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride, 1384 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride,
1384 BrowserURLHandler::null_handler()); 1385 BrowserURLHandler::null_handler());
1385 handler->AddHandlerPair(BrowserURLHandler::null_handler(), 1386 handler->AddHandlerPair(BrowserURLHandler::null_handler(),
1386 &ExtensionWebUI::HandleChromeURLOverrideReverse); 1387 &ExtensionWebUI::HandleChromeURLOverrideReverse);
1387 1388
1388 // about: handler. Must come before chrome: handler, since it will 1389 // about: handler. Must come before chrome: handler, since it will
1389 // rewrite about: urls to chrome: URLs and then expect chrome: to 1390 // rewrite about: urls to chrome: URLs and then expect chrome: to
1390 // actually handle them. 1391 // actually handle them.
1391 handler->AddHandlerPair(&WillHandleBrowserAboutURL, 1392 handler->AddHandlerPair(&WillHandleBrowserAboutURL,
1392 BrowserURLHandler::null_handler()); 1393 BrowserURLHandler::null_handler());
1393 // chrome: & friends. 1394 // chrome: & friends.
1394 handler->AddHandlerPair(&HandleWebUI, 1395 handler->AddHandlerPair(&HandleWebUI,
1395 BrowserURLHandler::null_handler()); 1396 BrowserURLHandler::null_handler());
1396 } 1397 }
1397 1398
1398 void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) { 1399 void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) {
1399 Profile* profile = Profile::FromBrowserContext( 1400 Profile* profile = Profile::FromBrowserContext(
1400 rvh->site_instance()->GetProcess()->GetBrowserContext()); 1401 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext());
1401 BrowsingDataRemover* remover = new BrowsingDataRemover(profile, 1402 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
1402 BrowsingDataRemover::EVERYTHING, 1403 BrowsingDataRemover::EVERYTHING,
1403 base::Time()); 1404 base::Time());
1404 remover->Remove(BrowsingDataRemover::REMOVE_CACHE); 1405 remover->Remove(BrowsingDataRemover::REMOVE_CACHE);
1405 // BrowsingDataRemover takes care of deleting itself when done. 1406 // BrowsingDataRemover takes care of deleting itself when done.
1406 } 1407 }
1407 1408
1408 void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) { 1409 void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) {
1409 Profile* profile = Profile::FromBrowserContext( 1410 Profile* profile = Profile::FromBrowserContext(
1410 rvh->site_instance()->GetProcess()->GetBrowserContext()); 1411 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext());
1411 BrowsingDataRemover* remover = new BrowsingDataRemover(profile, 1412 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
1412 BrowsingDataRemover::EVERYTHING, 1413 BrowsingDataRemover::EVERYTHING,
1413 base::Time()); 1414 base::Time());
1414 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; 1415 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA;
1415 remover->Remove(remove_mask); 1416 remover->Remove(remove_mask);
1416 // BrowsingDataRemover takes care of deleting itself when done. 1417 // BrowsingDataRemover takes care of deleting itself when done.
1417 } 1418 }
1418 1419
1419 FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { 1420 FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
1420 return download_util::GetDefaultDownloadDirectory(); 1421 return download_util::GetDefaultDownloadDirectory();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698