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" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 return render_view->Send( | 37 return render_view->Send( |
38 new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id)); | 38 new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id)); |
39 } | 39 } |
40 | 40 |
41 // 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. |
42 blink::WebElement ChromePrintWebViewHelperDelegate::GetPdfElement( | 42 blink::WebElement ChromePrintWebViewHelperDelegate::GetPdfElement( |
43 blink::WebLocalFrame* frame) { | 43 blink::WebLocalFrame* frame) { |
44 #if defined(ENABLE_EXTENSIONS) | 44 #if defined(ENABLE_EXTENSIONS) |
45 GURL url = frame->document().url(); | 45 GURL url = frame->document().url(); |
46 bool inside_print_preview = | 46 bool inside_print_preview = url.GetOrigin() == chrome::kChromeUIPrintURL; |
47 url.GetOrigin() == GURL(chrome::kChromeUIPrintURL); | |
48 bool inside_pdf_extension = url.SchemeIs(extensions::kExtensionScheme) && | 47 bool inside_pdf_extension = url.SchemeIs(extensions::kExtensionScheme) && |
49 url.host() == extension_misc::kPdfExtensionId; | 48 url.host() == extension_misc::kPdfExtensionId; |
50 if (inside_print_preview || inside_pdf_extension) { | 49 if (inside_print_preview || inside_pdf_extension) { |
51 // <object> with id="plugin" is created in | 50 // <object> with id="plugin" is created in |
52 // chrome/browser/resources/pdf/pdf.js. | 51 // chrome/browser/resources/pdf/pdf.js. |
53 auto plugin_element = frame->document().getElementById("plugin"); | 52 auto plugin_element = frame->document().getElementById("plugin"); |
54 if (!plugin_element.isNull()) { | 53 if (!plugin_element.isNull()) { |
55 return plugin_element; | 54 return plugin_element; |
56 } | 55 } |
57 NOTREACHED(); | 56 NOTREACHED(); |
(...skipping 22 matching lines...) Expand all Loading... |
80 // PDF plugin document correctly print the PDF. See | 79 // PDF plugin document correctly print the PDF. See |
81 // https://crbug.com/448720. | 80 // https://crbug.com/448720. |
82 base::DictionaryValue message; | 81 base::DictionaryValue message; |
83 message.SetString("type", "print"); | 82 message.SetString("type", "print"); |
84 mime_handlers.front()->PostMessageFromValue(message); | 83 mime_handlers.front()->PostMessageFromValue(message); |
85 return true; | 84 return true; |
86 } | 85 } |
87 #endif // defined(ENABLE_EXTENSIONS) | 86 #endif // defined(ENABLE_EXTENSIONS) |
88 return false; | 87 return false; |
89 } | 88 } |
OLD | NEW |