Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / guest_view / web_view / javascript_dialog_helper.h
1 // Copyright 2014 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 CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_JAVASCRIPT_DIALOG_HELPER_H_
6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_JAVASCRIPT_DIALOG_HELPER_H_
7
8 #include "content/public/browser/javascript_dialog_manager.h"
9
10 namespace extensions {
11
12 class WebViewGuest;
13
14 class JavaScriptDialogHelper : public content::JavaScriptDialogManager {
15  public:
16   explicit JavaScriptDialogHelper(WebViewGuest* guest);
17   virtual ~JavaScriptDialogHelper();
18
19   // JavaScriptDialogManager implementation.
20   virtual void RunJavaScriptDialog(
21       content::WebContents* web_contents,
22       const GURL& origin_url,
23       const std::string& accept_lang,
24       content::JavaScriptMessageType javascript_message_type,
25       const base::string16& message_text,
26       const base::string16& default_prompt_text,
27       const DialogClosedCallback& callback,
28       bool* did_suppress_message) OVERRIDE;
29   virtual void RunBeforeUnloadDialog(
30       content::WebContents* web_contents,
31       const base::string16& message_text,
32       bool is_reload,
33       const DialogClosedCallback& callback) OVERRIDE;
34   virtual bool HandleJavaScriptDialog(
35       content::WebContents* web_contents,
36       bool accept,
37       const base::string16* prompt_override) OVERRIDE;
38   virtual void CancelActiveAndPendingDialogs(
39       content::WebContents* web_contents) OVERRIDE;
40   virtual void WebContentsDestroyed(
41       content::WebContents* web_contents) OVERRIDE;
42
43  private:
44   void OnPermissionResponse(
45       const DialogClosedCallback& callback,
46       bool allow,
47       const std::string& user_input);
48
49   // Pointer to the webview that is being helped.
50   WebViewGuest* const web_view_guest_;
51
52   DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogHelper);
53 };
54
55 }  // namespace extensions
56
57 #endif  // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_JAVASCRIPT_DIALOG_HELPER_H_