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/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/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/safe_numerics.h" | 9 #include "base/safe_numerics.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "third_party/WebKit/public/web/WebElement.h" | 31 #include "third_party/WebKit/public/web/WebElement.h" |
32 #include "third_party/WebKit/public/web/WebFrame.h" | 32 #include "third_party/WebKit/public/web/WebFrame.h" |
33 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 33 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
34 #include "third_party/WebKit/public/web/WebView.h" | 34 #include "third_party/WebKit/public/web/WebView.h" |
35 #include "third_party/icu/source/i18n/unicode/usearch.h" | 35 #include "third_party/icu/source/i18n/unicode/usearch.h" |
36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/base/layout.h" | 37 #include "ui/base/layout.h" |
38 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
39 | 39 |
40 using ppapi::PpapiGlobals; | 40 using ppapi::PpapiGlobals; |
41 using WebKit::WebElement; | 41 using blink::WebElement; |
42 using WebKit::WebView; | 42 using blink::WebView; |
43 using content::RenderThread; | 43 using content::RenderThread; |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 47 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
48 class PrivateFontFile : public ppapi::Resource { | 48 class PrivateFontFile : public ppapi::Resource { |
49 public: | 49 public: |
50 PrivateFontFile(PP_Instance instance, int fd) | 50 PrivateFontFile(PP_Instance instance, int fd) |
51 : Resource(ppapi::OBJECT_IS_IMPL, instance), | 51 : Resource(ppapi::OBJECT_IS_IMPL, instance), |
52 fd_(fd) { | 52 fd_(fd) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 { PP_RESOURCEIMAGE_PDF_PROGRESS_BAR_BACKGROUND, | 125 { PP_RESOURCEIMAGE_PDF_PROGRESS_BAR_BACKGROUND, |
126 IDR_PDF_PROGRESS_BAR_BACKGROUND }, | 126 IDR_PDF_PROGRESS_BAR_BACKGROUND }, |
127 { PP_RESOURCEIMAGE_PDF_PAGE_INDICATOR_BACKGROUND, | 127 { PP_RESOURCEIMAGE_PDF_PAGE_INDICATOR_BACKGROUND, |
128 IDR_PDF_PAGE_INDICATOR_BACKGROUND }, | 128 IDR_PDF_PAGE_INDICATOR_BACKGROUND }, |
129 { PP_RESOURCEIMAGE_PDF_PAGE_DROPSHADOW, IDR_PDF_PAGE_DROPSHADOW }, | 129 { PP_RESOURCEIMAGE_PDF_PAGE_DROPSHADOW, IDR_PDF_PAGE_DROPSHADOW }, |
130 { PP_RESOURCEIMAGE_PDF_PAN_SCROLL_ICON, IDR_PAN_SCROLL_ICON }, | 130 { PP_RESOURCEIMAGE_PDF_PAN_SCROLL_ICON, IDR_PAN_SCROLL_ICON }, |
131 }; | 131 }; |
132 | 132 |
133 #if defined(ENABLE_FULL_PRINTING) | 133 #if defined(ENABLE_FULL_PRINTING) |
134 | 134 |
135 WebKit::WebElement GetWebElement(PP_Instance instance_id) { | 135 blink::WebElement GetWebElement(PP_Instance instance_id) { |
136 content::PepperPluginInstance* instance = | 136 content::PepperPluginInstance* instance = |
137 content::PepperPluginInstance::Get(instance_id); | 137 content::PepperPluginInstance::Get(instance_id); |
138 if (!instance) | 138 if (!instance) |
139 return WebKit::WebElement(); | 139 return blink::WebElement(); |
140 return instance->GetContainer()->element(); | 140 return instance->GetContainer()->element(); |
141 } | 141 } |
142 | 142 |
143 printing::PrintWebViewHelper* GetPrintWebViewHelper( | 143 printing::PrintWebViewHelper* GetPrintWebViewHelper( |
144 const WebKit::WebElement& element) { | 144 const blink::WebElement& element) { |
145 if (element.isNull()) | 145 if (element.isNull()) |
146 return NULL; | 146 return NULL; |
147 WebKit::WebView* view = element.document().frame()->view(); | 147 blink::WebView* view = element.document().frame()->view(); |
148 content::RenderView* render_view = content::RenderView::FromWebView(view); | 148 content::RenderView* render_view = content::RenderView::FromWebView(view); |
149 return printing::PrintWebViewHelper::Get(render_view); | 149 return printing::PrintWebViewHelper::Get(render_view); |
150 } | 150 } |
151 | 151 |
152 bool IsPrintingEnabled(PP_Instance instance_id) { | 152 bool IsPrintingEnabled(PP_Instance instance_id) { |
153 WebKit::WebElement element = GetWebElement(instance_id); | 153 blink::WebElement element = GetWebElement(instance_id); |
154 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); | 154 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); |
155 return helper && helper->IsPrintingEnabled(); | 155 return helper && helper->IsPrintingEnabled(); |
156 } | 156 } |
157 | 157 |
158 #else // ENABLE_FULL_PRINTING | 158 #else // ENABLE_FULL_PRINTING |
159 | 159 |
160 bool IsPrintingEnabled(PP_Instance instance_id) { | 160 bool IsPrintingEnabled(PP_Instance instance_id) { |
161 return false; | 161 return false; |
162 } | 162 } |
163 | 163 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 } | 341 } |
342 | 342 |
343 void SaveAs(PP_Instance instance_id) { | 343 void SaveAs(PP_Instance instance_id) { |
344 content::PepperPluginInstance* instance = | 344 content::PepperPluginInstance* instance = |
345 content::PepperPluginInstance::Get(instance_id); | 345 content::PepperPluginInstance::Get(instance_id); |
346 if (!instance) | 346 if (!instance) |
347 return; | 347 return; |
348 GURL url = instance->GetPluginURL(); | 348 GURL url = instance->GetPluginURL(); |
349 | 349 |
350 content::RenderView* render_view = instance->GetRenderView(); | 350 content::RenderView* render_view = instance->GetRenderView(); |
351 WebKit::WebFrame* frame = render_view->GetWebView()->mainFrame(); | 351 blink::WebFrame* frame = render_view->GetWebView()->mainFrame(); |
352 content::Referrer referrer(frame->document().url(), | 352 content::Referrer referrer(frame->document().url(), |
353 frame->document().referrerPolicy()); | 353 frame->document().referrerPolicy()); |
354 render_view->Send(new ChromeViewHostMsg_PDFSaveURLAs( | 354 render_view->Send(new ChromeViewHostMsg_PDFSaveURLAs( |
355 render_view->GetRoutingID(), url, referrer)); | 355 render_view->GetRoutingID(), url, referrer)); |
356 } | 356 } |
357 | 357 |
358 PP_Bool IsFeatureEnabled(PP_Instance instance, PP_PDFFeature feature) { | 358 PP_Bool IsFeatureEnabled(PP_Instance instance, PP_PDFFeature feature) { |
359 switch (feature) { | 359 switch (feature) { |
360 case PP_PDFFEATURE_HIDPI: | 360 case PP_PDFFEATURE_HIDPI: |
361 return PP_TRUE; | 361 return PP_TRUE; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 } // namespace | 441 } // namespace |
442 | 442 |
443 // static | 443 // static |
444 const PPB_PDF* PPB_PDF_Impl::GetInterface() { | 444 const PPB_PDF* PPB_PDF_Impl::GetInterface() { |
445 return &ppb_pdf; | 445 return &ppb_pdf; |
446 } | 446 } |
447 | 447 |
448 // static | 448 // static |
449 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { | 449 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { |
450 #if defined(ENABLE_FULL_PRINTING) | 450 #if defined(ENABLE_FULL_PRINTING) |
451 WebKit::WebElement element = GetWebElement(instance_id); | 451 blink::WebElement element = GetWebElement(instance_id); |
452 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); | 452 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); |
453 if (helper) | 453 if (helper) |
454 helper->PrintNode(element); | 454 helper->PrintNode(element); |
455 #endif // ENABLE_FULL_PRINTING | 455 #endif // ENABLE_FULL_PRINTING |
456 } | 456 } |
OLD | NEW |