OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/pepper_pdf_host.h" | 5 #include "chrome/renderer/pepper/pepper_pdf_host.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/common/render_messages.h" | |
9 #include "chrome/renderer/printing/print_web_view_helper.h" | 8 #include "chrome/renderer/printing/print_web_view_helper.h" |
| 9 #include "components/pdf/common/pdf_messages.h" |
10 #include "content/app/resources/grit/content_resources.h" | 10 #include "content/app/resources/grit/content_resources.h" |
11 #include "content/app/strings/grit/content_strings.h" | 11 #include "content/app/strings/grit/content_strings.h" |
12 #include "content/public/common/referrer.h" | 12 #include "content/public/common/referrer.h" |
13 #include "content/public/renderer/pepper_plugin_instance.h" | 13 #include "content/public/renderer/pepper_plugin_instance.h" |
14 #include "content/public/renderer/render_thread.h" | 14 #include "content/public/renderer/render_thread.h" |
15 #include "content/public/renderer/render_view.h" | 15 #include "content/public/renderer/render_view.h" |
16 #include "content/public/renderer/renderer_ppapi_host.h" | 16 #include "content/public/renderer/renderer_ppapi_host.h" |
17 #include "ppapi/host/dispatch_host_message.h" | 17 #include "ppapi/host/dispatch_host_message.h" |
18 #include "ppapi/host/host_message_context.h" | 18 #include "ppapi/host/host_message_context.h" |
19 #include "ppapi/host/ppapi_host.h" | 19 #include "ppapi/host/ppapi_host.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 return PP_OK; | 177 return PP_OK; |
178 } | 178 } |
179 | 179 |
180 int32_t PepperPDFHost::OnHostMsgSetContentRestriction( | 180 int32_t PepperPDFHost::OnHostMsgSetContentRestriction( |
181 ppapi::host::HostMessageContext* context, | 181 ppapi::host::HostMessageContext* context, |
182 int restrictions) { | 182 int restrictions) { |
183 content::PepperPluginInstance* instance = | 183 content::PepperPluginInstance* instance = |
184 host_->GetPluginInstance(pp_instance()); | 184 host_->GetPluginInstance(pp_instance()); |
185 if (!instance) | 185 if (!instance) |
186 return PP_ERROR_FAILED; | 186 return PP_ERROR_FAILED; |
187 instance->GetRenderView()->Send( | 187 instance->GetRenderView()->Send(new PDFHostMsg_PDFUpdateContentRestrictions( |
188 new ChromeViewHostMsg_PDFUpdateContentRestrictions( | 188 instance->GetRenderView()->GetRoutingID(), restrictions)); |
189 instance->GetRenderView()->GetRoutingID(), restrictions)); | |
190 return PP_OK; | 189 return PP_OK; |
191 } | 190 } |
192 | 191 |
193 int32_t PepperPDFHost::OnHostMsgUserMetricsRecordAction( | 192 int32_t PepperPDFHost::OnHostMsgUserMetricsRecordAction( |
194 ppapi::host::HostMessageContext* context, | 193 ppapi::host::HostMessageContext* context, |
195 const std::string& action) { | 194 const std::string& action) { |
196 if (action.empty()) | 195 if (action.empty()) |
197 return PP_ERROR_FAILED; | 196 return PP_ERROR_FAILED; |
198 content::RenderThread::Get()->RecordComputedAction(action); | 197 content::RenderThread::Get()->RecordComputedAction(action); |
199 return PP_OK; | 198 return PP_OK; |
200 } | 199 } |
201 | 200 |
202 int32_t PepperPDFHost::OnHostMsgHasUnsupportedFeature( | 201 int32_t PepperPDFHost::OnHostMsgHasUnsupportedFeature( |
203 ppapi::host::HostMessageContext* context) { | 202 ppapi::host::HostMessageContext* context) { |
204 content::PepperPluginInstance* instance = | 203 content::PepperPluginInstance* instance = |
205 host_->GetPluginInstance(pp_instance()); | 204 host_->GetPluginInstance(pp_instance()); |
206 if (!instance) | 205 if (!instance) |
207 return PP_ERROR_FAILED; | 206 return PP_ERROR_FAILED; |
208 | 207 |
209 blink::WebView* view = | 208 blink::WebView* view = |
210 instance->GetContainer()->element().document().frame()->view(); | 209 instance->GetContainer()->element().document().frame()->view(); |
211 content::RenderView* render_view = content::RenderView::FromWebView(view); | 210 content::RenderView* render_view = content::RenderView::FromWebView(view); |
212 render_view->Send(new ChromeViewHostMsg_PDFHasUnsupportedFeature( | 211 render_view->Send( |
213 render_view->GetRoutingID())); | 212 new PDFHostMsg_PDFHasUnsupportedFeature(render_view->GetRoutingID())); |
214 return PP_OK; | 213 return PP_OK; |
215 } | 214 } |
216 | 215 |
217 int32_t PepperPDFHost::OnHostMsgPrint( | 216 int32_t PepperPDFHost::OnHostMsgPrint( |
218 ppapi::host::HostMessageContext* context) { | 217 ppapi::host::HostMessageContext* context) { |
219 #if defined(ENABLE_FULL_PRINTING) | 218 #if defined(ENABLE_FULL_PRINTING) |
220 content::PepperPluginInstance* instance = | 219 content::PepperPluginInstance* instance = |
221 host_->GetPluginInstance(pp_instance()); | 220 host_->GetPluginInstance(pp_instance()); |
222 if (!instance) | 221 if (!instance) |
223 return PP_ERROR_FAILED; | 222 return PP_ERROR_FAILED; |
(...skipping 17 matching lines...) Expand all Loading... |
241 content::PepperPluginInstance* instance = | 240 content::PepperPluginInstance* instance = |
242 host_->GetPluginInstance(pp_instance()); | 241 host_->GetPluginInstance(pp_instance()); |
243 if (!instance) | 242 if (!instance) |
244 return PP_ERROR_FAILED; | 243 return PP_ERROR_FAILED; |
245 GURL url = instance->GetPluginURL(); | 244 GURL url = instance->GetPluginURL(); |
246 content::RenderView* render_view = instance->GetRenderView(); | 245 content::RenderView* render_view = instance->GetRenderView(); |
247 blink::WebLocalFrame* frame = | 246 blink::WebLocalFrame* frame = |
248 render_view->GetWebView()->mainFrame()->toWebLocalFrame(); | 247 render_view->GetWebView()->mainFrame()->toWebLocalFrame(); |
249 content::Referrer referrer(frame->document().url(), | 248 content::Referrer referrer(frame->document().url(), |
250 frame->document().referrerPolicy()); | 249 frame->document().referrerPolicy()); |
251 render_view->Send(new ChromeViewHostMsg_PDFSaveURLAs( | 250 render_view->Send( |
252 render_view->GetRoutingID(), url, referrer)); | 251 new PDFHostMsg_PDFSaveURLAs(render_view->GetRoutingID(), url, referrer)); |
253 return PP_OK; | 252 return PP_OK; |
254 } | 253 } |
255 | 254 |
256 int32_t PepperPDFHost::OnHostMsgGetResourceImage( | 255 int32_t PepperPDFHost::OnHostMsgGetResourceImage( |
257 ppapi::host::HostMessageContext* context, | 256 ppapi::host::HostMessageContext* context, |
258 PP_ResourceImage image_id, | 257 PP_ResourceImage image_id, |
259 float scale) { | 258 float scale) { |
260 int res_id = 0; | 259 int res_id = 0; |
261 for (size_t i = 0; i < arraysize(kResourceImageMap); ++i) { | 260 for (size_t i = 0; i < arraysize(kResourceImageMap); ++i) { |
262 if (kResourceImageMap[i].pp_id == image_id) { | 261 if (kResourceImageMap[i].pp_id == image_id) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 383 |
385 const SkBitmap* bitmap = &skia::GetTopDevice(*canvas)->accessBitmap(false); | 384 const SkBitmap* bitmap = &skia::GetTopDevice(*canvas)->accessBitmap(false); |
386 pixels_to_write.copyPixelsTo( | 385 pixels_to_write.copyPixelsTo( |
387 bitmap->getPixels(), bitmap->getSize(), bitmap->rowBytes()); | 386 bitmap->getPixels(), bitmap->getSize(), bitmap->rowBytes()); |
388 | 387 |
389 if (needs_unmapping) | 388 if (needs_unmapping) |
390 image_data->Unmap(); | 389 image_data->Unmap(); |
391 | 390 |
392 return true; | 391 return true; |
393 } | 392 } |
OLD | NEW |