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 <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 #elif defined(OS_ANDROID) | 356 #elif defined(OS_ANDROID) |
357 return new WebContentsViewAndroid(web_contents); | 357 return new WebContentsViewAndroid(web_contents); |
358 #else | 358 #else |
359 #error Need to create your platform WebContentsView here. | 359 #error Need to create your platform WebContentsView here. |
360 #endif | 360 #endif |
361 } | 361 } |
362 | 362 |
363 void ChromeContentBrowserClient::RenderViewHostCreated( | 363 void ChromeContentBrowserClient::RenderViewHostCreated( |
364 RenderViewHost* render_view_host) { | 364 RenderViewHost* render_view_host) { |
365 | 365 |
366 SiteInstance* site_instance = render_view_host->site_instance(); | 366 SiteInstance* site_instance = render_view_host->GetSiteInstance(); |
367 Profile* profile = Profile::FromBrowserContext( | 367 Profile* profile = Profile::FromBrowserContext( |
368 site_instance->GetBrowserContext()); | 368 site_instance->GetBrowserContext()); |
369 | 369 |
370 new ChromeRenderViewHostObserver(render_view_host, | 370 new ChromeRenderViewHostObserver(render_view_host, |
371 profile->GetNetworkPredictor()); | 371 profile->GetNetworkPredictor()); |
372 new ExtensionMessageHandler(render_view_host); | 372 new ExtensionMessageHandler(render_view_host); |
373 | 373 |
374 if (render_view_host->delegate()->GetRenderViewType() == | 374 if (render_view_host->GetDelegate()->GetRenderViewType() == |
375 content::VIEW_TYPE_INTERSTITIAL_PAGE) { | 375 content::VIEW_TYPE_INTERSTITIAL_PAGE) { |
376 render_view_host->Send(new ChromeViewMsg_SetAsInterstitial( | 376 render_view_host->Send(new ChromeViewMsg_SetAsInterstitial( |
377 render_view_host->routing_id())); | 377 render_view_host->GetRoutingID())); |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
381 void ChromeContentBrowserClient::RenderProcessHostCreated( | 381 void ChromeContentBrowserClient::RenderProcessHostCreated( |
382 content::RenderProcessHost* host) { | 382 content::RenderProcessHost* host) { |
383 int id = host->GetID(); | 383 int id = host->GetID(); |
384 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); | 384 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
385 host->GetChannel()->AddFilter(new ChromeRenderMessageFilter( | 385 host->GetChannel()->AddFilter(new ChromeRenderMessageFilter( |
386 id, profile, profile->GetRequestContextForRenderProcess(id))); | 386 id, profile, profile->GetRequestContextForRenderProcess(id))); |
387 host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile)); | 387 host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile)); |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 int render_process_id, | 1143 int render_process_id, |
1144 int render_view_id) { | 1144 int render_view_id) { |
1145 #if defined(ENABLE_NOTIFICATIONS) | 1145 #if defined(ENABLE_NOTIFICATIONS) |
1146 RenderViewHost* rvh = RenderViewHost::FromID( | 1146 RenderViewHost* rvh = RenderViewHost::FromID( |
1147 render_process_id, render_view_id); | 1147 render_process_id, render_view_id); |
1148 if (!rvh) { | 1148 if (!rvh) { |
1149 NOTREACHED(); | 1149 NOTREACHED(); |
1150 return; | 1150 return; |
1151 } | 1151 } |
1152 | 1152 |
1153 content::RenderProcessHost* process = rvh->process(); | 1153 content::RenderProcessHost* process = rvh->GetProcess(); |
1154 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); | 1154 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
1155 DesktopNotificationService* service = | 1155 DesktopNotificationService* service = |
1156 DesktopNotificationServiceFactory::GetForProfile(profile); | 1156 DesktopNotificationServiceFactory::GetForProfile(profile); |
1157 service->RequestPermission( | 1157 service->RequestPermission( |
1158 source_origin, render_process_id, render_view_id, callback_context, | 1158 source_origin, render_process_id, render_view_id, callback_context, |
1159 tab_util::GetWebContentsByID(render_process_id, render_view_id)); | 1159 tab_util::GetWebContentsByID(render_process_id, render_view_id)); |
1160 #else | 1160 #else |
1161 NOTIMPLEMENTED(); | 1161 NOTIMPLEMENTED(); |
1162 #endif | 1162 #endif |
1163 } | 1163 } |
(...skipping 27 matching lines...) Expand all Loading... |
1191 int render_view_id, | 1191 int render_view_id, |
1192 bool worker) { | 1192 bool worker) { |
1193 #if defined(ENABLE_NOTIFICATIONS) | 1193 #if defined(ENABLE_NOTIFICATIONS) |
1194 RenderViewHost* rvh = RenderViewHost::FromID( | 1194 RenderViewHost* rvh = RenderViewHost::FromID( |
1195 render_process_id, render_view_id); | 1195 render_process_id, render_view_id); |
1196 if (!rvh) { | 1196 if (!rvh) { |
1197 NOTREACHED(); | 1197 NOTREACHED(); |
1198 return; | 1198 return; |
1199 } | 1199 } |
1200 | 1200 |
1201 content::RenderProcessHost* process = rvh->process(); | 1201 content::RenderProcessHost* process = rvh->GetProcess(); |
1202 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); | 1202 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
1203 DesktopNotificationService* service = | 1203 DesktopNotificationService* service = |
1204 DesktopNotificationServiceFactory::GetForProfile(profile); | 1204 DesktopNotificationServiceFactory::GetForProfile(profile); |
1205 service->ShowDesktopNotification( | 1205 service->ShowDesktopNotification( |
1206 params, render_process_id, render_view_id, | 1206 params, render_process_id, render_view_id, |
1207 worker ? DesktopNotificationService::WorkerNotification : | 1207 worker ? DesktopNotificationService::WorkerNotification : |
1208 DesktopNotificationService::PageNotification); | 1208 DesktopNotificationService::PageNotification); |
1209 #else | 1209 #else |
1210 NOTIMPLEMENTED(); | 1210 NOTIMPLEMENTED(); |
1211 #endif | 1211 #endif |
1212 } | 1212 } |
1213 | 1213 |
1214 void ChromeContentBrowserClient::CancelDesktopNotification( | 1214 void ChromeContentBrowserClient::CancelDesktopNotification( |
1215 int render_process_id, | 1215 int render_process_id, |
1216 int render_view_id, | 1216 int render_view_id, |
1217 int notification_id) { | 1217 int notification_id) { |
1218 #if defined(ENABLE_NOTIFICATIONS) | 1218 #if defined(ENABLE_NOTIFICATIONS) |
1219 RenderViewHost* rvh = RenderViewHost::FromID( | 1219 RenderViewHost* rvh = RenderViewHost::FromID( |
1220 render_process_id, render_view_id); | 1220 render_process_id, render_view_id); |
1221 if (!rvh) { | 1221 if (!rvh) { |
1222 NOTREACHED(); | 1222 NOTREACHED(); |
1223 return; | 1223 return; |
1224 } | 1224 } |
1225 | 1225 |
1226 content::RenderProcessHost* process = rvh->process(); | 1226 content::RenderProcessHost* process = rvh->GetProcess(); |
1227 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); | 1227 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
1228 DesktopNotificationService* service = | 1228 DesktopNotificationService* service = |
1229 DesktopNotificationServiceFactory::GetForProfile(profile); | 1229 DesktopNotificationServiceFactory::GetForProfile(profile); |
1230 service->CancelDesktopNotification( | 1230 service->CancelDesktopNotification( |
1231 render_process_id, render_view_id, notification_id); | 1231 render_process_id, render_view_id, notification_id); |
1232 #else | 1232 #else |
1233 NOTIMPLEMENTED(); | 1233 NOTIMPLEMENTED(); |
1234 #endif | 1234 #endif |
1235 } | 1235 } |
1236 | 1236 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 } | 1297 } |
1298 | 1298 |
1299 bool ChromeContentBrowserClient::IsFastShutdownPossible() { | 1299 bool ChromeContentBrowserClient::IsFastShutdownPossible() { |
1300 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 1300 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
1301 return !browser_command_line.HasSwitch(switches::kChromeFrame); | 1301 return !browser_command_line.HasSwitch(switches::kChromeFrame); |
1302 } | 1302 } |
1303 | 1303 |
1304 void ChromeContentBrowserClient::OverrideWebkitPrefs( | 1304 void ChromeContentBrowserClient::OverrideWebkitPrefs( |
1305 RenderViewHost* rvh, const GURL& url, WebPreferences* web_prefs) { | 1305 RenderViewHost* rvh, const GURL& url, WebPreferences* web_prefs) { |
1306 Profile* profile = Profile::FromBrowserContext( | 1306 Profile* profile = Profile::FromBrowserContext( |
1307 rvh->process()->GetBrowserContext()); | 1307 rvh->GetProcess()->GetBrowserContext()); |
1308 PrefService* prefs = profile->GetPrefs(); | 1308 PrefService* prefs = profile->GetPrefs(); |
1309 | 1309 |
1310 web_prefs->standard_font_family = | 1310 web_prefs->standard_font_family = |
1311 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalStandardFontFamily)); | 1311 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalStandardFontFamily)); |
1312 web_prefs->fixed_font_family = | 1312 web_prefs->fixed_font_family = |
1313 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFixedFontFamily)); | 1313 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalFixedFontFamily)); |
1314 web_prefs->serif_font_family = | 1314 web_prefs->serif_font_family = |
1315 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSerifFontFamily)); | 1315 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSerifFontFamily)); |
1316 web_prefs->sans_serif_font_family = | 1316 web_prefs->sans_serif_font_family = |
1317 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily)); | 1317 UTF8ToUTF16(prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily)); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 if (web_prefs->default_encoding.empty()) { | 1417 if (web_prefs->default_encoding.empty()) { |
1418 prefs->ClearPref(prefs::kGlobalDefaultCharset); | 1418 prefs->ClearPref(prefs::kGlobalDefaultCharset); |
1419 web_prefs->default_encoding = | 1419 web_prefs->default_encoding = |
1420 prefs->GetString(prefs::kGlobalDefaultCharset); | 1420 prefs->GetString(prefs::kGlobalDefaultCharset); |
1421 } | 1421 } |
1422 DCHECK(!web_prefs->default_encoding.empty()); | 1422 DCHECK(!web_prefs->default_encoding.empty()); |
1423 | 1423 |
1424 ExtensionService* service = profile->GetExtensionService(); | 1424 ExtensionService* service = profile->GetExtensionService(); |
1425 if (service) { | 1425 if (service) { |
1426 const Extension* extension = service->extensions()->GetByID( | 1426 const Extension* extension = service->extensions()->GetByID( |
1427 rvh->site_instance()->GetSite().host()); | 1427 rvh->GetSiteInstance()->GetSite().host()); |
1428 extension_webkit_preferences::SetPreferences( | 1428 extension_webkit_preferences::SetPreferences( |
1429 extension, rvh->delegate()->GetRenderViewType(), web_prefs); | 1429 extension, rvh->GetDelegate()->GetRenderViewType(), web_prefs); |
1430 } | 1430 } |
1431 | 1431 |
1432 if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION) { | 1432 if (rvh->GetDelegate()->GetRenderViewType() == |
| 1433 chrome::VIEW_TYPE_NOTIFICATION) { |
1433 web_prefs->allow_scripts_to_close_windows = true; | 1434 web_prefs->allow_scripts_to_close_windows = true; |
1434 } else if (rvh->delegate()->GetRenderViewType() == | 1435 } else if (rvh->GetDelegate()->GetRenderViewType() == |
1435 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { | 1436 chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { |
1436 // Disable all kinds of acceleration for background pages. | 1437 // Disable all kinds of acceleration for background pages. |
1437 // See http://crbug.com/96005 and http://crbug.com/96006 | 1438 // See http://crbug.com/96005 and http://crbug.com/96006 |
1438 web_prefs->force_compositing_mode = false; | 1439 web_prefs->force_compositing_mode = false; |
1439 web_prefs->accelerated_compositing_enabled = false; | 1440 web_prefs->accelerated_compositing_enabled = false; |
1440 web_prefs->accelerated_2d_canvas_enabled = false; | 1441 web_prefs->accelerated_2d_canvas_enabled = false; |
1441 web_prefs->accelerated_video_enabled = false; | 1442 web_prefs->accelerated_video_enabled = false; |
1442 web_prefs->accelerated_painting_enabled = false; | 1443 web_prefs->accelerated_painting_enabled = false; |
1443 web_prefs->accelerated_plugins_enabled = false; | 1444 web_prefs->accelerated_plugins_enabled = false; |
1444 } | 1445 } |
1445 | 1446 |
1446 #if defined(FILE_MANAGER_EXTENSION) | 1447 #if defined(FILE_MANAGER_EXTENSION) |
1447 // Override the default of suppressing HW compositing for WebUI pages for the | 1448 // Override the default of suppressing HW compositing for WebUI pages for the |
1448 // file manager, which is implemented using WebUI but wants HW acceleration | 1449 // file manager, which is implemented using WebUI but wants HW acceleration |
1449 // for video decode & render. | 1450 // for video decode & render. |
1450 if (url.spec() == chrome::kChromeUIFileManagerURL) { | 1451 if (url.spec() == chrome::kChromeUIFileManagerURL) { |
1451 web_prefs->accelerated_compositing_enabled = true; | 1452 web_prefs->accelerated_compositing_enabled = true; |
1452 web_prefs->accelerated_2d_canvas_enabled = true; | 1453 web_prefs->accelerated_2d_canvas_enabled = true; |
1453 } | 1454 } |
1454 #endif | 1455 #endif |
1455 } | 1456 } |
1456 | 1457 |
1457 void ChromeContentBrowserClient::UpdateInspectorSetting( | 1458 void ChromeContentBrowserClient::UpdateInspectorSetting( |
1458 RenderViewHost* rvh, const std::string& key, const std::string& value) { | 1459 RenderViewHost* rvh, const std::string& key, const std::string& value) { |
1459 content::BrowserContext* browser_context = | 1460 content::BrowserContext* browser_context = |
1460 rvh->process()->GetBrowserContext(); | 1461 rvh->GetProcess()->GetBrowserContext(); |
1461 DictionaryPrefUpdate update( | 1462 DictionaryPrefUpdate update( |
1462 Profile::FromBrowserContext(browser_context)->GetPrefs(), | 1463 Profile::FromBrowserContext(browser_context)->GetPrefs(), |
1463 prefs::kWebKitInspectorSettings); | 1464 prefs::kWebKitInspectorSettings); |
1464 DictionaryValue* inspector_settings = update.Get(); | 1465 DictionaryValue* inspector_settings = update.Get(); |
1465 inspector_settings->SetWithoutPathExpansion(key, | 1466 inspector_settings->SetWithoutPathExpansion(key, |
1466 Value::CreateStringValue(value)); | 1467 Value::CreateStringValue(value)); |
1467 } | 1468 } |
1468 | 1469 |
1469 void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) { | 1470 void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) { |
1470 content::BrowserContext* browser_context = | 1471 content::BrowserContext* browser_context = |
1471 rvh->process()->GetBrowserContext(); | 1472 rvh->GetProcess()->GetBrowserContext(); |
1472 Profile::FromBrowserContext(browser_context)->GetPrefs()-> | 1473 Profile::FromBrowserContext(browser_context)->GetPrefs()-> |
1473 ClearPref(prefs::kWebKitInspectorSettings); | 1474 ClearPref(prefs::kWebKitInspectorSettings); |
1474 } | 1475 } |
1475 | 1476 |
1476 void ChromeContentBrowserClient::BrowserURLHandlerCreated( | 1477 void ChromeContentBrowserClient::BrowserURLHandlerCreated( |
1477 BrowserURLHandler* handler) { | 1478 BrowserURLHandler* handler) { |
1478 // Add the default URL handlers. | 1479 // Add the default URL handlers. |
1479 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride, | 1480 handler->AddHandlerPair(&ExtensionWebUI::HandleChromeURLOverride, |
1480 BrowserURLHandler::null_handler()); | 1481 BrowserURLHandler::null_handler()); |
1481 handler->AddHandlerPair(BrowserURLHandler::null_handler(), | 1482 handler->AddHandlerPair(BrowserURLHandler::null_handler(), |
1482 &ExtensionWebUI::HandleChromeURLOverrideReverse); | 1483 &ExtensionWebUI::HandleChromeURLOverrideReverse); |
1483 | 1484 |
1484 // about: handler. Must come before chrome: handler, since it will | 1485 // about: handler. Must come before chrome: handler, since it will |
1485 // rewrite about: urls to chrome: URLs and then expect chrome: to | 1486 // rewrite about: urls to chrome: URLs and then expect chrome: to |
1486 // actually handle them. | 1487 // actually handle them. |
1487 handler->AddHandlerPair(&WillHandleBrowserAboutURL, | 1488 handler->AddHandlerPair(&WillHandleBrowserAboutURL, |
1488 BrowserURLHandler::null_handler()); | 1489 BrowserURLHandler::null_handler()); |
1489 // chrome: & friends. | 1490 // chrome: & friends. |
1490 handler->AddHandlerPair(&HandleWebUI, | 1491 handler->AddHandlerPair(&HandleWebUI, |
1491 BrowserURLHandler::null_handler()); | 1492 BrowserURLHandler::null_handler()); |
1492 } | 1493 } |
1493 | 1494 |
1494 void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) { | 1495 void ChromeContentBrowserClient::ClearCache(RenderViewHost* rvh) { |
1495 Profile* profile = Profile::FromBrowserContext( | 1496 Profile* profile = Profile::FromBrowserContext( |
1496 rvh->site_instance()->GetProcess()->GetBrowserContext()); | 1497 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext()); |
1497 BrowsingDataRemover* remover = new BrowsingDataRemover(profile, | 1498 BrowsingDataRemover* remover = new BrowsingDataRemover(profile, |
1498 BrowsingDataRemover::EVERYTHING, | 1499 BrowsingDataRemover::EVERYTHING, |
1499 base::Time()); | 1500 base::Time()); |
1500 remover->Remove(BrowsingDataRemover::REMOVE_CACHE); | 1501 remover->Remove(BrowsingDataRemover::REMOVE_CACHE); |
1501 // BrowsingDataRemover takes care of deleting itself when done. | 1502 // BrowsingDataRemover takes care of deleting itself when done. |
1502 } | 1503 } |
1503 | 1504 |
1504 void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) { | 1505 void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) { |
1505 Profile* profile = Profile::FromBrowserContext( | 1506 Profile* profile = Profile::FromBrowserContext( |
1506 rvh->site_instance()->GetProcess()->GetBrowserContext()); | 1507 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext()); |
1507 BrowsingDataRemover* remover = new BrowsingDataRemover(profile, | 1508 BrowsingDataRemover* remover = new BrowsingDataRemover(profile, |
1508 BrowsingDataRemover::EVERYTHING, | 1509 BrowsingDataRemover::EVERYTHING, |
1509 base::Time()); | 1510 base::Time()); |
1510 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; | 1511 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; |
1511 remover->Remove(remove_mask); | 1512 remover->Remove(remove_mask); |
1512 // BrowsingDataRemover takes care of deleting itself when done. | 1513 // BrowsingDataRemover takes care of deleting itself when done. |
1513 } | 1514 } |
1514 | 1515 |
1515 FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { | 1516 FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
1516 return download_util::GetDefaultDownloadDirectory(); | 1517 return download_util::GetDefaultDownloadDirectory(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1587 #if defined(USE_NSS) | 1588 #if defined(USE_NSS) |
1588 crypto::CryptoModuleBlockingPasswordDelegate* | 1589 crypto::CryptoModuleBlockingPasswordDelegate* |
1589 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 1590 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
1590 const GURL& url) { | 1591 const GURL& url) { |
1591 return browser::NewCryptoModuleBlockingDialogDelegate( | 1592 return browser::NewCryptoModuleBlockingDialogDelegate( |
1592 browser::kCryptoModulePasswordKeygen, url.host()); | 1593 browser::kCryptoModulePasswordKeygen, url.host()); |
1593 } | 1594 } |
1594 #endif | 1595 #endif |
1595 | 1596 |
1596 } // namespace chrome | 1597 } // namespace chrome |
OLD | NEW |