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

Side by Side Diff: chrome/browser/ui/android/infobars/app_banner_infobar_android.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/app_banner_infobar_android.h" 5 #include "chrome/browser/ui/android/infobars/app_banner_infobar_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/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" 10 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 base::android::ScopedJavaLocalRef<jobject> java_bitmap; 42 base::android::ScopedJavaLocalRef<jobject> java_bitmap;
43 if (!app_banner_infobar_delegate->GetIcon().IsEmpty()) { 43 if (!app_banner_infobar_delegate->GetIcon().IsEmpty()) {
44 java_bitmap = gfx::ConvertToJavaBitmap( 44 java_bitmap = gfx::ConvertToJavaBitmap(
45 app_banner_infobar_delegate->GetIcon().ToSkBitmap()); 45 app_banner_infobar_delegate->GetIcon().ToSkBitmap());
46 } 46 }
47 47
48 base::android::ScopedJavaLocalRef<jobject> infobar; 48 base::android::ScopedJavaLocalRef<jobject> infobar;
49 if (!japp_data_.is_null()) { 49 if (!japp_data_.is_null()) {
50 infobar.Reset(Java_AppBannerInfoBarAndroid_createNativeAppInfoBar( 50 infobar.Reset(Java_AppBannerInfoBarAndroid_createNativeAppInfoBar(
51 env, 51 env,
52 reinterpret_cast<intptr_t>(this),
53 app_title.obj(), 52 app_title.obj(),
54 java_bitmap.obj(), 53 java_bitmap.obj(),
55 japp_data_.obj())); 54 japp_data_.obj()));
56 } else { 55 } else {
57 // Trim down the app URL to the domain and registry. 56 // Trim down the app URL to the domain and registry.
58 std::string trimmed_url = 57 std::string trimmed_url =
59 net::registry_controlled_domains::GetDomainAndRegistry( 58 net::registry_controlled_domains::GetDomainAndRegistry(
60 app_url_, 59 app_url_,
61 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 60 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
62 61
63 base::android::ScopedJavaLocalRef<jstring> app_url = 62 base::android::ScopedJavaLocalRef<jstring> app_url =
64 base::android::ConvertUTF8ToJavaString(env, trimmed_url); 63 base::android::ConvertUTF8ToJavaString(env, trimmed_url);
65 64
66 infobar.Reset(Java_AppBannerInfoBarAndroid_createWebAppInfoBar( 65 infobar.Reset(Java_AppBannerInfoBarAndroid_createWebAppInfoBar(
67 env, 66 env,
68 reinterpret_cast<intptr_t>(this),
69 app_title.obj(), 67 app_title.obj(),
70 java_bitmap.obj(), 68 java_bitmap.obj(),
71 app_url.obj())); 69 app_url.obj()));
72 } 70 }
73 71
74 java_infobar_.Reset(env, infobar.obj()); 72 java_infobar_.Reset(env, infobar.obj());
75 return infobar; 73 return infobar;
76 } 74 }
77 75
78 void AppBannerInfoBarAndroid::OnInstallStateChanged(int new_state) { 76 void AppBannerInfoBarAndroid::OnInstallStateChanged(int new_state) {
79 JNIEnv* env = base::android::AttachCurrentThread(); 77 JNIEnv* env = base::android::AttachCurrentThread();
80 Java_AppBannerInfoBarAndroid_onInstallStateChanged(env, java_infobar_.obj(), 78 Java_AppBannerInfoBarAndroid_onInstallStateChanged(env, java_infobar_.obj(),
81 new_state); 79 new_state);
82 } 80 }
83 81
84 // Native JNI methods --------------------------------------------------------- 82 // Native JNI methods ---------------------------------------------------------
85 83
86 bool RegisterAppBannerInfoBarAndroid(JNIEnv* env) { 84 bool RegisterAppBannerInfoBarAndroid(JNIEnv* env) {
87 return RegisterNativesImpl(env); 85 return RegisterNativesImpl(env);
88 } 86 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/infobars/account_chooser_infobar.cc ('k') | chrome/browser/ui/android/infobars/confirm_infobar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698