Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / pdf / browser / pdf_web_contents_helper.h
blobd37b57f9573fb283384b7959c450af61cdc7a667
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_