OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_ | 5 #ifndef COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_ |
6 #define COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_ | 6 #define COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
14 #include "content/public/browser/web_contents_user_data.h" | 14 #include "content/public/browser/web_contents_user_data.h" |
15 #include "ipc/ipc_message.h" | 15 #include "ipc/ipc_message.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class WebContents; | 18 class WebContents; |
19 } | 19 } |
20 | 20 |
21 namespace pdf { | 21 namespace pdf { |
22 | 22 |
23 class OpenPDFInReaderPromptClient; | 23 class OpenPDFInReaderPromptClient; |
24 class PDFWebContentsHelperClient; | 24 class PDFWebContentsHelperClient; |
25 | 25 |
26 // Per-WebContents class to handle PDF messages. | 26 // Per-WebContents class to handle PDF messages. |
27 class PDFWebContentsHelper | 27 class PDFWebContentsHelper |
28 : public content::WebContentsObserver, | 28 : public content::WebContentsObserver, |
29 public content::WebContentsUserData<PDFWebContentsHelper> { | 29 public content::WebContentsUserData<PDFWebContentsHelper> { |
30 public: | 30 public: |
31 static void CreateForWebContentsWithClient( | 31 static void CreateForWebContentsWithClient( |
32 content::WebContents* contents, | 32 content::WebContents* contents, |
33 scoped_ptr<PDFWebContentsHelperClient> client); | 33 std::unique_ptr<PDFWebContentsHelperClient> client); |
34 | 34 |
35 OpenPDFInReaderPromptClient* open_in_reader_prompt() const { | 35 OpenPDFInReaderPromptClient* open_in_reader_prompt() const { |
36 return open_in_reader_prompt_.get(); | 36 return open_in_reader_prompt_.get(); |
37 } | 37 } |
38 | 38 |
39 void ShowOpenInReaderPrompt(scoped_ptr<OpenPDFInReaderPromptClient> prompt); | 39 void ShowOpenInReaderPrompt( |
| 40 std::unique_ptr<OpenPDFInReaderPromptClient> prompt); |
40 | 41 |
41 private: | 42 private: |
42 PDFWebContentsHelper(content::WebContents* web_contents, | 43 PDFWebContentsHelper(content::WebContents* web_contents, |
43 scoped_ptr<PDFWebContentsHelperClient> client); | 44 std::unique_ptr<PDFWebContentsHelperClient> client); |
44 ~PDFWebContentsHelper() override; | 45 ~PDFWebContentsHelper() override; |
45 | 46 |
46 // content::WebContentsObserver overrides: | 47 // content::WebContentsObserver overrides: |
47 bool OnMessageReceived(const IPC::Message& message) override; | 48 bool OnMessageReceived(const IPC::Message& message) override; |
48 void DidNavigateMainFrame( | 49 void DidNavigateMainFrame( |
49 const content::LoadCommittedDetails& details, | 50 const content::LoadCommittedDetails& details, |
50 const content::FrameNavigateParams& params) override; | 51 const content::FrameNavigateParams& params) override; |
51 | 52 |
52 // Internal helpers ---------------------------------------------------------- | 53 // Internal helpers ---------------------------------------------------------- |
53 | 54 |
54 void UpdateLocationBar(); | 55 void UpdateLocationBar(); |
55 | 56 |
56 // Message handlers. | 57 // Message handlers. |
57 void OnHasUnsupportedFeature(); | 58 void OnHasUnsupportedFeature(); |
58 void OnSaveURLAs(const GURL& url, const content::Referrer& referrer); | 59 void OnSaveURLAs(const GURL& url, const content::Referrer& referrer); |
59 void OnUpdateContentRestrictions(int content_restrictions); | 60 void OnUpdateContentRestrictions(int content_restrictions); |
60 | 61 |
61 // The model for the confirmation prompt to open a PDF in Adobe Reader. | 62 // The model for the confirmation prompt to open a PDF in Adobe Reader. |
62 scoped_ptr<OpenPDFInReaderPromptClient> open_in_reader_prompt_; | 63 std::unique_ptr<OpenPDFInReaderPromptClient> open_in_reader_prompt_; |
63 scoped_ptr<PDFWebContentsHelperClient> client_; | 64 std::unique_ptr<PDFWebContentsHelperClient> client_; |
64 | 65 |
65 DISALLOW_COPY_AND_ASSIGN(PDFWebContentsHelper); | 66 DISALLOW_COPY_AND_ASSIGN(PDFWebContentsHelper); |
66 }; | 67 }; |
67 | 68 |
68 } // namespace pdf | 69 } // namespace pdf |
69 | 70 |
70 #endif // COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_ | 71 #endif // COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_ |
OLD | NEW |