OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 base::android::ScopedJavaLocalRef<jobject> java_bitmap; | 39 base::android::ScopedJavaLocalRef<jobject> java_bitmap; |
40 if (!app_banner_infobar_delegate->GetIcon().IsEmpty()) { | 40 if (!app_banner_infobar_delegate->GetIcon().IsEmpty()) { |
41 java_bitmap = gfx::ConvertToJavaBitmap( | 41 java_bitmap = gfx::ConvertToJavaBitmap( |
42 app_banner_infobar_delegate->GetIcon().ToSkBitmap()); | 42 app_banner_infobar_delegate->GetIcon().ToSkBitmap()); |
43 } | 43 } |
44 | 44 |
45 base::android::ScopedJavaLocalRef<jobject> infobar; | 45 base::android::ScopedJavaLocalRef<jobject> infobar; |
46 if (!japp_data_.is_null()) { | 46 if (!japp_data_.is_null()) { |
47 infobar.Reset(Java_AppBannerInfoBarAndroid_createNativeAppInfoBar( | 47 infobar.Reset(Java_AppBannerInfoBarAndroid_createNativeAppInfoBar( |
48 env, | 48 env, app_title, java_bitmap, japp_data_)); |
49 app_title.obj(), | |
50 java_bitmap.obj(), | |
51 japp_data_.obj())); | |
52 } else { | 49 } else { |
53 // Trim down the app URL to the domain and registry. | 50 // Trim down the app URL to the domain and registry. |
54 std::string trimmed_url = | 51 std::string trimmed_url = |
55 net::registry_controlled_domains::GetDomainAndRegistry( | 52 net::registry_controlled_domains::GetDomainAndRegistry( |
56 app_url_, | 53 app_url_, |
57 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | 54 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
58 | 55 |
59 base::android::ScopedJavaLocalRef<jstring> app_url = | 56 base::android::ScopedJavaLocalRef<jstring> app_url = |
60 base::android::ConvertUTF8ToJavaString(env, trimmed_url); | 57 base::android::ConvertUTF8ToJavaString(env, trimmed_url); |
61 | 58 |
62 infobar.Reset(Java_AppBannerInfoBarAndroid_createWebAppInfoBar( | 59 infobar.Reset(Java_AppBannerInfoBarAndroid_createWebAppInfoBar( |
63 env, | 60 env, app_title, java_bitmap, app_url)); |
64 app_title.obj(), | |
65 java_bitmap.obj(), | |
66 app_url.obj())); | |
67 } | 61 } |
68 | 62 |
69 java_infobar_.Reset(env, infobar.obj()); | 63 java_infobar_.Reset(env, infobar.obj()); |
70 return infobar; | 64 return infobar; |
71 } | 65 } |
72 | 66 |
73 void AppBannerInfoBarAndroid::OnInstallStateChanged(int new_state) { | 67 void AppBannerInfoBarAndroid::OnInstallStateChanged(int new_state) { |
74 JNIEnv* env = base::android::AttachCurrentThread(); | 68 JNIEnv* env = base::android::AttachCurrentThread(); |
75 Java_AppBannerInfoBarAndroid_onInstallStateChanged(env, java_infobar_.obj(), | 69 Java_AppBannerInfoBarAndroid_onInstallStateChanged(env, java_infobar_, |
76 new_state); | 70 new_state); |
77 } | 71 } |
78 | 72 |
OLD | NEW |