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

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

Issue 19800005: Hide knowledge of webkit::ppapi::PluginDelegate from chrome. This is part of moving ppapi implement… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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
« no previous file with comments | « chrome/renderer/pepper/pepper_pdf_host.cc ('k') | content/browser/download/download_stats.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/render_messages.h" 13 #include "chrome/common/render_messages.h"
14 #include "chrome/renderer/printing/print_web_view_helper.h" 14 #include "chrome/renderer/printing/print_web_view_helper.h"
15 #include "content/public/common/child_process_sandbox_support_linux.h" 15 #include "content/public/common/child_process_sandbox_support_linux.h"
16 #include "content/public/common/content_client.h" 16 #include "content/public/common/content_client.h"
17 #include "content/public/common/referrer.h"
17 #include "content/public/renderer/render_thread.h" 18 #include "content/public/renderer/render_thread.h"
18 #include "content/public/renderer/render_view.h" 19 #include "content/public/renderer/render_view.h"
19 #include "grit/webkit_resources.h" 20 #include "grit/webkit_resources.h"
20 #include "grit/webkit_strings.h" 21 #include "grit/webkit_strings.h"
21 #include "ppapi/c/pp_resource.h" 22 #include "ppapi/c/pp_resource.h"
22 #include "ppapi/c/private/ppb_pdf.h" 23 #include "ppapi/c/private/ppb_pdf.h"
23 #include "ppapi/shared_impl/resource.h" 24 #include "ppapi/shared_impl/resource.h"
24 #include "ppapi/shared_impl/resource_tracker.h" 25 #include "ppapi/shared_impl/resource_tracker.h"
25 #include "ppapi/shared_impl/var.h" 26 #include "ppapi/shared_impl/var.h"
26 #include "skia/ext/platform_canvas.h" 27 #include "skia/ext/platform_canvas.h"
27 #include "third_party/skia/include/core/SkBitmap.h" 28 #include "third_party/skia/include/core/SkBitmap.h"
28 #include "third_party/WebKit/public/web/WebDocument.h" 29 #include "third_party/WebKit/public/web/WebDocument.h"
29 #include "third_party/WebKit/public/web/WebElement.h" 30 #include "third_party/WebKit/public/web/WebElement.h"
30 #include "third_party/WebKit/public/web/WebFrame.h" 31 #include "third_party/WebKit/public/web/WebFrame.h"
31 #include "third_party/WebKit/public/web/WebPluginContainer.h" 32 #include "third_party/WebKit/public/web/WebPluginContainer.h"
33 #include "third_party/WebKit/public/web/WebView.h"
32 #include "third_party/icu/source/i18n/unicode/usearch.h" 34 #include "third_party/icu/source/i18n/unicode/usearch.h"
33 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/layout.h" 36 #include "ui/base/layout.h"
35 #include "ui/base/resource/resource_bundle.h" 37 #include "ui/base/resource/resource_bundle.h"
36 #include "ui/gfx/image/image_skia.h" 38 #include "ui/gfx/image/image_skia.h"
37 #include "ui/gfx/image/image_skia_rep.h" 39 #include "ui/gfx/image/image_skia_rep.h"
38 #include "webkit/plugins/ppapi/host_globals.h" 40 #include "webkit/plugins/ppapi/host_globals.h"
39 #include "webkit/plugins/ppapi/plugin_delegate.h"
40 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 41 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
41 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 42 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
42 43
43 using ppapi::PpapiGlobals; 44 using ppapi::PpapiGlobals;
44 using webkit::ppapi::HostGlobals; 45 using webkit::ppapi::HostGlobals;
45 using webkit::ppapi::PluginInstance; 46 using webkit::ppapi::PluginInstance;
46 using WebKit::WebElement; 47 using WebKit::WebElement;
47 using WebKit::WebView; 48 using WebKit::WebView;
48 using content::RenderThread; 49 using content::RenderThread;
49 50
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 290 }
290 291
291 usearch_close(searcher); 292 usearch_close(searcher);
292 } 293 }
293 294
294 void DidStartLoading(PP_Instance instance_id) { 295 void DidStartLoading(PP_Instance instance_id) {
295 PluginInstance* instance = 296 PluginInstance* instance =
296 content::GetHostGlobals()->GetInstance(instance_id); 297 content::GetHostGlobals()->GetInstance(instance_id);
297 if (!instance) 298 if (!instance)
298 return; 299 return;
299 instance->delegate()->DidStartLoading(); 300 instance->render_view()->DidStartLoading();
300 } 301 }
301 302
302 void DidStopLoading(PP_Instance instance_id) { 303 void DidStopLoading(PP_Instance instance_id) {
303 PluginInstance* instance = 304 PluginInstance* instance =
304 content::GetHostGlobals()->GetInstance(instance_id); 305 content::GetHostGlobals()->GetInstance(instance_id);
305 if (!instance) 306 if (!instance)
306 return; 307 return;
307 instance->delegate()->DidStopLoading(); 308 instance->render_view()->DidStopLoading();
308 } 309 }
309 310
310 void SetContentRestriction(PP_Instance instance_id, int restrictions) { 311 void SetContentRestriction(PP_Instance instance_id, int restrictions) {
311 PluginInstance* instance = 312 PluginInstance* instance =
312 content::GetHostGlobals()->GetInstance(instance_id); 313 content::GetHostGlobals()->GetInstance(instance_id);
313 if (!instance) 314 if (!instance)
314 return; 315 return;
315 instance->delegate()->SetContentRestriction(restrictions); 316 instance->render_view()->Send(
317 new ChromeViewHostMsg_PDFUpdateContentRestrictions(
318 instance->render_view()->GetRoutingID(), restrictions));
316 } 319 }
317 320
318 void HistogramPDFPageCount(PP_Instance /*instance*/, int count) { 321 void HistogramPDFPageCount(PP_Instance /*instance*/, int count) {
319 UMA_HISTOGRAM_COUNTS_10000("PDF.PageCount", count); 322 UMA_HISTOGRAM_COUNTS_10000("PDF.PageCount", count);
320 } 323 }
321 324
322 void UserMetricsRecordAction(PP_Instance /*instance*/, PP_Var action) { 325 void UserMetricsRecordAction(PP_Instance /*instance*/, PP_Var action) {
323 scoped_refptr<ppapi::StringVar> action_str( 326 scoped_refptr<ppapi::StringVar> action_str(
324 ppapi::StringVar::FromPPVar(action)); 327 ppapi::StringVar::FromPPVar(action));
325 if (action_str.get()) 328 if (action_str.get())
(...skipping 14 matching lines...) Expand all
340 content::RenderView* render_view = content::RenderView::FromWebView(view); 343 content::RenderView* render_view = content::RenderView::FromWebView(view);
341 render_view->Send(new ChromeViewHostMsg_PDFHasUnsupportedFeature( 344 render_view->Send(new ChromeViewHostMsg_PDFHasUnsupportedFeature(
342 render_view->GetRoutingID())); 345 render_view->GetRoutingID()));
343 } 346 }
344 347
345 void SaveAs(PP_Instance instance_id) { 348 void SaveAs(PP_Instance instance_id) {
346 PluginInstance* instance = 349 PluginInstance* instance =
347 content::GetHostGlobals()->GetInstance(instance_id); 350 content::GetHostGlobals()->GetInstance(instance_id);
348 if (!instance) 351 if (!instance)
349 return; 352 return;
350 instance->delegate()->SaveURLAs(instance->plugin_url()); 353 GURL url = instance->plugin_url();
354
355 content::RenderView* render_view = instance->render_view();
356 WebKit::WebFrame* frame = render_view->GetWebView()->mainFrame();
357 content::Referrer referrer(frame->document().url(),
scottmg 2013/07/23 00:34:16 i don't know anything about the lifetimes here, is
jam 2013/07/23 00:42:03 this is code I moved from PepperPluginDelegateImpl
358 frame->document().referrerPolicy());
359 render_view->Send(new ChromeViewHostMsg_PDFSaveURLAs(
360 render_view->GetRoutingID(), url, referrer));
351 } 361 }
352 362
353 PP_Bool IsFeatureEnabled(PP_Instance instance, PP_PDFFeature feature) { 363 PP_Bool IsFeatureEnabled(PP_Instance instance, PP_PDFFeature feature) {
354 switch (feature) { 364 switch (feature) {
355 case PP_PDFFEATURE_HIDPI: 365 case PP_PDFFEATURE_HIDPI:
356 return PP_TRUE; 366 return PP_TRUE;
357 case PP_PDFFEATURE_PRINTING: 367 case PP_PDFFEATURE_PRINTING:
358 return IsPrintingEnabled(instance) ? PP_TRUE : PP_FALSE; 368 return IsPrintingEnabled(instance) ? PP_TRUE : PP_FALSE;
359 } 369 }
360 return PP_FALSE; 370 return PP_FALSE;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 457
448 // static 458 // static
449 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { 459 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) {
450 #if defined(ENABLE_PRINTING) 460 #if defined(ENABLE_PRINTING)
451 WebKit::WebElement element = GetWebElement(instance_id); 461 WebKit::WebElement element = GetWebElement(instance_id);
452 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); 462 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element);
453 if (helper) 463 if (helper)
454 helper->PrintNode(element); 464 helper->PrintNode(element);
455 #endif // ENABLE_PRINTING 465 #endif // ENABLE_PRINTING
456 } 466 }
OLDNEW
« no previous file with comments | « chrome/renderer/pepper/pepper_pdf_host.cc ('k') | content/browser/download/download_stats.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698