OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/renderer/printing/chrome_print_web_view_helper_delegate.h" |
| 6 |
| 7 #include "chrome/common/render_messages.h" |
| 8 #include "chrome/renderer/prerender/prerender_helper.h" |
| 9 #include "content/public/renderer/render_view.h" |
| 10 #include "ipc/ipc_message.h" |
| 11 #include "third_party/WebKit/public/web/WebDocument.h" |
| 12 #include "third_party/WebKit/public/web/WebElement.h" |
| 13 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 14 |
| 15 #if defined(ENABLE_EXTENSIONS) |
| 16 #include "chrome/common/extensions/extension_constants.h" |
| 17 #include "extensions/common/constants.h" |
| 18 #endif // defined(ENABLE_EXTENSIONS) |
| 19 |
| 20 ChromePrintWebViewHelperDelegate::~ChromePrintWebViewHelperDelegate(){ |
| 21 } |
| 22 |
| 23 bool ChromePrintWebViewHelperDelegate::CancelPrerender( |
| 24 content::RenderView* render_view, int routing_id) { |
| 25 if (!render_view || !prerender::PrerenderHelper::IsPrerendering( |
| 26 render_view->GetMainRenderFrame())) |
| 27 return false; |
| 28 |
| 29 return render_view->Send( |
| 30 new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id)); |
| 31 } |
| 32 |
| 33 // Return the PDF object element if |frame| is the out of process PDF extension. |
| 34 blink::WebElement ChromePrintWebViewHelperDelegate::GetPdfElement( |
| 35 blink::WebLocalFrame* frame) { |
| 36 #if defined(ENABLE_EXTENSIONS) |
| 37 GURL url = frame->document().url(); |
| 38 if (url.SchemeIs(extensions::kExtensionScheme) && |
| 39 url.host() == extension_misc::kPdfExtensionId) { |
| 40 // <object> with id="plugin" is created in |
| 41 // chrome/browser/resources/pdf/pdf.js. |
| 42 auto plugin_element = frame->document().getElementById("plugin"); |
| 43 if (!plugin_element.isNull()) { |
| 44 return plugin_element; |
| 45 } |
| 46 NOTREACHED(); |
| 47 } |
| 48 #endif // defined(ENABLE_EXTENSIONS) |
| 49 return blink::WebElement(); |
| 50 } |
OLD | NEW |