summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/android/javascript_app_modal_dialog_android.h
blob: 955c9dedcd1fa86da267c6995d4909cf23ba3245 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_ANDROID_JAVASCRIPT_APP_MODAL_DIALOG_ANDROID_H_
#define CHROME_BROWSER_UI_ANDROID_JAVASCRIPT_APP_MODAL_DIALOG_ANDROID_H_

#include "base/android/jni_helper.h"
#include "base/android/scoped_java_ref.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"

class JavaScriptAppModalDialog;

class JavascriptAppModalDialogAndroid : public NativeAppModalDialog {
 public:
  JavascriptAppModalDialogAndroid(JNIEnv* env,
                                  JavaScriptAppModalDialog* dialog,
                                  gfx::NativeWindow parent);
  virtual ~JavascriptAppModalDialogAndroid();

  // NativeAppModalDialog:
  virtual int GetAppModalDialogButtons() const OVERRIDE;
  virtual void ShowAppModalDialog() OVERRIDE;
  virtual void ActivateAppModalDialog() OVERRIDE;
  virtual void CloseAppModalDialog() OVERRIDE;
  virtual void AcceptAppModalDialog() OVERRIDE;
  virtual void CancelAppModalDialog() OVERRIDE;

  // Called when java confirms or cancels the dialog.
  void DidAcceptAppModalDialog(JNIEnv* env,
                               jobject obj,
                               jstring prompt_text,
                               bool suppress_js_dialogs);
  void DidCancelAppModalDialog(JNIEnv* env, jobject, bool suppress_js_dialogs);

  static bool RegisterJavascriptAppModalDialog(JNIEnv* env);

 private:
  scoped_ptr<JavaScriptAppModalDialog> dialog_;
  base::android::ScopedJavaGlobalRef<jobject> dialog_jobject_;
  JavaObjectWeakGlobalRef parent_jobject_weak_ref_;

  DISALLOW_COPY_AND_ASSIGN(JavascriptAppModalDialogAndroid);
};


#endif  // CHROME_BROWSER_UI_ANDROID_JAVASCRIPT_APP_MODAL_DIALOG_ANDROID_H_