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

Side by Side Diff: chrome/renderer/plugins/pdf_plugin_placeholder.cc

Issue 2972123002: Click to Open PDF: Open PDF once View PDF is clicked. (Closed)
Patch Set: . Created 3 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
« no previous file with comments | « chrome/common/render_messages.h ('k') | chrome/renderer/resources/plugins/pdf_plugin.html » ('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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/plugins/pdf_plugin_placeholder.h" 5 #include "chrome/renderer/plugins/pdf_plugin_placeholder.h"
6 6
7 #include "chrome/common/render_messages.h"
7 #include "chrome/grit/renderer_resources.h" 8 #include "chrome/grit/renderer_resources.h"
9 #include "content/public/renderer/render_thread.h"
8 #include "gin/object_template_builder.h" 10 #include "gin/object_template_builder.h"
9 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/base/webui/jstemplate_builder.h" 12 #include "ui/base/webui/jstemplate_builder.h"
11 13
12 gin::WrapperInfo PDFPluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin}; 14 gin::WrapperInfo PDFPluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin};
13 15
14 PDFPluginPlaceholder::PDFPluginPlaceholder(content::RenderFrame* render_frame, 16 PDFPluginPlaceholder::PDFPluginPlaceholder(content::RenderFrame* render_frame,
15 const blink::WebPluginParams& params, 17 const blink::WebPluginParams& params,
16 const std::string& html_data) 18 const std::string& html_data)
17 : plugins::PluginPlaceholderBase(render_frame, params, html_data) {} 19 : plugins::PluginPlaceholderBase(render_frame, params, html_data) {}
18 20
19 PDFPluginPlaceholder::~PDFPluginPlaceholder() {} 21 PDFPluginPlaceholder::~PDFPluginPlaceholder() {}
20 22
21 PDFPluginPlaceholder* PDFPluginPlaceholder::CreatePDFPlaceholder( 23 PDFPluginPlaceholder* PDFPluginPlaceholder::CreatePDFPlaceholder(
22 content::RenderFrame* render_frame, 24 content::RenderFrame* render_frame,
23 const blink::WebPluginParams& params) { 25 const blink::WebPluginParams& params) {
24 const base::StringPiece template_html( 26 const base::StringPiece template_html(
25 ResourceBundle::GetSharedInstance().GetRawDataResource( 27 ResourceBundle::GetSharedInstance().GetRawDataResource(
26 IDR_PDF_PLUGIN_HTML)); 28 IDR_PDF_PLUGIN_HTML));
27 base::DictionaryValue values; 29 base::DictionaryValue values;
30 GURL url = params.url;
Lei Zhang 2017/07/07 21:08:20 Can this be written as: values.SetString("fileNam
amberwon 2017/07/07 21:23:09 Yes, it can. Done.
31 values.SetString("fileName", url.ExtractFileName());
28 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); 32 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values);
29 return new PDFPluginPlaceholder(render_frame, params, html_data); 33 return new PDFPluginPlaceholder(render_frame, params, html_data);
30 } 34 }
31 35
32 v8::Local<v8::Value> PDFPluginPlaceholder::GetV8Handle(v8::Isolate* isolate) { 36 v8::Local<v8::Value> PDFPluginPlaceholder::GetV8Handle(v8::Isolate* isolate) {
33 return gin::CreateHandle(isolate, this).ToV8(); 37 return gin::CreateHandle(isolate, this).ToV8();
34 } 38 }
35 39
36 gin::ObjectTemplateBuilder PDFPluginPlaceholder::GetObjectTemplateBuilder( 40 gin::ObjectTemplateBuilder PDFPluginPlaceholder::GetObjectTemplateBuilder(
37 v8::Isolate* isolate) { 41 v8::Isolate* isolate) {
38 return gin::Wrappable<PDFPluginPlaceholder>::GetObjectTemplateBuilder(isolate) 42 return gin::Wrappable<PDFPluginPlaceholder>::GetObjectTemplateBuilder(isolate)
39 .SetMethod<void (PDFPluginPlaceholder::*)()>( 43 .SetMethod<void (PDFPluginPlaceholder::*)()>(
40 "downloadPDF", &PDFPluginPlaceholder::DownloadPDFCallback); 44 "downloadPDF", &PDFPluginPlaceholder::DownloadPDFCallback);
41 } 45 }
42 46
43 void PDFPluginPlaceholder::DownloadPDFCallback() { 47 void PDFPluginPlaceholder::DownloadPDFCallback() {
44 // TODO(amberwon): Implement starting PDF download. 48 content::RenderThread::Get()->Send(
49 new ChromeViewHostMsg_DownloadPDF(routing_id(), GetPluginParams().url));
45 } 50 }
OLDNEW
« no previous file with comments | « chrome/common/render_messages.h ('k') | chrome/renderer/resources/plugins/pdf_plugin.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698