| 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 } |
| 30 | 31 |
| 31 bool ChromePrintWebViewHelperDelegate::CancelPrerender( | 32 bool ChromePrintWebViewHelperDelegate::CancelPrerender( |
| 32 content::RenderFrame* render_frame) { | 33 content::RenderView* render_view, int routing_id) { |
| 33 if (!prerender::PrerenderHelper::IsPrerendering(render_frame)) | 34 if (!render_view || !prerender::PrerenderHelper::IsPrerendering( |
| 35 render_view->GetMainRenderFrame())) |
| 34 return false; | 36 return false; |
| 35 | 37 |
| 36 auto* render_view = render_frame->GetRenderView(); | 38 return render_view->Send( |
| 37 return render_view->Send(new ChromeViewHostMsg_CancelPrerenderForPrinting( | 39 new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id)); |
| 38 render_view->GetRoutingID())); | |
| 39 } | 40 } |
| 40 | 41 |
| 41 // Return the PDF object element if |frame| is the out of process PDF extension. | 42 // Return the PDF object element if |frame| is the out of process PDF extension. |
| 42 blink::WebElement ChromePrintWebViewHelperDelegate::GetPdfElement( | 43 blink::WebElement ChromePrintWebViewHelperDelegate::GetPdfElement( |
| 43 blink::WebLocalFrame* frame) { | 44 blink::WebLocalFrame* frame) { |
| 44 #if BUILDFLAG(ENABLE_EXTENSIONS) | 45 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 45 GURL url = frame->document().url(); | 46 GURL url = frame->document().url(); |
| 46 bool inside_print_preview = url.GetOrigin() == chrome::kChromeUIPrintURL; | 47 bool inside_print_preview = url.GetOrigin() == chrome::kChromeUIPrintURL; |
| 47 bool inside_pdf_extension = | 48 bool inside_pdf_extension = |
| 48 url.SchemeIs(extensions::kExtensionScheme) && | 49 url.SchemeIs(extensions::kExtensionScheme) && |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // PDF plugin document correctly print the PDF. See | 81 // PDF plugin document correctly print the PDF. See |
| 81 // https://crbug.com/448720. | 82 // https://crbug.com/448720. |
| 82 base::DictionaryValue message; | 83 base::DictionaryValue message; |
| 83 message.SetString("type", "print"); | 84 message.SetString("type", "print"); |
| 84 mime_handlers.front()->PostMessageFromValue(message); | 85 mime_handlers.front()->PostMessageFromValue(message); |
| 85 return true; | 86 return true; |
| 86 } | 87 } |
| 87 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 88 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 88 return false; | 89 return false; |
| 89 } | 90 } |
| OLD | NEW |