| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 { PP_RESOURCEIMAGE_PDF_PROGRESS_BAR_7, IDR_PDF_PROGRESS_BAR_7 }, | 123 { PP_RESOURCEIMAGE_PDF_PROGRESS_BAR_7, IDR_PDF_PROGRESS_BAR_7 }, |
| 124 { PP_RESOURCEIMAGE_PDF_PROGRESS_BAR_8, IDR_PDF_PROGRESS_BAR_8 }, | 124 { PP_RESOURCEIMAGE_PDF_PROGRESS_BAR_8, IDR_PDF_PROGRESS_BAR_8 }, |
| 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_PRINTING) | 133 #if defined(ENABLE_FULL_PRINTING) |
| 134 | 134 |
| 135 WebKit::WebElement GetWebElement(PP_Instance instance_id) { | 135 WebKit::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 WebKit::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 WebKit::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 WebKit::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 WebKit::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_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 |
| 164 #endif // ENABLE_PRINTING | 164 #endif // ENABLE_FULL_PRINTING |
| 165 | 165 |
| 166 | 166 |
| 167 | 167 |
| 168 PP_Var GetLocalizedString(PP_Instance instance_id, | 168 PP_Var GetLocalizedString(PP_Instance instance_id, |
| 169 PP_ResourceString string_id) { | 169 PP_ResourceString string_id) { |
| 170 content::PepperPluginInstance* instance = | 170 content::PepperPluginInstance* instance = |
| 171 content::PepperPluginInstance::Get(instance_id); | 171 content::PepperPluginInstance::Get(instance_id); |
| 172 if (!instance) | 172 if (!instance) |
| 173 return PP_MakeUndefined(); | 173 return PP_MakeUndefined(); |
| 174 | 174 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 418 |
| 419 } // namespace | 419 } // namespace |
| 420 | 420 |
| 421 // static | 421 // static |
| 422 const PPB_PDF* PPB_PDF_Impl::GetInterface() { | 422 const PPB_PDF* PPB_PDF_Impl::GetInterface() { |
| 423 return &ppb_pdf; | 423 return &ppb_pdf; |
| 424 } | 424 } |
| 425 | 425 |
| 426 // static | 426 // static |
| 427 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { | 427 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { |
| 428 #if defined(ENABLE_PRINTING) | 428 #if defined(ENABLE_FULL_PRINTING) |
| 429 WebKit::WebElement element = GetWebElement(instance_id); | 429 WebKit::WebElement element = GetWebElement(instance_id); |
| 430 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); | 430 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); |
| 431 if (helper) | 431 if (helper) |
| 432 helper->PrintNode(element); | 432 helper->PrintNode(element); |
| 433 #endif // ENABLE_PRINTING | 433 #endif // ENABLE_FULL_PRINTING |
| 434 } | 434 } |
| OLD | NEW |