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

Side by Side Diff: chrome/browser/ui/android/infobars/download_overwrite_infobar.cc

Issue 1150193004: Straighten up life cycle of native InfoBar pointers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unrelated file Created 5 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/infobars/download_overwrite_infobar.h" 5 #include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/jni_weak_ref.h" 10 #include "base/android/jni_weak_ref.h"
(...skipping 22 matching lines...) Expand all
33 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate(); 33 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate();
34 34
35 ScopedJavaLocalRef<jstring> j_file_name = 35 ScopedJavaLocalRef<jstring> j_file_name =
36 base::android::ConvertUTF8ToJavaString(env, delegate->GetFileName()); 36 base::android::ConvertUTF8ToJavaString(env, delegate->GetFileName());
37 ScopedJavaLocalRef<jstring> j_dir_name = 37 ScopedJavaLocalRef<jstring> j_dir_name =
38 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirName()); 38 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirName());
39 ScopedJavaLocalRef<jstring> j_dir_full_path = 39 ScopedJavaLocalRef<jstring> j_dir_full_path =
40 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirFullPath()); 40 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirFullPath());
41 base::android::ScopedJavaLocalRef<jobject> java_infobar( 41 base::android::ScopedJavaLocalRef<jobject> java_infobar(
42 Java_DownloadOverwriteInfoBar_createInfoBar( 42 Java_DownloadOverwriteInfoBar_createInfoBar(
43 env, reinterpret_cast<intptr_t>(this), j_file_name.obj(), 43 env, j_file_name.obj(), j_dir_name.obj(), j_dir_full_path.obj()));
44 j_dir_name.obj(), j_dir_full_path.obj()));
45 return java_infobar; 44 return java_infobar;
46 } 45 }
47 46
48 void DownloadOverwriteInfoBar::ProcessButton(int action, 47 void DownloadOverwriteInfoBar::ProcessButton(int action,
49 const std::string& action_value) { 48 const std::string& action_value) {
50 if (!owner()) 49 if (!owner())
51 return; // We're closing; don't call anything, it might access the owner. 50 return; // We're closing; don't call anything, it might access the owner.
52 51
53 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate(); 52 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate();
54 if (action == InfoBarAndroid::ACTION_OVERWRITE) 53 if (action == InfoBarAndroid::ACTION_OVERWRITE)
55 delegate->OverwriteExistingFile(); 54 delegate->OverwriteExistingFile();
56 else if (action == InfoBarAndroid::ACTION_CREATE_NEW_FILE) 55 else if (action == InfoBarAndroid::ACTION_CREATE_NEW_FILE)
57 delegate->CreateNewFile(); 56 delegate->CreateNewFile();
58 else 57 else
59 DCHECK(false); 58 DCHECK(false);
60 59
61 RemoveSelf(); 60 RemoveSelf();
62 } 61 }
63 62
64 DownloadOverwriteInfoBarDelegate* DownloadOverwriteInfoBar::GetDelegate() { 63 DownloadOverwriteInfoBarDelegate* DownloadOverwriteInfoBar::GetDelegate() {
65 return static_cast<DownloadOverwriteInfoBarDelegate*>(delegate()); 64 return static_cast<DownloadOverwriteInfoBarDelegate*>(delegate());
66 } 65 }
67 66
68 // Native JNI methods --------------------------------------------------------- 67 // Native JNI methods ---------------------------------------------------------
69 68
70 bool RegisterDownloadOverwriteInfoBarDelegate(JNIEnv* env) { 69 bool RegisterDownloadOverwriteInfoBarDelegate(JNIEnv* env) {
71 return RegisterNativesImpl(env); 70 return RegisterNativesImpl(env);
72 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698