Chromium Code Reviews| 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/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 #include "chrome/renderer/external_extension.h" | 44 #include "chrome/renderer/external_extension.h" |
| 45 #include "chrome/renderer/loadtimes_extension_bindings.h" | 45 #include "chrome/renderer/loadtimes_extension_bindings.h" |
| 46 #include "chrome/renderer/media/cast_ipc_dispatcher.h" | 46 #include "chrome/renderer/media/cast_ipc_dispatcher.h" |
| 47 #include "chrome/renderer/media/chrome_key_systems.h" | 47 #include "chrome/renderer/media/chrome_key_systems.h" |
| 48 #include "chrome/renderer/net/net_error_helper.h" | 48 #include "chrome/renderer/net/net_error_helper.h" |
| 49 #include "chrome/renderer/net/prescient_networking_dispatcher.h" | 49 #include "chrome/renderer/net/prescient_networking_dispatcher.h" |
| 50 #include "chrome/renderer/net/renderer_net_predictor.h" | 50 #include "chrome/renderer/net/renderer_net_predictor.h" |
| 51 #include "chrome/renderer/net_benchmarking_extension.h" | 51 #include "chrome/renderer/net_benchmarking_extension.h" |
| 52 #include "chrome/renderer/page_load_histograms.h" | 52 #include "chrome/renderer/page_load_histograms.h" |
| 53 #include "chrome/renderer/pepper/pepper_helper.h" | 53 #include "chrome/renderer/pepper/pepper_helper.h" |
| 54 #include "chrome/renderer/pepper/ppb_pdf_impl.h" | |
| 55 #include "chrome/renderer/playback_extension.h" | 54 #include "chrome/renderer/playback_extension.h" |
| 56 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" | 55 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" |
| 57 #include "chrome/renderer/plugins/plugin_uma.h" | 56 #include "chrome/renderer/plugins/plugin_uma.h" |
| 58 #include "chrome/renderer/prefetch_helper.h" | 57 #include "chrome/renderer/prefetch_helper.h" |
| 59 #include "chrome/renderer/prerender/prerender_dispatcher.h" | 58 #include "chrome/renderer/prerender/prerender_dispatcher.h" |
| 60 #include "chrome/renderer/prerender/prerender_helper.h" | 59 #include "chrome/renderer/prerender/prerender_helper.h" |
| 61 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h" | 60 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h" |
| 62 #include "chrome/renderer/prerender/prerenderer_client.h" | 61 #include "chrome/renderer/prerender/prerenderer_client.h" |
| 63 #include "chrome/renderer/principals_extension_bindings.h" | 62 #include "chrome/renderer/principals_extension_bindings.h" |
| 64 #include "chrome/renderer/printing/print_web_view_helper.h" | 63 #include "chrome/renderer/printing/print_web_view_helper.h" |
| 65 #include "chrome/renderer/safe_browsing/malware_dom_details.h" | 64 #include "chrome/renderer/safe_browsing/malware_dom_details.h" |
| 66 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 65 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
| 67 #include "chrome/renderer/searchbox/search_bouncer.h" | 66 #include "chrome/renderer/searchbox/search_bouncer.h" |
| 68 #include "chrome/renderer/searchbox/searchbox.h" | 67 #include "chrome/renderer/searchbox/searchbox.h" |
| 69 #include "chrome/renderer/searchbox/searchbox_extension.h" | 68 #include "chrome/renderer/searchbox/searchbox_extension.h" |
| 70 #include "chrome/renderer/tts_dispatcher.h" | 69 #include "chrome/renderer/tts_dispatcher.h" |
| 71 #include "chrome/renderer/worker_permission_client_proxy.h" | 70 #include "chrome/renderer/worker_permission_client_proxy.h" |
| 72 #include "components/autofill/content/renderer/autofill_agent.h" | 71 #include "components/autofill/content/renderer/autofill_agent.h" |
| 73 #include "components/autofill/content/renderer/password_autofill_agent.h" | 72 #include "components/autofill/content/renderer/password_autofill_agent.h" |
| 74 #include "components/autofill/content/renderer/password_generation_agent.h" | 73 #include "components/autofill/content/renderer/password_generation_agent.h" |
| 75 #include "components/dom_distiller/core/url_constants.h" | 74 #include "components/dom_distiller/core/url_constants.h" |
| 76 #include "components/nacl/renderer/ppb_nacl_private_impl.h" | 75 #include "components/nacl/renderer/ppb_nacl_private_impl.h" |
| 77 #include "components/password_manager/content/renderer/credential_manager_client .h" | 76 #include "components/password_manager/content/renderer/credential_manager_client .h" |
| 77 #include "components/pdf/renderer/ppb_pdf_impl.h" | |
| 78 #include "components/plugins/renderer/mobile_youtube_plugin.h" | 78 #include "components/plugins/renderer/mobile_youtube_plugin.h" |
| 79 #include "components/signin/core/common/profile_management_switches.h" | 79 #include "components/signin/core/common/profile_management_switches.h" |
| 80 #include "components/visitedlink/renderer/visitedlink_slave.h" | 80 #include "components/visitedlink/renderer/visitedlink_slave.h" |
| 81 #include "content/public/common/content_constants.h" | 81 #include "content/public/common/content_constants.h" |
| 82 #include "content/public/renderer/pepper_plugin_instance.h" | |
| 82 #include "content/public/renderer/render_frame.h" | 83 #include "content/public/renderer/render_frame.h" |
| 83 #include "content/public/renderer/render_thread.h" | 84 #include "content/public/renderer/render_thread.h" |
| 84 #include "content/public/renderer/render_view.h" | 85 #include "content/public/renderer/render_view.h" |
| 85 #include "content/public/renderer/render_view_visitor.h" | 86 #include "content/public/renderer/render_view_visitor.h" |
| 86 #include "extensions/common/constants.h" | 87 #include "extensions/common/constants.h" |
| 87 #include "extensions/common/extension.h" | 88 #include "extensions/common/extension.h" |
| 88 #include "extensions/common/extension_set.h" | 89 #include "extensions/common/extension_set.h" |
| 89 #include "extensions/common/extension_urls.h" | 90 #include "extensions/common/extension_urls.h" |
| 90 #include "extensions/common/switches.h" | 91 #include "extensions/common/switches.h" |
| 91 #include "extensions/renderer/dispatcher.h" | 92 #include "extensions/renderer/dispatcher.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 void IsGuestViewApiAvailableToScriptContext( | 252 void IsGuestViewApiAvailableToScriptContext( |
| 252 bool* api_is_available, | 253 bool* api_is_available, |
| 253 extensions::ScriptContext* context) { | 254 extensions::ScriptContext* context) { |
| 254 if (context->GetAvailability("guestViewInternal").is_available()) { | 255 if (context->GetAvailability("guestViewInternal").is_available()) { |
| 255 *api_is_available = true; | 256 *api_is_available = true; |
| 256 } | 257 } |
| 257 } | 258 } |
| 258 | 259 |
| 259 } // namespace | 260 } // namespace |
| 260 | 261 |
| 262 #if defined(ENABLE_FULL_PRINTING) | |
| 263 // XXX: Move into its own file. | |
|
raymes
2014/08/25 03:11:49
I guess you might as well move this into its own f
sadrul
2014/08/26 17:09:54
Done.
| |
| 264 class PDFPluginPrintDelegate : public pdf::PPB_PDF_Impl::PrintDelegate { | |
| 265 public: | |
| 266 PDFPluginPrintDelegate() {} | |
| 267 virtual ~PDFPluginPrintDelegate() {} | |
| 268 | |
| 269 virtual bool IsPrintingEnabled(PP_Instance instance_id) OVERRIDE { | |
| 270 blink::WebElement element = GetWebElement(instance_id); | |
| 271 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); | |
| 272 return helper && helper->IsPrintingEnabled(); | |
| 273 } | |
| 274 | |
| 275 virtual void Print(PP_Instance instance_id) OVERRIDE { | |
| 276 blink::WebElement element = GetWebElement(instance_id); | |
| 277 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); | |
| 278 if (helper) | |
| 279 helper->PrintNode(element); | |
| 280 } | |
| 281 | |
| 282 private: | |
| 283 blink::WebElement GetWebElement(PP_Instance instance_id) { | |
| 284 content::PepperPluginInstance* instance = | |
| 285 content::PepperPluginInstance::Get(instance_id); | |
| 286 if (!instance) | |
| 287 return blink::WebElement(); | |
| 288 return instance->GetContainer()->element(); | |
| 289 } | |
| 290 | |
| 291 printing::PrintWebViewHelper* GetPrintWebViewHelper( | |
| 292 const blink::WebElement& element) { | |
| 293 if (element.isNull()) | |
| 294 return NULL; | |
| 295 blink::WebView* view = element.document().frame()->view(); | |
| 296 content::RenderView* render_view = content::RenderView::FromWebView(view); | |
| 297 return printing::PrintWebViewHelper::Get(render_view); | |
| 298 } | |
| 299 | |
| 300 DISALLOW_COPY_AND_ASSIGN(PDFPluginPrintDelegate); | |
| 301 }; | |
| 302 #endif // defined(ENABLE_FULL_PRINTING) | |
| 303 | |
| 261 ChromeContentRendererClient::ChromeContentRendererClient() { | 304 ChromeContentRendererClient::ChromeContentRendererClient() { |
| 262 g_current_client = this; | 305 g_current_client = this; |
| 263 | 306 |
| 264 extensions::ExtensionsClient::Set( | 307 extensions::ExtensionsClient::Set( |
| 265 extensions::ChromeExtensionsClient::GetInstance()); | 308 extensions::ChromeExtensionsClient::GetInstance()); |
| 266 extensions::ExtensionsRendererClient::Set( | 309 extensions::ExtensionsRendererClient::Set( |
| 267 ChromeExtensionsRendererClient::GetInstance()); | 310 ChromeExtensionsRendererClient::GetInstance()); |
| 268 #if defined(ENABLE_PLUGINS) | 311 #if defined(ENABLE_PLUGINS) |
| 269 for (size_t i = 0; i < arraysize(kPredefinedAllowedCompositorOrigins); ++i) | 312 for (size_t i = 0; i < arraysize(kPredefinedAllowedCompositorOrigins); ++i) |
| 270 allowed_compositor_origins_.insert(kPredefinedAllowedCompositorOrigins[i]); | 313 allowed_compositor_origins_.insert(kPredefinedAllowedCompositorOrigins[i]); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy( | 457 WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy( |
| 415 extension_resource_scheme); | 458 extension_resource_scheme); |
| 416 | 459 |
| 417 #if defined(OS_WIN) | 460 #if defined(OS_WIN) |
| 418 // Report if the renderer process has been patched by chrome_elf. | 461 // Report if the renderer process has been patched by chrome_elf. |
| 419 // TODO(csharp): Remove once the renderer is no longer getting | 462 // TODO(csharp): Remove once the renderer is no longer getting |
| 420 // patched this way. | 463 // patched this way. |
| 421 if (blacklist::IsBlacklistInitialized()) | 464 if (blacklist::IsBlacklistInitialized()) |
| 422 UMA_HISTOGRAM_BOOLEAN("Blacklist.PatchedInRenderer", true); | 465 UMA_HISTOGRAM_BOOLEAN("Blacklist.PatchedInRenderer", true); |
| 423 #endif | 466 #endif |
| 467 #if defined(ENABLE_FULL_PRINTING) | |
| 468 pdf_print_delegate_.reset(new PDFPluginPrintDelegate()); | |
| 469 pdf::PPB_PDF_Impl::SetPrintDelegate(pdf_print_delegate_.get()); | |
| 470 #endif | |
| 424 } | 471 } |
| 425 | 472 |
| 426 void ChromeContentRendererClient::RenderFrameCreated( | 473 void ChromeContentRendererClient::RenderFrameCreated( |
| 427 content::RenderFrame* render_frame) { | 474 content::RenderFrame* render_frame) { |
| 428 new ChromeRenderFrameObserver(render_frame); | 475 new ChromeRenderFrameObserver(render_frame); |
| 429 | 476 |
| 430 ContentSettingsObserver* content_settings = | 477 ContentSettingsObserver* content_settings = |
| 431 new ContentSettingsObserver(render_frame, extension_dispatcher_.get()); | 478 new ContentSettingsObserver(render_frame, extension_dispatcher_.get()); |
| 432 if (chrome_observer_.get()) { | 479 if (chrome_observer_.get()) { |
| 433 content_settings->SetContentSettingRules( | 480 content_settings->SetContentSettingRules( |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1387 } | 1434 } |
| 1388 | 1435 |
| 1389 const void* ChromeContentRendererClient::CreatePPAPIInterface( | 1436 const void* ChromeContentRendererClient::CreatePPAPIInterface( |
| 1390 const std::string& interface_name) { | 1437 const std::string& interface_name) { |
| 1391 #if defined(ENABLE_PLUGINS) | 1438 #if defined(ENABLE_PLUGINS) |
| 1392 #if !defined(DISABLE_NACL) | 1439 #if !defined(DISABLE_NACL) |
| 1393 if (interface_name == PPB_NACL_PRIVATE_INTERFACE) | 1440 if (interface_name == PPB_NACL_PRIVATE_INTERFACE) |
| 1394 return nacl::GetNaClPrivateInterface(); | 1441 return nacl::GetNaClPrivateInterface(); |
| 1395 #endif // DISABLE_NACL | 1442 #endif // DISABLE_NACL |
| 1396 if (interface_name == PPB_PDF_INTERFACE) | 1443 if (interface_name == PPB_PDF_INTERFACE) |
| 1397 return PPB_PDF_Impl::GetInterface(); | 1444 return pdf::PPB_PDF_Impl::GetInterface(); |
| 1398 #endif | 1445 #endif |
| 1399 return NULL; | 1446 return NULL; |
| 1400 } | 1447 } |
| 1401 | 1448 |
| 1402 bool ChromeContentRendererClient::IsExternalPepperPlugin( | 1449 bool ChromeContentRendererClient::IsExternalPepperPlugin( |
| 1403 const std::string& module_name) { | 1450 const std::string& module_name) { |
| 1404 // TODO(bbudge) remove this when the trusted NaCl plugin has been removed. | 1451 // TODO(bbudge) remove this when the trusted NaCl plugin has been removed. |
| 1405 // We must defer certain plugin events for NaCl instances since we switch | 1452 // We must defer certain plugin events for NaCl instances since we switch |
| 1406 // from the in-process to the out-of-process proxy after instantiating them. | 1453 // from the in-process to the out-of-process proxy after instantiating them. |
| 1407 return module_name == "Native Client"; | 1454 return module_name == "Native Client"; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1514 | 1561 |
| 1515 if (IsExtensionOrSharedModuleWhitelisted(url, allowed_video_decode_origins_)) | 1562 if (IsExtensionOrSharedModuleWhitelisted(url, allowed_video_decode_origins_)) |
| 1516 return true; | 1563 return true; |
| 1517 | 1564 |
| 1518 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 1565 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 1519 return channel <= chrome::VersionInfo::CHANNEL_DEV; | 1566 return channel <= chrome::VersionInfo::CHANNEL_DEV; |
| 1520 #else | 1567 #else |
| 1521 return false; | 1568 return false; |
| 1522 #endif | 1569 #endif |
| 1523 } | 1570 } |
| OLD | NEW |