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 CHROME_BROWSER_UI_ANDROID_JAVASCRIPT_APP_MODAL_DIALOG_ANDROID_H_
6 #define CHROME_BROWSER_UI_ANDROID_JAVASCRIPT_APP_MODAL_DIALOG_ANDROID_H_
8 #include "base/android/jni_weak_ref.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "components/app_modal/native_app_modal_dialog.h"
13 class JavaScriptAppModalDialog
;
15 class JavascriptAppModalDialogAndroid
16 : public app_modal::NativeAppModalDialog
{
18 JavascriptAppModalDialogAndroid(
20 app_modal::JavaScriptAppModalDialog
* dialog
,
21 gfx::NativeWindow parent
);
23 // NativeAppModalDialog:
24 int GetAppModalDialogButtons() const override
;
25 void ShowAppModalDialog() override
;
26 void ActivateAppModalDialog() override
;
27 void CloseAppModalDialog() override
;
28 void AcceptAppModalDialog() override
;
29 void CancelAppModalDialog() override
;
30 bool IsShowing() const override
;
32 // Called when java confirms or cancels the dialog.
33 void DidAcceptAppModalDialog(JNIEnv
* env
,
36 bool suppress_js_dialogs
);
37 void DidCancelAppModalDialog(JNIEnv
* env
, jobject
, bool suppress_js_dialogs
);
39 const base::android::ScopedJavaGlobalRef
<jobject
>& GetDialogObject() const;
41 static bool RegisterJavascriptAppModalDialog(JNIEnv
* env
);
44 // The object deletes itself.
45 ~JavascriptAppModalDialogAndroid() override
;
47 scoped_ptr
<app_modal::JavaScriptAppModalDialog
> dialog_
;
48 base::android::ScopedJavaGlobalRef
<jobject
> dialog_jobject_
;
49 JavaObjectWeakGlobalRef parent_jobject_weak_ref_
;
51 DISALLOW_COPY_AND_ASSIGN(JavascriptAppModalDialogAndroid
);
55 #endif // CHROME_BROWSER_UI_ANDROID_JAVASCRIPT_APP_MODAL_DIALOG_ANDROID_H_