OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/printing/chrome_print_web_view_helper_delegate.h" | 5 #include "chrome/renderer/printing/chrome_print_web_view_helper_delegate.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
14 #include "chrome/renderer/prerender/prerender_helper.h" | 14 #include "chrome/renderer/prerender/prerender_helper.h" |
15 #include "content/public/renderer/render_frame.h" | 15 #include "content/public/renderer/render_frame.h" |
16 #include "content/public/renderer/render_view.h" | 16 #include "content/public/renderer/render_view.h" |
17 #include "extensions/features/features.h" | 17 #include "extensions/features/features.h" |
18 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
19 #include "third_party/WebKit/public/web/WebDocument.h" | 19 #include "third_party/WebKit/public/web/WebDocument.h" |
20 #include "third_party/WebKit/public/web/WebElement.h" | 20 #include "third_party/WebKit/public/web/WebElement.h" |
21 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 21 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
22 | 22 |
23 #if BUILDFLAG(ENABLE_EXTENSIONS) | 23 #if BUILDFLAG(ENABLE_EXTENSIONS) |
24 #include "chrome/common/extensions/extension_constants.h" | 24 #include "chrome/common/extensions/extension_constants.h" |
25 #include "extensions/common/constants.h" | 25 #include "extensions/common/constants.h" |
26 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con
tainer.h" | 26 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con
tainer.h" |
27 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 27 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
28 | 28 |
29 ChromePrintWebViewHelperDelegate::~ChromePrintWebViewHelperDelegate(){ | 29 ChromePrintWebViewHelperDelegate::~ChromePrintWebViewHelperDelegate() {} |
30 } | |
31 | 30 |
32 bool ChromePrintWebViewHelperDelegate::CancelPrerender( | 31 bool ChromePrintWebViewHelperDelegate::CancelPrerender( |
33 content::RenderView* render_view, int routing_id) { | 32 content::RenderFrame* render_frame) { |
34 if (!render_view || !prerender::PrerenderHelper::IsPrerendering( | 33 if (!prerender::PrerenderHelper::IsPrerendering(render_frame)) |
35 render_view->GetMainRenderFrame())) | |
36 return false; | 34 return false; |
37 | 35 |
38 return render_view->Send( | 36 auto* render_view = render_frame->GetRenderView(); |
39 new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id)); | 37 return render_view->Send(new ChromeViewHostMsg_CancelPrerenderForPrinting( |
| 38 render_view->GetRoutingID())); |
40 } | 39 } |
41 | 40 |
42 // Return the PDF object element if |frame| is the out of process PDF extension. | 41 // Return the PDF object element if |frame| is the out of process PDF extension. |
43 blink::WebElement ChromePrintWebViewHelperDelegate::GetPdfElement( | 42 blink::WebElement ChromePrintWebViewHelperDelegate::GetPdfElement( |
44 blink::WebLocalFrame* frame) { | 43 blink::WebLocalFrame* frame) { |
45 #if BUILDFLAG(ENABLE_EXTENSIONS) | 44 #if BUILDFLAG(ENABLE_EXTENSIONS) |
46 GURL url = frame->document().url(); | 45 GURL url = frame->document().url(); |
47 bool inside_print_preview = url.GetOrigin() == chrome::kChromeUIPrintURL; | 46 bool inside_print_preview = url.GetOrigin() == chrome::kChromeUIPrintURL; |
48 bool inside_pdf_extension = | 47 bool inside_pdf_extension = |
49 url.SchemeIs(extensions::kExtensionScheme) && | 48 url.SchemeIs(extensions::kExtensionScheme) && |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // PDF plugin document correctly print the PDF. See | 80 // PDF plugin document correctly print the PDF. See |
82 // https://crbug.com/448720. | 81 // https://crbug.com/448720. |
83 base::DictionaryValue message; | 82 base::DictionaryValue message; |
84 message.SetString("type", "print"); | 83 message.SetString("type", "print"); |
85 mime_handlers.front()->PostMessageFromValue(message); | 84 mime_handlers.front()->PostMessageFromValue(message); |
86 return true; | 85 return true; |
87 } | 86 } |
88 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 87 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
89 return false; | 88 return false; |
90 } | 89 } |
OLD | NEW |