Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / pdf / browser / pdf_web_contents_helper.h
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.
4
5 #ifndef COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_
6 #define COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_
7
8 #include <string>
9
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"
15
16 namespace content {
17 class WebContents;
18 }
19
20 namespace pdf {
21
22 class OpenPDFInReaderPromptClient;
23 class PDFWebContentsHelperClient;
24
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);
33
34   OpenPDFInReaderPromptClient* open_in_reader_prompt() const {
35     return open_in_reader_prompt_.get();
36   }
37
38   void ShowOpenInReaderPrompt(scoped_ptr<OpenPDFInReaderPromptClient> prompt);
39
40  private:
41   PDFWebContentsHelper(content::WebContents* web_contents,
42                        scoped_ptr<PDFWebContentsHelperClient> client);
43   virtual ~PDFWebContentsHelper();
44
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;
50
51   // Internal helpers ----------------------------------------------------------
52
53   void UpdateLocationBar();
54   void OnModalPromptForPasswordClosed(IPC::Message* reply_message,
55                                       bool success,
56                                       const base::string16& actual_value);
57
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);
64
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_;
68
69   DISALLOW_COPY_AND_ASSIGN(PDFWebContentsHelper);
70 };
71
72 }  // namespace pdf
73
74 #endif  // COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_