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

Side by Side Diff: chrome/renderer/pepper/ppb_pdf_impl.cc

Issue 10802004: Experimental flag for HiDPI-aware PDF Viewer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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/pepper/ppb_pdf_impl.h" 5 #include "chrome/renderer/pepper/ppb_pdf_impl.h"
6 6
7 #include "base/command_line.h"
7 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/render_messages.h" 12 #include "chrome/common/render_messages.h"
11 #include "chrome/renderer/print_web_view_helper.h" 13 #include "chrome/renderer/print_web_view_helper.h"
12 #include "content/public/common/child_process_sandbox_support_linux.h" 14 #include "content/public/common/child_process_sandbox_support_linux.h"
13 #include "content/public/common/content_client.h" 15 #include "content/public/common/content_client.h"
14 #include "content/public/renderer/render_thread.h" 16 #include "content/public/renderer/render_thread.h"
15 #include "content/public/renderer/render_view.h" 17 #include "content/public/renderer/render_view.h"
16 #include "grit/webkit_resources.h" 18 #include "grit/webkit_resources.h"
17 #include "grit/webkit_strings.h" 19 #include "grit/webkit_strings.h"
18 #include "ppapi/c/pp_resource.h" 20 #include "ppapi/c/pp_resource.h"
19 #include "ppapi/c/private/ppb_pdf.h" 21 #include "ppapi/c/private/ppb_pdf.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 342 }
341 343
342 void SaveAs(PP_Instance instance_id) { 344 void SaveAs(PP_Instance instance_id) {
343 PluginInstance* instance = 345 PluginInstance* instance =
344 content::GetHostGlobals()->GetInstance(instance_id); 346 content::GetHostGlobals()->GetInstance(instance_id);
345 if (!instance) 347 if (!instance)
346 return; 348 return;
347 instance->delegate()->SaveURLAs(instance->plugin_url()); 349 instance->delegate()->SaveURLAs(instance->plugin_url());
348 } 350 }
349 351
352 PP_Bool IsFeatureEnabled(PP_PDFFeature feature) {
353 PP_Bool result = PP_FALSE;
354 switch (feature) {
355 case PP_PDFFEATURE_HIDPI:
356 if (CommandLine::ForCurrentProcess()->HasSwitch(
357 switches::kEnableHighDPIPDFPlugin))
358 result = PP_TRUE;
359 break;
360 }
361 return result;
362 }
363
350 const PPB_PDF ppb_pdf = { 364 const PPB_PDF ppb_pdf = {
351 &GetLocalizedString, 365 &GetLocalizedString,
352 &GetResourceImage, 366 &GetResourceImage,
353 &GetFontFileWithFallback, 367 &GetFontFileWithFallback,
354 &GetFontTableForPrivateFontFile, 368 &GetFontTableForPrivateFontFile,
355 &SearchString, 369 &SearchString,
356 &DidStartLoading, 370 &DidStartLoading,
357 &DidStopLoading, 371 &DidStopLoading,
358 &SetContentRestriction, 372 &SetContentRestriction,
359 &HistogramPDFPageCount, 373 &HistogramPDFPageCount,
360 &UserMetricsRecordAction, 374 &UserMetricsRecordAction,
361 &HasUnsupportedFeature, 375 &HasUnsupportedFeature,
362 &SaveAs, 376 &SaveAs,
363 &PPB_PDF_Impl::InvokePrintingForInstance 377 &PPB_PDF_Impl::InvokePrintingForInstance,
378 &IsFeatureEnabled
364 }; 379 };
365 380
366 } // namespace 381 } // namespace
367 382
368 // static 383 // static
369 const PPB_PDF* PPB_PDF_Impl::GetInterface() { 384 const PPB_PDF* PPB_PDF_Impl::GetInterface() {
370 return &ppb_pdf; 385 return &ppb_pdf;
371 } 386 }
372 387
373 // static 388 // static
374 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { 389 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) {
375 #if defined(ENABLE_PRINTING) 390 #if defined(ENABLE_PRINTING)
376 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); 391 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id);
377 if (!instance) 392 if (!instance)
378 return; 393 return;
379 394
380 WebKit::WebElement element = instance->container()->element(); 395 WebKit::WebElement element = instance->container()->element();
381 WebKit::WebView* view = element.document().frame()->view(); 396 WebKit::WebView* view = element.document().frame()->view();
382 content::RenderView* render_view = content::RenderView::FromWebView(view); 397 content::RenderView* render_view = content::RenderView::FromWebView(view);
383 398
384 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view); 399 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view);
385 if (print_view_helper) 400 if (print_view_helper)
386 print_view_helper->PrintNode(element); 401 print_view_helper->PrintNode(element);
387 #endif 402 #endif
388 } 403 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698