Move Webstore URL concepts to //extensions and out
[chromium-blink-merge.git] / chrome / browser / ui / pdf / chrome_pdf_web_contents_helper_client.cc
blobdc5c1dcf4c9c98be6f4d0772951ceace8a4f2058
1 // Copyright 2014 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/browser/ui/pdf/chrome_pdf_web_contents_helper_client.h"
7 #include "chrome/browser/download/download_stats.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/browser/ui/location_bar/location_bar.h"
12 #include "chrome/browser/ui/pdf/pdf_unsupported_feature.h"
13 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
15 ChromePDFWebContentsHelperClient::ChromePDFWebContentsHelperClient() {
18 ChromePDFWebContentsHelperClient::~ChromePDFWebContentsHelperClient() {
21 void ChromePDFWebContentsHelperClient::UpdateLocationBar(
22 content::WebContents* contents) {
23 Browser* browser = chrome::FindBrowserWithWebContents(contents);
24 if (!browser)
25 return;
27 BrowserWindow* window = browser->window();
28 if (!window)
29 return;
31 LocationBar* location_bar = window->GetLocationBar();
32 if (!location_bar)
33 return;
35 location_bar->UpdateOpenPDFInReaderPrompt();
38 void ChromePDFWebContentsHelperClient::UpdateContentRestrictions(
39 content::WebContents* contents,
40 int content_restrictions) {
41 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents);
42 // |core_tab_helper| is NULL for WebViewGuest.
43 if (core_tab_helper)
44 core_tab_helper->UpdateContentRestrictions(content_restrictions);
47 void ChromePDFWebContentsHelperClient::OnPDFHasUnsupportedFeature(
48 content::WebContents* contents) {
49 PDFHasUnsupportedFeature(contents);
52 void ChromePDFWebContentsHelperClient::OnSaveURL(
53 content::WebContents* contents) {
54 RecordDownloadSource(DOWNLOAD_INITIATED_BY_PDF_SAVE);
57 void ChromePDFWebContentsHelperClient::OnShowPDFPasswordDialog(
58 content::WebContents* contents,
59 const base::string16& prompt,
60 const pdf::PasswordDialogClosedCallback& callback) {
61 ShowPDFPasswordDialog(contents, prompt, callback);