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/android/banners/app_banner_manager_android.h" | 5 #include "chrome/browser/android/banners/app_banner_manager_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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 const char kPlayPlatform[] = "play"; | 25 const char kPlayPlatform[] = "play"; |
26 const char kReferrerName[] = "referrer"; | 26 const char kReferrerName[] = "referrer"; |
27 const char kIdName[] = "id"; | 27 const char kIdName[] = "id"; |
28 | 28 |
29 } // anonymous namespace | 29 } // anonymous namespace |
30 | 30 |
31 namespace banners { | 31 namespace banners { |
32 | 32 |
33 AppBannerManagerAndroid::AppBannerManagerAndroid(JNIEnv* env, | 33 AppBannerManagerAndroid::AppBannerManagerAndroid(JNIEnv* env, |
34 jobject obj, | 34 jobject obj, |
| 35 int splash_icon_size, |
35 int icon_size) | 36 int icon_size) |
36 : AppBannerManager(icon_size), | 37 : AppBannerManager(icon_size), |
| 38 ideal_splash_icon_size_(splash_icon_size), |
37 weak_java_banner_view_manager_(env, obj) { | 39 weak_java_banner_view_manager_(env, obj) { |
38 } | 40 } |
39 | 41 |
40 AppBannerManagerAndroid::~AppBannerManagerAndroid() { | 42 AppBannerManagerAndroid::~AppBannerManagerAndroid() { |
41 } | 43 } |
42 | 44 |
43 void AppBannerManagerAndroid::Destroy(JNIEnv* env, jobject obj) { | 45 void AppBannerManagerAndroid::Destroy(JNIEnv* env, jobject obj) { |
44 delete this; | 46 delete this; |
45 } | 47 } |
46 | 48 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (key_str == name) | 129 if (key_str == name) |
128 return value_str; | 130 return value_str; |
129 } | 131 } |
130 return ""; | 132 return ""; |
131 } | 133 } |
132 | 134 |
133 AppBannerDataFetcher* AppBannerManagerAndroid::CreateAppBannerDataFetcher( | 135 AppBannerDataFetcher* AppBannerManagerAndroid::CreateAppBannerDataFetcher( |
134 base::WeakPtr<Delegate> weak_delegate, | 136 base::WeakPtr<Delegate> weak_delegate, |
135 const int ideal_icon_size) { | 137 const int ideal_icon_size) { |
136 return new AppBannerDataFetcherAndroid(web_contents(), weak_delegate, | 138 return new AppBannerDataFetcherAndroid(web_contents(), weak_delegate, |
| 139 ideal_splash_icon_size_, |
137 ideal_icon_size); | 140 ideal_icon_size); |
138 } | 141 } |
139 | 142 |
140 bool AppBannerManagerAndroid::OnAppDetailsRetrieved(JNIEnv* env, | 143 bool AppBannerManagerAndroid::OnAppDetailsRetrieved(JNIEnv* env, |
141 jobject obj, | 144 jobject obj, |
142 jobject japp_data, | 145 jobject japp_data, |
143 jstring japp_title, | 146 jstring japp_title, |
144 jstring japp_package, | 147 jstring japp_package, |
145 jstring jicon_url) { | 148 jstring jicon_url) { |
146 if (!CheckFetcherMatchesContents()) | 149 if (!CheckFetcherMatchesContents()) |
(...skipping 13 matching lines...) Expand all Loading... |
160 | 163 |
161 bool AppBannerManagerAndroid::IsFetcherActive(JNIEnv* env, jobject obj) { | 164 bool AppBannerManagerAndroid::IsFetcherActive(JNIEnv* env, jobject obj) { |
162 return AppBannerManager::IsFetcherActive(); | 165 return AppBannerManager::IsFetcherActive(); |
163 } | 166 } |
164 | 167 |
165 // static | 168 // static |
166 bool AppBannerManagerAndroid::Register(JNIEnv* env) { | 169 bool AppBannerManagerAndroid::Register(JNIEnv* env) { |
167 return RegisterNativesImpl(env); | 170 return RegisterNativesImpl(env); |
168 } | 171 } |
169 | 172 |
170 jlong Init(JNIEnv* env, jobject obj, jint icon_size) { | 173 jlong Init(JNIEnv* env, jobject obj, jint splash_icon_size, jint icon_size) { |
171 AppBannerManagerAndroid* manager = | 174 AppBannerManagerAndroid* manager = |
172 new AppBannerManagerAndroid(env, obj, icon_size); | 175 new AppBannerManagerAndroid(env, obj, splash_icon_size, icon_size); |
173 return reinterpret_cast<intptr_t>(manager); | 176 return reinterpret_cast<intptr_t>(manager); |
174 } | 177 } |
175 | 178 |
176 void SetTimeDeltaForTesting(JNIEnv* env, jclass clazz, jint days) { | 179 void SetTimeDeltaForTesting(JNIEnv* env, jclass clazz, jint days) { |
177 AppBannerDataFetcher::SetTimeDeltaForTesting(days); | 180 AppBannerDataFetcher::SetTimeDeltaForTesting(days); |
178 } | 181 } |
179 | 182 |
180 void DisableSecureSchemeCheckForTesting(JNIEnv* env, jclass clazz) { | 183 void DisableSecureSchemeCheckForTesting(JNIEnv* env, jclass clazz) { |
181 AppBannerManager::DisableSecureSchemeCheckForTesting(); | 184 AppBannerManager::DisableSecureSchemeCheckForTesting(); |
182 } | 185 } |
183 | 186 |
184 void ForceEngagementWeightsForTesting(JNIEnv* env, | 187 void ForceEngagementWeightsForTesting(JNIEnv* env, |
185 jclass clazz, | 188 jclass clazz, |
186 jdouble direct_engagement, | 189 jdouble direct_engagement, |
187 jdouble indirect_engagement) { | 190 jdouble indirect_engagement) { |
188 AppBannerManager::ForceEngagementWeightsForTesting(direct_engagement, | 191 AppBannerManager::ForceEngagementWeightsForTesting(direct_engagement, |
189 indirect_engagement); | 192 indirect_engagement); |
190 } | 193 } |
191 | 194 |
192 jboolean IsEnabled(JNIEnv* env, jclass clazz) { | 195 jboolean IsEnabled(JNIEnv* env, jclass clazz) { |
193 return base::FieldTrialList::FindFullName("AppBanners") == "Enabled"; | 196 return base::FieldTrialList::FindFullName("AppBanners") == "Enabled"; |
194 } | 197 } |
195 | 198 |
196 } // namespace banners | 199 } // namespace banners |
OLD | NEW |