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_
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"
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
> {
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
);
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
,
56 const base::string16
& actual_value
);
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
);
74 #endif // COMPONENTS_PDF_BROWSER_PDF_WEB_CONTENTS_HELPER_H_