Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/grit/renderer_resources.h" | 7 #include "chrome/grit/renderer_resources.h" |
| 8 #include "gin/object_template_builder.h" | |
| 8 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 9 #include "ui/base/webui/jstemplate_builder.h" | 10 #include "ui/base/webui/jstemplate_builder.h" |
| 10 | 11 |
| 11 gin::WrapperInfo PDFPluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin}; | 12 gin::WrapperInfo PDFPluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin}; |
| 12 | 13 |
| 13 PDFPluginPlaceholder::PDFPluginPlaceholder(content::RenderFrame* render_frame, | 14 PDFPluginPlaceholder::PDFPluginPlaceholder(content::RenderFrame* render_frame, |
| 14 const blink::WebPluginParams& params, | 15 const blink::WebPluginParams& params, |
| 15 const std::string& html_data) | 16 const std::string& html_data) |
| 16 : plugins::PluginPlaceholderBase(render_frame, params, html_data) {} | 17 : plugins::PluginPlaceholderBase(render_frame, params, html_data) {} |
| 17 | 18 |
| 18 PDFPluginPlaceholder::~PDFPluginPlaceholder() {} | 19 PDFPluginPlaceholder::~PDFPluginPlaceholder() {} |
| 19 | 20 |
| 20 PDFPluginPlaceholder* PDFPluginPlaceholder::CreatePDFPlaceholder( | 21 PDFPluginPlaceholder* PDFPluginPlaceholder::CreatePDFPlaceholder( |
| 21 content::RenderFrame* render_frame, | 22 content::RenderFrame* render_frame, |
| 22 const blink::WebPluginParams& params) { | 23 const blink::WebPluginParams& params) { |
| 23 const base::StringPiece template_html( | 24 const base::StringPiece template_html( |
| 24 ResourceBundle::GetSharedInstance().GetRawDataResource( | 25 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 25 IDR_PDF_PLUGIN_HTML)); | 26 IDR_PDF_PLUGIN_HTML)); |
| 26 base::DictionaryValue values; | 27 base::DictionaryValue values; |
| 27 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); | 28 std::string html_data = webui::GetI18nTemplateHtml(template_html, &values); |
| 28 return new PDFPluginPlaceholder(render_frame, params, html_data); | 29 return new PDFPluginPlaceholder(render_frame, params, html_data); |
| 29 } | 30 } |
| 30 | 31 |
| 31 v8::Local<v8::Value> PDFPluginPlaceholder::GetV8Handle(v8::Isolate* isolate) { | 32 v8::Local<v8::Value> PDFPluginPlaceholder::GetV8Handle(v8::Isolate* isolate) { |
| 32 return gin::CreateHandle(isolate, this).ToV8(); | 33 return gin::CreateHandle(isolate, this).ToV8(); |
| 33 } | 34 } |
| 35 | |
| 36 gin::ObjectTemplateBuilder PDFPluginPlaceholder::GetObjectTemplateBuilder( | |
| 37 v8::Isolate* isolate) { | |
| 38 gin::ObjectTemplateBuilder builder = | |
| 39 gin::Wrappable<PDFPluginPlaceholder>::GetObjectTemplateBuilder(isolate) | |
| 40 .SetMethod<void (PDFPluginPlaceholder::*)()>( | |
| 41 "downloadPDF", &PDFPluginPlaceholder::DownloadPDFCallback); | |
| 42 | |
| 43 return builder; | |
|
tommycli
2017/07/05 19:46:23
I think you can just return it directly like here:
amberwon
2017/07/05 19:54:02
Done.
| |
| 44 } | |
| 45 | |
| 46 void PDFPluginPlaceholder::DownloadPDFCallback() { | |
| 47 // TODO(amberwon): Download PDF. | |
|
tommycli
2017/07/05 19:46:23
TODO(amberwon): Implement starting PDF download.
amberwon
2017/07/05 19:54:02
Done.
| |
| 48 } | |
| OLD | NEW |