Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / components / pdf / browser / pdf_web_contents_helper.h
blob7948768e84e707c01b1a218bd0fed6479a584e62
1 // Copyright (c) 2012 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 #ifndef COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_
6 #define COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/web_contents_observer.h"
13 #include "content/public/browser/web_contents_user_data.h"
14 #include "ipc/ipc_message.h"
16 namespace content {
17 class WebContents;
20 namespace pdf {
22 class OpenPDFInReaderPromptClient;
23 class PDFWebContentsHelperClient;
25 // Per-WebContents class to handle PDF messages.
26 class PDFWebContentsHelper
27 : public content::WebContentsObserver,
28 public content::WebContentsUserData<PDFWebContentsHelper> {
29 public:
30 static void CreateForWebContentsWithClient(
31 content::WebContents* contents,
32 scoped_ptr<PDFWebContentsHelperClient> client);
34 OpenPDFInReaderPromptClient* open_in_reader_prompt() const {
35 return open_in_reader_prompt_.get();
38 void ShowOpenInReaderPrompt(scoped_ptr<OpenPDFInReaderPromptClient> prompt);
40 private:
41 PDFWebContentsHelper(content::WebContents* web_contents,
42 scoped_ptr<PDFWebContentsHelperClient> client);
43 virtual ~PDFWebContentsHelper();
45 // content::WebContentsObserver overrides:
46 virtual bool OnMessageReceived(const IPC::Message& message) override;
47 virtual void DidNavigateMainFrame(
48 const content::LoadCommittedDetails& details,
49 const content::FrameNavigateParams& params) override;
51 // Internal helpers ----------------------------------------------------------
53 void UpdateLocationBar();
54 void OnModalPromptForPasswordClosed(IPC::Message* reply_message,
55 bool success,
56 const base::string16& actual_value);
58 // Message handlers.
59 void OnHasUnsupportedFeature();
60 void OnSaveURLAs(const GURL& url, const content::Referrer& referrer);
61 void OnUpdateContentRestrictions(int content_restrictions);
62 void OnModalPromptForPassword(const std::string& prompt,
63 IPC::Message* reply_message);
65 // The model for the confirmation prompt to open a PDF in Adobe Reader.
66 scoped_ptr<OpenPDFInReaderPromptClient> open_in_reader_prompt_;
67 scoped_ptr<PDFWebContentsHelperClient> client_;
69 DISALLOW_COPY_AND_ASSIGN(PDFWebContentsHelper);
72 } // namespace pdf
74 #endif // COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_