Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/pdf/renderer/ppb_pdf_impl.h" | 5 #include "components/pdf/renderer/ppb_pdf_impl.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_file.h" | 7 #include "base/files/scoped_file.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 | 315 |
| 316 content::RenderView* render_view = instance->GetRenderView(); | 316 content::RenderView* render_view = instance->GetRenderView(); |
| 317 blink::WebLocalFrame* frame = | 317 blink::WebLocalFrame* frame = |
| 318 render_view->GetWebView()->mainFrame()->toWebLocalFrame(); | 318 render_view->GetWebView()->mainFrame()->toWebLocalFrame(); |
| 319 content::Referrer referrer(frame->document().url(), | 319 content::Referrer referrer(frame->document().url(), |
| 320 frame->document().referrerPolicy()); | 320 frame->document().referrerPolicy()); |
| 321 render_view->Send( | 321 render_view->Send( |
| 322 new PDFHostMsg_PDFSaveURLAs(render_view->GetRoutingID(), url, referrer)); | 322 new PDFHostMsg_PDFSaveURLAs(render_view->GetRoutingID(), url, referrer)); |
| 323 } | 323 } |
| 324 | 324 |
| 325 void Print(PP_Instance instance) { | |
| 326 PPB_PDF_Impl::InvokePrintingForInstance(instance); | |
|
Lei Zhang
2014/08/26 21:58:26
Why do we bother making InvokePrintingForInstance(
sadrul
2014/08/27 01:05:15
The return value is used in PepperPDFHost::OnHostM
| |
| 327 } | |
| 328 | |
| 325 PP_Bool IsFeatureEnabled(PP_Instance instance, PP_PDFFeature feature) { | 329 PP_Bool IsFeatureEnabled(PP_Instance instance, PP_PDFFeature feature) { |
| 326 switch (feature) { | 330 switch (feature) { |
| 327 case PP_PDFFEATURE_HIDPI: | 331 case PP_PDFFEATURE_HIDPI: |
| 328 return PP_TRUE; | 332 return PP_TRUE; |
| 329 case PP_PDFFEATURE_PRINTING: | 333 case PP_PDFFEATURE_PRINTING: |
| 330 return (print_delegate && print_delegate->IsPrintingEnabled(instance)) | 334 return (print_delegate && print_delegate->IsPrintingEnabled(instance)) |
| 331 ? PP_TRUE | 335 ? PP_TRUE |
| 332 : PP_FALSE; | 336 : PP_FALSE; |
| 333 } | 337 } |
| 334 return PP_FALSE; | 338 return PP_FALSE; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 &GetFontFileWithFallback, // | 413 &GetFontFileWithFallback, // |
| 410 &GetFontTableForPrivateFontFile, // | 414 &GetFontTableForPrivateFontFile, // |
| 411 &SearchString, // | 415 &SearchString, // |
| 412 &DidStartLoading, // | 416 &DidStartLoading, // |
| 413 &DidStopLoading, // | 417 &DidStopLoading, // |
| 414 &SetContentRestriction, // | 418 &SetContentRestriction, // |
| 415 &HistogramPDFPageCount, // | 419 &HistogramPDFPageCount, // |
| 416 &UserMetricsRecordAction, // | 420 &UserMetricsRecordAction, // |
| 417 &HasUnsupportedFeature, // | 421 &HasUnsupportedFeature, // |
| 418 &SaveAs, // | 422 &SaveAs, // |
| 419 &PPB_PDF_Impl::InvokePrintingForInstance, // | 423 &Print, // |
| 420 &IsFeatureEnabled, // | 424 &IsFeatureEnabled, // |
| 421 &GetResourceImageForScale, // | 425 &GetResourceImageForScale, // |
| 422 &ModalPromptForPassword, // | 426 &ModalPromptForPassword, // |
| 423 &IsOutOfProcess, // | 427 &IsOutOfProcess, // |
| 424 &SetSelectedText, // | 428 &SetSelectedText, // |
| 425 &SetLinkUnderCursor, // | 429 &SetLinkUnderCursor, // |
| 426 }; | 430 }; |
| 427 | 431 |
| 428 } // namespace | 432 } // namespace |
| 429 | 433 |
| 430 // static | 434 // static |
| 431 const PPB_PDF* PPB_PDF_Impl::GetInterface() { | 435 const PPB_PDF* PPB_PDF_Impl::GetInterface() { |
| 432 return &ppb_pdf; | 436 return &ppb_pdf; |
| 433 } | 437 } |
| 434 | 438 |
| 435 // static | 439 // static |
| 436 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { | 440 bool PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { |
| 437 if (print_delegate) | 441 return print_delegate ? print_delegate->Print(instance_id) : false; |
| 438 print_delegate->Print(instance_id); | |
| 439 } | 442 } |
| 440 | 443 |
| 441 void PPB_PDF_Impl::SetPrintDelegate(PPB_PDF_Impl::PrintDelegate* delegate) { | 444 void PPB_PDF_Impl::SetPrintDelegate(PPB_PDF_Impl::PrintDelegate* delegate) { |
| 442 CHECK(!print_delegate) << "There should only be a single PrintDelegate."; | 445 CHECK(!print_delegate) << "There should only be a single PrintDelegate."; |
| 443 print_delegate = delegate; | 446 print_delegate = delegate; |
| 444 } | 447 } |
| 445 | 448 |
| 446 } // namespace pdf | 449 } // namespace pdf |
| OLD | NEW |