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

Side by Side Diff: chrome/renderer/printing/chrome_print_web_view_helper_delegate.cc

Issue 791133006: Delegates for the printing component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/printing/chrome_print_web_view_helper_delegate.h"
6
7 #include "base/command_line.h"
8 #include "base/json/json_writer.h"
9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/render_messages.h"
11 #include "chrome/grit/browser_resources.h"
12 #include "chrome/renderer/prerender/prerender_helper.h"
13 #include "content/public/renderer/render_view.h"
14 #include "ipc/ipc_message.h"
15 #include "third_party/WebKit/public/web/WebLocalFrame.h"
16 #include "ui/base/resource/resource_bundle.h"
17
18 #if defined(ENABLE_EXTENSIONS)
19 #include "chrome/common/extensions/extension_constants.h"
20 #include "extensions/common/constants.h"
21 #endif // defined(ENABLE_EXTENSIONS)
22
23 namespace printing {
24
25 ChromePrintWebViewHelperDelegate::ChromePrintWebViewHelperDelegate()
26 : PrintWebViewHelperDelegate() {
27 }
28
29 ChromePrintWebViewHelperDelegate::~ChromePrintWebViewHelperDelegate() {
30 }
31
32 IPC::Message* ChromePrintWebViewHelperDelegate::GetScriptedPrintCancelMessage(
33 content::RenderView* render_view, int routing_id) {
34 if (!prerender::PrerenderHelper::IsPrerendering(
35 render_view->GetMainRenderFrame()))
Vitaly Buka (NO REVIEWS) 2015/01/05 19:57:03 there is content::RenderView::Send please rename G
dgn 2015/01/05 22:45:47 I'm not sure to understand the second part of the
36 return nullptr;
37
38 return new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id);
39 }
40
41 bool ChromePrintWebViewHelperDelegate::OutOfProcessPdfEnabled() {
42 return switches::OutOfProcessPdfEnabled();
Vitaly Buka (NO REVIEWS) 2015/01/05 19:57:03 OutOfProcessPdfEnabled and PrintPreviewDisabled sh
dgn 2015/01/05 22:45:47 Done.
43 }
44
45 // Return the PDF object element if |frame| is the out of process PDF extension.
46 blink::WebElement ChromePrintWebViewHelperDelegate::GetPdfElement(
47 blink::WebLocalFrame* frame) {
48 #if defined(ENABLE_EXTENSIONS)
49 GURL url = frame->document().url();
50 if (url.SchemeIs(extensions::kExtensionScheme) &&
Vitaly Buka (NO REVIEWS) 2015/01/05 19:57:03 seems ChromePrintWebViewHelperDelegate::GetPdfElem
dgn 2015/01/05 22:45:47 Done.
51 url.host() == extension_misc::kPdfExtensionId) {
52 // <object> with id="plugin" is created in
53 // chrome/browser/resources/pdf/pdf.js.
54 auto plugin_element = frame->document().getElementById("plugin");
55 if (!plugin_element.isNull()) {
56 return plugin_element;
57 }
58 NOTREACHED();
59 }
60 #endif // defined(ENABLE_EXTENSIONS)
61 return blink::WebElement();
62 }
63
64 base::StringValue ChromePrintWebViewHelperDelegate::GetPrintPreviewHtml() {
dgn 2014/12/30 17:15:48 Will probably end up with the whole function in th
Vitaly Buka (NO REVIEWS) 2015/01/05 19:57:03 seems ChromePrintWebViewHelperDelegate::GetPrintPr
dgn 2015/01/05 22:45:47 Done.
65 #if defined(ENABLE_PRINT_PREVIEW)
66 return base::StringValue(
67 ResourceBundle::GetSharedInstance().GetLocalizedString(
68 IDR_PRINT_PREVIEW_PAGE));
69 #endif
70 return base::StringValue("");
71 }
72
73 bool ChromePrintWebViewHelperDelegate::PrintPreviewDisabled() {
74 return CommandLine::ForCurrentProcess()->HasSwitch(
75 switches::kDisablePrintPreview);
76 }
77
78 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698