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 "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
18 #include "third_party/WebKit/public/web/WebDocument.h" | 18 #include "third_party/WebKit/public/web/WebDocument.h" |
19 #include "third_party/WebKit/public/web/WebElement.h" | 19 #include "third_party/WebKit/public/web/WebElement.h" |
20 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 20 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
21 | 21 |
22 #if defined(ENABLE_EXTENSIONS) | 22 #if defined(ENABLE_EXTENSIONS) |
23 #include "chrome/common/extensions/extension_constants.h" | 23 #include "chrome/common/extensions/extension_constants.h" |
24 #include "extensions/common/constants.h" | 24 #include "extensions/common/constants.h" |
25 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con tainer.h" | 25 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con tainer.h" |
26 #endif // defined(ENABLE_EXTENSIONS) | 26 #endif // defined(ENABLE_EXTENSIONS) |
27 | 27 |
28 ChromePrintWebViewHelperDelegate::~ChromePrintWebViewHelperDelegate(){ | 28 ChromePrintWebViewHelperDelegate::~ChromePrintWebViewHelperDelegate() {} |
29 } | |
30 | 29 |
31 bool ChromePrintWebViewHelperDelegate::CancelPrerender( | 30 bool ChromePrintWebViewHelperDelegate::CancelPrerender( |
32 content::RenderView* render_view, int routing_id) { | 31 content::RenderFrame* render_frame) { |
33 if (!render_view || !prerender::PrerenderHelper::IsPrerendering( | 32 if (!prerender::PrerenderHelper::IsPrerendering(render_frame)) |
34 render_view->GetMainRenderFrame())) | |
35 return false; | 33 return false; |
36 | 34 |
37 return render_view->Send( | 35 auto* render_view = render_frame->GetRenderView(); |
38 new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id)); | 36 return render_view->Send(new ChromeViewHostMsg_CancelPrerenderForPrinting( |
37 render_view->GetRoutingID())); | |
nasko
2016/11/02 04:50:37
Why is this still using the RenderView routing id?
Lei Zhang
2016/11/08 11:13:22
PrerenderContents hasn't changed in this CL, so we
nasko
2016/11/08 22:18:35
Acknowledged.
| |
39 } | 38 } |
40 | 39 |
41 // Return the PDF object element if |frame| is the out of process PDF extension. | 40 // Return the PDF object element if |frame| is the out of process PDF extension. |
42 blink::WebElement ChromePrintWebViewHelperDelegate::GetPdfElement( | 41 blink::WebElement ChromePrintWebViewHelperDelegate::GetPdfElement( |
43 blink::WebLocalFrame* frame) { | 42 blink::WebLocalFrame* frame) { |
44 #if defined(ENABLE_EXTENSIONS) | 43 #if defined(ENABLE_EXTENSIONS) |
45 GURL url = frame->document().url(); | 44 GURL url = frame->document().url(); |
46 bool inside_print_preview = url.GetOrigin() == chrome::kChromeUIPrintURL; | 45 bool inside_print_preview = url.GetOrigin() == chrome::kChromeUIPrintURL; |
47 bool inside_pdf_extension = url.SchemeIs(extensions::kExtensionScheme) && | 46 bool inside_pdf_extension = url.SchemeIs(extensions::kExtensionScheme) && |
48 url.host() == extension_misc::kPdfExtensionId; | 47 url.host() == extension_misc::kPdfExtensionId; |
(...skipping 30 matching lines...) Expand all Loading... | |
79 // PDF plugin document correctly print the PDF. See | 78 // PDF plugin document correctly print the PDF. See |
80 // https://crbug.com/448720. | 79 // https://crbug.com/448720. |
81 base::DictionaryValue message; | 80 base::DictionaryValue message; |
82 message.SetString("type", "print"); | 81 message.SetString("type", "print"); |
83 mime_handlers.front()->PostMessageFromValue(message); | 82 mime_handlers.front()->PostMessageFromValue(message); |
84 return true; | 83 return true; |
85 } | 84 } |
86 #endif // defined(ENABLE_EXTENSIONS) | 85 #endif // defined(ENABLE_EXTENSIONS) |
87 return false; | 86 return false; |
88 } | 87 } |
OLD | NEW |