Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / chrome / renderer / printing / chrome_print_web_view_helper_delegate.cc
blob131555763cfb3035acbf923f5adc617e2a659968
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.
5 #include "chrome/renderer/printing/chrome_print_web_view_helper_delegate.h"
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"
15 #if defined(ENABLE_EXTENSIONS)
16 #include "chrome/common/extensions/extension_constants.h"
17 #include "extensions/common/constants.h"
18 #endif // defined(ENABLE_EXTENSIONS)
20 ChromePrintWebViewHelperDelegate::~ChromePrintWebViewHelperDelegate(){
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;
29 return render_view->Send(
30 new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id));
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;
46 NOTREACHED();
48 #endif // defined(ENABLE_EXTENSIONS)
49 return blink::WebElement();