Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/browser/ui/android/javascript_app_modal_dialog_android.cc

Issue 11728004: Fix use after free in JavascriptAppModalDialogAndroid. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing 'virtual' (only needed by the Chromium style Clang plugin) Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/android/javascript_app_modal_dialog_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/android/javascript_app_modal_dialog_android.h" 5 #include "chrome/browser/ui/android/javascript_app_modal_dialog_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 10
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 JavascriptAppModalDialogAndroid::JavascriptAppModalDialogAndroid( 34 JavascriptAppModalDialogAndroid::JavascriptAppModalDialogAndroid(
35 JNIEnv* env, 35 JNIEnv* env,
36 JavaScriptAppModalDialog* dialog, 36 JavaScriptAppModalDialog* dialog,
37 gfx::NativeWindow parent) 37 gfx::NativeWindow parent)
38 : dialog_(dialog), 38 : dialog_(dialog),
39 parent_jobject_weak_ref_(env, parent->GetJavaObject().obj()) { 39 parent_jobject_weak_ref_(env, parent->GetJavaObject().obj()) {
40 } 40 }
41 41
42 JavascriptAppModalDialogAndroid::~JavascriptAppModalDialogAndroid() {
43 JNIEnv* env = AttachCurrentThread();
44 // In case the dialog is still displaying, tell it to close itself.
45 // This can happen if you trigger a dialog but close the Tab before it's
46 // shown, and then accept the dialog.
47 if (!dialog_jobject_.is_null())
48 Java_JavascriptAppModalDialog_dismiss(env, dialog_jobject_.obj());
49 }
50
51 int JavascriptAppModalDialogAndroid::GetAppModalDialogButtons() const { 42 int JavascriptAppModalDialogAndroid::GetAppModalDialogButtons() const {
52 NOTIMPLEMENTED(); 43 NOTIMPLEMENTED();
53 return 0; 44 return 0;
54 } 45 }
55 46
56 void JavascriptAppModalDialogAndroid::ShowAppModalDialog() { 47 void JavascriptAppModalDialogAndroid::ShowAppModalDialog() {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 49
59 JNIEnv* env = AttachCurrentThread(); 50 JNIEnv* env = AttachCurrentThread();
60 // Keep a strong ref to the parent window while we make the call to java to 51 // Keep a strong ref to the parent window while we make the call to java to
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 JavascriptAppModalDialogAndroid* js_dialog = 147 JavascriptAppModalDialogAndroid* js_dialog =
157 static_cast<JavascriptAppModalDialogAndroid*>(dialog->native_dialog()); 148 static_cast<JavascriptAppModalDialogAndroid*>(dialog->native_dialog());
158 return js_dialog->GetDialogObject().obj(); 149 return js_dialog->GetDialogObject().obj();
159 } 150 }
160 151
161 // static 152 // static
162 bool JavascriptAppModalDialogAndroid::RegisterJavascriptAppModalDialog( 153 bool JavascriptAppModalDialogAndroid::RegisterJavascriptAppModalDialog(
163 JNIEnv* env) { 154 JNIEnv* env) {
164 return RegisterNativesImpl(env); 155 return RegisterNativesImpl(env);
165 } 156 }
157
158 JavascriptAppModalDialogAndroid::~JavascriptAppModalDialogAndroid() {
159 JNIEnv* env = AttachCurrentThread();
160 // In case the dialog is still displaying, tell it to close itself.
161 // This can happen if you trigger a dialog but close the Tab before it's
162 // shown, and then accept the dialog.
163 if (!dialog_jobject_.is_null())
164 Java_JavascriptAppModalDialog_dismiss(env, dialog_jobject_.obj());
165 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/javascript_app_modal_dialog_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698