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

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 477263003: pdf: Create a separate component for using the pdf pepper plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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/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
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"
76 #include "components/pdf/renderer/ppb_pdf_impl.h"
77 #include "components/plugins/renderer/mobile_youtube_plugin.h" 77 #include "components/plugins/renderer/mobile_youtube_plugin.h"
78 #include "components/signin/core/common/profile_management_switches.h" 78 #include "components/signin/core/common/profile_management_switches.h"
79 #include "components/visitedlink/renderer/visitedlink_slave.h" 79 #include "components/visitedlink/renderer/visitedlink_slave.h"
80 #include "content/public/common/content_constants.h" 80 #include "content/public/common/content_constants.h"
81 #include "content/public/renderer/pepper_plugin_instance.h"
81 #include "content/public/renderer/render_frame.h" 82 #include "content/public/renderer/render_frame.h"
82 #include "content/public/renderer/render_thread.h" 83 #include "content/public/renderer/render_thread.h"
83 #include "content/public/renderer/render_view.h" 84 #include "content/public/renderer/render_view.h"
84 #include "content/public/renderer/render_view_visitor.h" 85 #include "content/public/renderer/render_view_visitor.h"
85 #include "extensions/common/constants.h" 86 #include "extensions/common/constants.h"
86 #include "extensions/common/extension.h" 87 #include "extensions/common/extension.h"
87 #include "extensions/common/extension_set.h" 88 #include "extensions/common/extension_set.h"
88 #include "extensions/common/extension_urls.h" 89 #include "extensions/common/extension_urls.h"
89 #include "extensions/common/switches.h" 90 #include "extensions/common/switches.h"
90 #include "extensions/renderer/dispatcher.h" 91 #include "extensions/renderer/dispatcher.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 void IsGuestViewApiAvailableToScriptContext( 251 void IsGuestViewApiAvailableToScriptContext(
251 bool* api_is_available, 252 bool* api_is_available,
252 extensions::ScriptContext* context) { 253 extensions::ScriptContext* context) {
253 if (context->GetAvailability("guestViewInternal").is_available()) { 254 if (context->GetAvailability("guestViewInternal").is_available()) {
254 *api_is_available = true; 255 *api_is_available = true;
255 } 256 }
256 } 257 }
257 258
258 } // namespace 259 } // namespace
259 260
261 #if defined(ENABLE_FULL_PRINTING)
262 // XXX: Move into its own file.
263 class PDFPluginPrintDelegate : public pdf::PPB_PDF_Impl::PrintDelegate {
264 public:
265 PDFPluginPrintDelegate() {}
266 virtual ~PDFPluginPrintDelegate() {}
267
268 virtual bool IsPrintingEnabled(PP_Instance instance_id) OVERRIDE {
269 blink::WebElement element = GetWebElement(instance_id);
270 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
271 return helper && helper->IsPrintingEnabled();
272 }
273
274 virtual void Print(PP_Instance instance_id) OVERRIDE {
275 blink::WebElement element = GetWebElement(instance_id);
276 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
277 if (helper)
278 helper->PrintNode(element);
279 }
280
281 private:
282 blink::WebElement GetWebElement(PP_Instance instance_id) {
283 content::PepperPluginInstance* instance =
284 content::PepperPluginInstance::Get(instance_id);
285 if (!instance)
286 return blink::WebElement();
287 return instance->GetContainer()->element();
288 }
289
290 printing::PrintWebViewHelper* GetPrintWebViewHelper(
291 const blink::WebElement& element) {
292 if (element.isNull())
293 return NULL;
294 blink::WebView* view = element.document().frame()->view();
295 content::RenderView* render_view = content::RenderView::FromWebView(view);
296 return printing::PrintWebViewHelper::Get(render_view);
297 }
298
299 DISALLOW_COPY_AND_ASSIGN(PDFPluginPrintDelegate);
300 };
301 #endif // defined(ENABLE_FULL_PRINTING)
302
260 ChromeContentRendererClient::ChromeContentRendererClient() { 303 ChromeContentRendererClient::ChromeContentRendererClient() {
261 g_current_client = this; 304 g_current_client = this;
262 305
263 extensions::ExtensionsClient::Set( 306 extensions::ExtensionsClient::Set(
264 extensions::ChromeExtensionsClient::GetInstance()); 307 extensions::ChromeExtensionsClient::GetInstance());
265 extensions::ExtensionsRendererClient::Set( 308 extensions::ExtensionsRendererClient::Set(
266 ChromeExtensionsRendererClient::GetInstance()); 309 ChromeExtensionsRendererClient::GetInstance());
267 #if defined(ENABLE_PLUGINS) 310 #if defined(ENABLE_PLUGINS)
268 for (size_t i = 0; i < arraysize(kPredefinedAllowedCompositorOrigins); ++i) 311 for (size_t i = 0; i < arraysize(kPredefinedAllowedCompositorOrigins); ++i)
269 allowed_compositor_origins_.insert(kPredefinedAllowedCompositorOrigins[i]); 312 allowed_compositor_origins_.insert(kPredefinedAllowedCompositorOrigins[i]);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy( 452 WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(
410 extension_resource_scheme); 453 extension_resource_scheme);
411 454
412 #if defined(OS_WIN) 455 #if defined(OS_WIN)
413 // Report if the renderer process has been patched by chrome_elf. 456 // Report if the renderer process has been patched by chrome_elf.
414 // TODO(csharp): Remove once the renderer is no longer getting 457 // TODO(csharp): Remove once the renderer is no longer getting
415 // patched this way. 458 // patched this way.
416 if (blacklist::IsBlacklistInitialized()) 459 if (blacklist::IsBlacklistInitialized())
417 UMA_HISTOGRAM_BOOLEAN("Blacklist.PatchedInRenderer", true); 460 UMA_HISTOGRAM_BOOLEAN("Blacklist.PatchedInRenderer", true);
418 #endif 461 #endif
462 #if defined(ENABLE_FULL_PRINTING)
463 pdf_print_delegate_.reset(new PDFPluginPrintDelegate());
464 pdf::PPB_PDF_Impl::SetPrintDelegate(pdf_print_delegate_.get());
465 #endif
419 } 466 }
420 467
421 void ChromeContentRendererClient::RenderFrameCreated( 468 void ChromeContentRendererClient::RenderFrameCreated(
422 content::RenderFrame* render_frame) { 469 content::RenderFrame* render_frame) {
423 new ChromeRenderFrameObserver(render_frame); 470 new ChromeRenderFrameObserver(render_frame);
424 471
425 ContentSettingsObserver* content_settings = 472 ContentSettingsObserver* content_settings =
426 new ContentSettingsObserver(render_frame, extension_dispatcher_.get()); 473 new ContentSettingsObserver(render_frame, extension_dispatcher_.get());
427 if (chrome_observer_.get()) { 474 if (chrome_observer_.get()) {
428 content_settings->SetContentSettingRules( 475 content_settings->SetContentSettingRules(
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 } 1426 }
1380 1427
1381 const void* ChromeContentRendererClient::CreatePPAPIInterface( 1428 const void* ChromeContentRendererClient::CreatePPAPIInterface(
1382 const std::string& interface_name) { 1429 const std::string& interface_name) {
1383 #if defined(ENABLE_PLUGINS) 1430 #if defined(ENABLE_PLUGINS)
1384 #if !defined(DISABLE_NACL) 1431 #if !defined(DISABLE_NACL)
1385 if (interface_name == PPB_NACL_PRIVATE_INTERFACE) 1432 if (interface_name == PPB_NACL_PRIVATE_INTERFACE)
1386 return nacl::GetNaClPrivateInterface(); 1433 return nacl::GetNaClPrivateInterface();
1387 #endif // DISABLE_NACL 1434 #endif // DISABLE_NACL
1388 if (interface_name == PPB_PDF_INTERFACE) 1435 if (interface_name == PPB_PDF_INTERFACE)
1389 return PPB_PDF_Impl::GetInterface(); 1436 return pdf::PPB_PDF_Impl::GetInterface();
1390 #endif 1437 #endif
1391 return NULL; 1438 return NULL;
1392 } 1439 }
1393 1440
1394 bool ChromeContentRendererClient::IsExternalPepperPlugin( 1441 bool ChromeContentRendererClient::IsExternalPepperPlugin(
1395 const std::string& module_name) { 1442 const std::string& module_name) {
1396 // TODO(bbudge) remove this when the trusted NaCl plugin has been removed. 1443 // TODO(bbudge) remove this when the trusted NaCl plugin has been removed.
1397 // We must defer certain plugin events for NaCl instances since we switch 1444 // We must defer certain plugin events for NaCl instances since we switch
1398 // from the in-process to the out-of-process proxy after instantiating them. 1445 // from the in-process to the out-of-process proxy after instantiating them.
1399 return module_name == "Native Client"; 1446 return module_name == "Native Client";
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 1553
1507 if (IsExtensionOrSharedModuleWhitelisted(url, allowed_video_decode_origins_)) 1554 if (IsExtensionOrSharedModuleWhitelisted(url, allowed_video_decode_origins_))
1508 return true; 1555 return true;
1509 1556
1510 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 1557 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
1511 return channel <= chrome::VersionInfo::CHANNEL_DEV; 1558 return channel <= chrome::VersionInfo::CHANNEL_DEV;
1512 #else 1559 #else
1513 return false; 1560 return false;
1514 #endif 1561 #endif
1515 } 1562 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698