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

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: Merge to LKGR, fix a weird runtime issue. 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 #elif defined(OS_ANDROID) 370 #elif defined(OS_ANDROID)
371 return new WebContentsViewAndroid(web_contents); 371 return new WebContentsViewAndroid(web_contents);
372 #else 372 #else
373 #error Need to create your platform WebContentsView here. 373 #error Need to create your platform WebContentsView here.
374 #endif 374 #endif
375 } 375 }
376 376
377 void ChromeContentBrowserClient::RenderViewHostCreated( 377 void ChromeContentBrowserClient::RenderViewHostCreated(
378 RenderViewHost* render_view_host) { 378 RenderViewHost* render_view_host) {
379 379
380 SiteInstance* site_instance = render_view_host->site_instance(); 380 SiteInstance* site_instance = render_view_host->GetSiteInstance();
381 Profile* profile = Profile::FromBrowserContext( 381 Profile* profile = Profile::FromBrowserContext(
382 site_instance->GetBrowserContext()); 382 site_instance->GetBrowserContext());
383 383
384 new ChromeRenderViewHostObserver(render_view_host, 384 new ChromeRenderViewHostObserver(render_view_host,
385 profile->GetNetworkPredictor()); 385 profile->GetNetworkPredictor());
386 new ExtensionMessageHandler(render_view_host); 386 new ExtensionMessageHandler(render_view_host);
387 387
388 if (render_view_host->delegate()->GetRenderViewType() == 388 if (render_view_host->GetDelegate()->GetRenderViewType() ==
389 content::VIEW_TYPE_INTERSTITIAL_PAGE) { 389 content::VIEW_TYPE_INTERSTITIAL_PAGE) {
390 render_view_host->Send(new ChromeViewMsg_SetAsInterstitial( 390 render_view_host->Send(new ChromeViewMsg_SetAsInterstitial(
391 render_view_host->routing_id())); 391 render_view_host->GetRoutingID()));
392 } 392 }
393 } 393 }
394 394
395 void ChromeContentBrowserClient::RenderProcessHostCreated( 395 void ChromeContentBrowserClient::RenderProcessHostCreated(
396 content::RenderProcessHost* host) { 396 content::RenderProcessHost* host) {
397 int id = host->GetID(); 397 int id = host->GetID();
398 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); 398 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
399 host->GetChannel()->AddFilter(new ChromeRenderMessageFilter( 399 host->GetChannel()->AddFilter(new ChromeRenderMessageFilter(
400 id, profile, profile->GetRequestContextForRenderProcess(id))); 400 id, profile, profile->GetRequestContextForRenderProcess(id)));
401 host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile)); 401 host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile));
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 int render_process_id, 1128 int render_process_id,
1129 int render_view_id) { 1129 int render_view_id) {
1130 #if defined(ENABLE_NOTIFICATIONS) 1130 #if defined(ENABLE_NOTIFICATIONS)
1131 RenderViewHost* rvh = RenderViewHost::FromID( 1131 RenderViewHost* rvh = RenderViewHost::FromID(
1132 render_process_id, render_view_id); 1132 render_process_id, render_view_id);
1133 if (!rvh) { 1133 if (!rvh) {
1134 NOTREACHED(); 1134 NOTREACHED();
1135 return; 1135 return;
1136 } 1136 }
1137 1137
1138 content::RenderProcessHost* process = rvh->process(); 1138 content::RenderProcessHost* process = rvh->GetProcess();
1139 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 1139 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
1140 DesktopNotificationService* service = 1140 DesktopNotificationService* service =
1141 DesktopNotificationServiceFactory::GetForProfile(profile); 1141 DesktopNotificationServiceFactory::GetForProfile(profile);
1142 service->RequestPermission( 1142 service->RequestPermission(
1143 source_origin, render_process_id, render_view_id, callback_context, 1143 source_origin, render_process_id, render_view_id, callback_context,
1144 tab_util::GetWebContentsByID(render_process_id, render_view_id)); 1144 tab_util::GetWebContentsByID(render_process_id, render_view_id));
1145 #else 1145 #else
1146 NOTIMPLEMENTED(); 1146 NOTIMPLEMENTED();
1147 #endif 1147 #endif
1148 } 1148 }
(...skipping 27 matching lines...) Expand all
1176 int render_view_id, 1176 int render_view_id,
1177 bool worker) { 1177 bool worker) {
1178 #if defined(ENABLE_NOTIFICATIONS) 1178 #if defined(ENABLE_NOTIFICATIONS)
1179 RenderViewHost* rvh = RenderViewHost::FromID( 1179 RenderViewHost* rvh = RenderViewHost::FromID(
1180 render_process_id, render_view_id); 1180 render_process_id, render_view_id);
1181 if (!rvh) { 1181 if (!rvh) {
1182 NOTREACHED(); 1182 NOTREACHED();
1183 return; 1183 return;
1184 } 1184 }
1185 1185
1186 content::RenderProcessHost* process = rvh->process(); 1186 content::RenderProcessHost* process = rvh->GetProcess();
1187 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 1187 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
1188 DesktopNotificationService* service = 1188 DesktopNotificationService* service =
1189 DesktopNotificationServiceFactory::GetForProfile(profile); 1189 DesktopNotificationServiceFactory::GetForProfile(profile);
1190 service->ShowDesktopNotification( 1190 service->ShowDesktopNotification(
1191 params, render_process_id, render_view_id, 1191 params, render_process_id, render_view_id,
1192 worker ? DesktopNotificationService::WorkerNotification : 1192 worker ? DesktopNotificationService::WorkerNotification :
1193 DesktopNotificationService::PageNotification); 1193 DesktopNotificationService::PageNotification);
1194 #else 1194 #else
1195 NOTIMPLEMENTED(); 1195 NOTIMPLEMENTED();
1196 #endif 1196 #endif
1197 } 1197 }
1198 1198
1199 void ChromeContentBrowserClient::CancelDesktopNotification( 1199 void ChromeContentBrowserClient::CancelDesktopNotification(
1200 int render_process_id, 1200 int render_process_id,
1201 int render_view_id, 1201 int render_view_id,
1202 int notification_id) { 1202 int notification_id) {
1203 #if defined(ENABLE_NOTIFICATIONS) 1203 #if defined(ENABLE_NOTIFICATIONS)
1204 RenderViewHost* rvh = RenderViewHost::FromID( 1204 RenderViewHost* rvh = RenderViewHost::FromID(
1205 render_process_id, render_view_id); 1205 render_process_id, render_view_id);
1206 if (!rvh) { 1206 if (!rvh) {
1207 NOTREACHED(); 1207 NOTREACHED();
1208 return; 1208 return;
1209 } 1209 }
1210 1210
1211 content::RenderProcessHost* process = rvh->process(); 1211 content::RenderProcessHost* process = rvh->GetProcess();
1212 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 1212 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
1213 DesktopNotificationService* service = 1213 DesktopNotificationService* service =
1214 DesktopNotificationServiceFactory::GetForProfile(profile); 1214 DesktopNotificationServiceFactory::GetForProfile(profile);
1215 service->CancelDesktopNotification( 1215 service->CancelDesktopNotification(
1216 render_process_id, render_view_id, notification_id); 1216 render_process_id, render_view_id, notification_id);
1217 #else 1217 #else
1218 NOTIMPLEMENTED(); 1218 NOTIMPLEMENTED();
1219 #endif 1219 #endif
1220 } 1220 }
1221 1221
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 } 1273 }
1274 1274
1275 bool ChromeContentBrowserClient::IsFastShutdownPossible() { 1275 bool ChromeContentBrowserClient::IsFastShutdownPossible() {
1276 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 1276 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
1277 return !browser_command_line.HasSwitch(switches::kChromeFrame); 1277 return !browser_command_line.HasSwitch(switches::kChromeFrame);
1278 } 1278 }
1279 1279
1280 void ChromeContentBrowserClient::OverrideWebkitPrefs( 1280 void ChromeContentBrowserClient::OverrideWebkitPrefs(
1281 RenderViewHost* rvh, WebPreferences* web_prefs) { 1281 RenderViewHost* rvh, WebPreferences* web_prefs) {
1282 Profile* profile = Profile::FromBrowserContext( 1282 Profile* profile = Profile::FromBrowserContext(
1283 rvh->process()->GetBrowserContext()); 1283 rvh->GetProcess()->GetBrowserContext());
1284 PrefService* prefs = profile->GetPrefs(); 1284 PrefService* prefs = profile->GetPrefs();
1285 1285
1286 web_prefs->standard_font_family = 1286 web_prefs->standard_font_family =
1287 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalStandardFontFamily)); 1287 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalStandardFontFamily));
1288 web_prefs->fixed_font_family = 1288 web_prefs->fixed_font_family =
1289 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFixedFontFamily)); 1289 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFixedFontFamily));
1290 web_prefs->serif_font_family = 1290 web_prefs->serif_font_family =
1291 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSerifFontFamily)); 1291 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSerifFontFamily));
1292 web_prefs->sans_serif_font_family = 1292 web_prefs->sans_serif_font_family =
1293 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily)); 1293 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 if (web_prefs->default_encoding.empty()) { 1393 if (web_prefs->default_encoding.empty()) {
1394 prefs->ClearPref(prefs::kGlobalDefaultCharset); 1394 prefs->ClearPref(prefs::kGlobalDefaultCharset);
1395 web_prefs->default_encoding = 1395 web_prefs->default_encoding =
1396 prefs->GetString(prefs::kGlobalDefaultCharset); 1396 prefs->GetString(prefs::kGlobalDefaultCharset);
1397 } 1397 }
1398 DCHECK(!web_prefs->default_encoding.empty()); 1398 DCHECK(!web_prefs->default_encoding.empty());
1399 1399
1400 ExtensionService* service = profile->GetExtensionService(); 1400 ExtensionService* service = profile->GetExtensionService();
1401 if (service) { 1401 if (service) {
1402 const Extension* extension = service->extensions()->GetByID( 1402 const Extension* extension = service->extensions()->GetByID(
1403 rvh->site_instance()->GetSite().host()); 1403 rvh->GetSiteInstance()->GetSite().host());
1404 extension_webkit_preferences::SetPreferences( 1404 extension_webkit_preferences::SetPreferences(
1405 extension, rvh->delegate()->GetRenderViewType(), web_prefs); 1405 extension, rvh->GetDelegate()->GetRenderViewType(), web_prefs);
1406 } 1406 }
1407 1407
1408 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) { 1408 if (rvh->GetDelegate()->GetRenderViewType() ==
1409 chrome::VIEW_TYPE_NOTIFICATION) {
1409 web_prefs->allow_scripts_to_close_windows = true; 1410 web_prefs->allow_scripts_to_close_windows = true;
1410 } else if (rvh->delegate()->GetRenderViewType() == 1411 } else if (rvh->GetDelegate()->GetRenderViewType() ==
1411 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { 1412 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) {
1412 // Disable all kinds of acceleration for background pages. 1413 // Disable all kinds of acceleration for background pages.
1413 // See http://crbug.com/96005 and http://crbug.com/96006 1414 // See http://crbug.com/96005 and http://crbug.com/96006
1414 web_prefs->force_compositing_mode = false; 1415 web_prefs->force_compositing_mode = false;
1415 web_prefs->accelerated_compositing_enabled = false; 1416 web_prefs->accelerated_compositing_enabled = false;
1416 web_prefs->accelerated_2d_canvas_enabled = false; 1417 web_prefs->accelerated_2d_canvas_enabled = false;
1417 web_prefs->accelerated_video_enabled = false; 1418 web_prefs->accelerated_video_enabled = false;
1418 web_prefs->accelerated_painting_enabled = false; 1419 web_prefs->accelerated_painting_enabled = false;
1419 web_prefs->accelerated_plugins_enabled = false; 1420 web_prefs->accelerated_plugins_enabled = false;
1420 } 1421 }
1421 } 1422 }
1422 1423
1423 void ChromeContentBrowserClient::UpdateInspectorSetting( 1424 void ChromeContentBrowserClient::UpdateInspectorSetting(
1424 RenderViewHost* rvh, const std::string& key, const std::string& value) { 1425 RenderViewHost* rvh, const std::string& key, const std::string& value) {
1425 content::BrowserContext* browser_context = 1426 content::BrowserContext* browser_context =
1426 rvh->process()->GetBrowserContext(); 1427 rvh->GetProcess()->GetBrowserContext();
1427 DictionaryPrefUpdate update( 1428 DictionaryPrefUpdate update(
1428 Profile::FromBrowserContext(browser_context)->GetPrefs(), 1429 Profile::FromBrowserContext(browser_context)->GetPrefs(),
1429 prefs::kWebKitInspectorSettings); 1430 prefs::kWebKitInspectorSettings);
1430 DictionaryValue* inspector_settings = update.Get(); 1431 DictionaryValue* inspector_settings = update.Get();
1431 inspector_settings->SetWithoutPathExpansion(key, 1432 inspector_settings->SetWithoutPathExpansion(key,
1432 Value::CreateStringValue(value)); 1433 Value::CreateStringValue(value));
1433 } 1434 }
1434 1435
1435 void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) { 1436 void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) {
1436 content::BrowserContext* browser_context = 1437 content::BrowserContext* browser_context =
1437 rvh->process()->GetBrowserContext(); 1438 rvh->GetProcess()->GetBrowserContext();
1438 Profile::FromBrowserContext(browser_context)->GetPrefs()-> 1439 Profile::FromBrowserContext(browser_context)->GetPrefs()->
1439 ClearPref(prefs::kWebKitInspectorSettings); 1440 ClearPref(prefs::kWebKitInspectorSettings);
1440 } 1441 }
1441 1442
1442 void ChromeContentBrowserClient::BrowserURLHandlerCreated( 1443 void ChromeContentBrowserClient::BrowserURLHandlerCreated(
1443 BrowserURLHandler* handler) { 1444 BrowserURLHandler* handler) {
1444 // Add the default URL handlers. 1445 // Add the default URL handlers.
1445 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride, 1446 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride,
1446 BrowserURLHandler::null_handler()); 1447 BrowserURLHandler::null_handler());
1447 handler->AddHandlerPair(BrowserURLHandler::null_handler(), 1448 handler->AddHandlerPair(BrowserURLHandler::null_handler(),
1448 &ExtensionWebUI::HandleChromeURLOverrideReverse); 1449 &ExtensionWebUI::HandleChromeURLOverrideReverse);
1449 1450
1450 // about: handler. Must come before chrome: handler, since it will 1451 // about: handler. Must come before chrome: handler, since it will
1451 // rewrite about: urls to chrome: URLs and then expect chrome: to 1452 // rewrite about: urls to chrome: URLs and then expect chrome: to
1452 // actually handle them. 1453 // actually handle them.
1453 handler->AddHandlerPair(&WillHandleBrowserAboutURL, 1454 handler->AddHandlerPair(&WillHandleBrowserAboutURL,
1454 BrowserURLHandler::null_handler()); 1455 BrowserURLHandler::null_handler());
1455 // chrome: & friends. 1456 // chrome: & friends.
1456 handler->AddHandlerPair(&HandleWebUI, 1457 handler->AddHandlerPair(&HandleWebUI,
1457 BrowserURLHandler::null_handler()); 1458 BrowserURLHandler::null_handler());
1458 } 1459 }
1459 1460
1460 void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) { 1461 void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) {
1461 Profile* profile = Profile::FromBrowserContext( 1462 Profile* profile = Profile::FromBrowserContext(
1462 rvh->site_instance()->GetProcess()->GetBrowserContext()); 1463 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext());
1463 BrowsingDataRemover* remover = new BrowsingDataRemover(profile, 1464 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
1464 BrowsingDataRemover::EVERYTHING, 1465 BrowsingDataRemover::EVERYTHING,
1465 base::Time()); 1466 base::Time());
1466 remover->Remove(BrowsingDataRemover::REMOVE_CACHE); 1467 remover->Remove(BrowsingDataRemover::REMOVE_CACHE);
1467 // BrowsingDataRemover takes care of deleting itself when done. 1468 // BrowsingDataRemover takes care of deleting itself when done.
1468 } 1469 }
1469 1470
1470 void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) { 1471 void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) {
1471 Profile* profile = Profile::FromBrowserContext( 1472 Profile* profile = Profile::FromBrowserContext(
1472 rvh->site_instance()->GetProcess()->GetBrowserContext()); 1473 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext());
1473 BrowsingDataRemover* remover = new BrowsingDataRemover(profile, 1474 BrowsingDataRemover* remover = new BrowsingDataRemover(profile,
1474 BrowsingDataRemover::EVERYTHING, 1475 BrowsingDataRemover::EVERYTHING,
1475 base::Time()); 1476 base::Time());
1476 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; 1477 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA;
1477 remover->Remove(remove_mask); 1478 remover->Remove(remove_mask);
1478 // BrowsingDataRemover takes care of deleting itself when done. 1479 // BrowsingDataRemover takes care of deleting itself when done.
1479 } 1480 }
1480 1481
1481 FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { 1482 FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() {
1482 return download_util::GetDefaultDownloadDirectory(); 1483 return download_util::GetDefaultDownloadDirectory();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 #if defined(USE_NSS) 1535 #if defined(USE_NSS)
1535 crypto::CryptoModuleBlockingPasswordDelegate* 1536 crypto::CryptoModuleBlockingPasswordDelegate*
1536 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1537 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1537 const GURL& url) { 1538 const GURL& url) {
1538 return browser::NewCryptoModuleBlockingDialogDelegate( 1539 return browser::NewCryptoModuleBlockingDialogDelegate(
1539 browser::kCryptoModulePasswordKeygen, url.host()); 1540 browser::kCryptoModulePasswordKeygen, url.host());
1540 } 1541 }
1541 #endif 1542 #endif
1542 1543
1543 } // namespace chrome 1544 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698