| 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 <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.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; | |
| 24 class PDFWebContentsHelperClient; | 23 class PDFWebContentsHelperClient; |
| 25 | 24 |
| 26 // Per-WebContents class to handle PDF messages. | 25 // Per-WebContents class to handle PDF messages. |
| 27 class PDFWebContentsHelper | 26 class PDFWebContentsHelper |
| 28 : public content::WebContentsObserver, | 27 : public content::WebContentsObserver, |
| 29 public content::WebContentsUserData<PDFWebContentsHelper> { | 28 public content::WebContentsUserData<PDFWebContentsHelper> { |
| 30 public: | 29 public: |
| 31 static void CreateForWebContentsWithClient( | 30 static void CreateForWebContentsWithClient( |
| 32 content::WebContents* contents, | 31 content::WebContents* contents, |
| 33 std::unique_ptr<PDFWebContentsHelperClient> client); | 32 std::unique_ptr<PDFWebContentsHelperClient> client); |
| 34 | 33 |
| 35 OpenPDFInReaderPromptClient* open_in_reader_prompt() const { | |
| 36 return open_in_reader_prompt_.get(); | |
| 37 } | |
| 38 | |
| 39 void ShowOpenInReaderPrompt( | |
| 40 std::unique_ptr<OpenPDFInReaderPromptClient> prompt); | |
| 41 | |
| 42 private: | 34 private: |
| 43 PDFWebContentsHelper(content::WebContents* web_contents, | 35 PDFWebContentsHelper(content::WebContents* web_contents, |
| 44 std::unique_ptr<PDFWebContentsHelperClient> client); | 36 std::unique_ptr<PDFWebContentsHelperClient> client); |
| 45 ~PDFWebContentsHelper() override; | 37 ~PDFWebContentsHelper() override; |
| 46 | 38 |
| 47 // content::WebContentsObserver overrides: | 39 // content::WebContentsObserver overrides: |
| 48 bool OnMessageReceived(const IPC::Message& message, | 40 bool OnMessageReceived(const IPC::Message& message, |
| 49 content::RenderFrameHost* render_frame_host) override; | 41 content::RenderFrameHost* render_frame_host) override; |
| 50 void DidNavigateMainFrame( | |
| 51 const content::LoadCommittedDetails& details, | |
| 52 const content::FrameNavigateParams& params) override; | |
| 53 | |
| 54 // Internal helpers ---------------------------------------------------------- | |
| 55 | |
| 56 void UpdateLocationBar(); | |
| 57 | 42 |
| 58 // Message handlers. | 43 // Message handlers. |
| 59 void OnHasUnsupportedFeature(); | 44 void OnHasUnsupportedFeature(); |
| 60 void OnSaveURLAs(const GURL& url, const content::Referrer& referrer); | 45 void OnSaveURLAs(const GURL& url, const content::Referrer& referrer); |
| 61 void OnUpdateContentRestrictions(int content_restrictions); | 46 void OnUpdateContentRestrictions(int content_restrictions); |
| 62 | 47 |
| 63 // The model for the confirmation prompt to open a PDF in Adobe Reader. | |
| 64 std::unique_ptr<OpenPDFInReaderPromptClient> open_in_reader_prompt_; | |
| 65 std::unique_ptr<PDFWebContentsHelperClient> client_; | 48 std::unique_ptr<PDFWebContentsHelperClient> client_; |
| 66 | 49 |
| 67 DISALLOW_COPY_AND_ASSIGN(PDFWebContentsHelper); | 50 DISALLOW_COPY_AND_ASSIGN(PDFWebContentsHelper); |
| 68 }; | 51 }; |
| 69 | 52 |
| 70 } // namespace pdf | 53 } // namespace pdf |
| 71 | 54 |
| 72 #endif // COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_ | 55 #endif // COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_ |
| OLD | NEW |