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

Side by Side Diff: chrome/browser/android/banners/app_banner_manager_android.cc

Issue 1310223002: webapps: initial addition of splash screen icon downloading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webapps-database-exp
Patch Set: Fix compile Created 5 years, 3 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/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 13 matching lines...) Expand all
24 24
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 const char kPlayInlineReferrer[] = "playinline=chrome_inline"; 28 const char kPlayInlineReferrer[] = "playinline=chrome_inline";
29 29
30 } // anonymous namespace 30 } // anonymous namespace
31 31
32 namespace banners { 32 namespace banners {
33 33
34 AppBannerManagerAndroid::AppBannerManagerAndroid(JNIEnv* env, 34 AppBannerManagerAndroid::AppBannerManagerAndroid(
35 jobject obj, 35 JNIEnv* env,
36 int icon_size) 36 jobject obj,
37 : AppBannerManager(icon_size), 37 int ideal_splash_image_size_in_dp,
38 int ideal_icon_size_in_dp)
39 : AppBannerManager(ideal_icon_size_in_dp),
40 ideal_splash_image_size_in_dp_(ideal_splash_image_size_in_dp),
38 weak_java_banner_view_manager_(env, obj) { 41 weak_java_banner_view_manager_(env, obj) {
39 } 42 }
40 43
41 AppBannerManagerAndroid::~AppBannerManagerAndroid() { 44 AppBannerManagerAndroid::~AppBannerManagerAndroid() {
42 } 45 }
43 46
44 void AppBannerManagerAndroid::Destroy(JNIEnv* env, jobject obj) { 47 void AppBannerManagerAndroid::Destroy(JNIEnv* env, jobject obj) {
45 delete this; 48 delete this;
46 } 49 }
47 50
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 referrer.append("&").append(kPlayInlineReferrer); 88 referrer.append("&").append(kPlayInlineReferrer);
86 89
87 ScopedJavaLocalRef<jstring> jurl( 90 ScopedJavaLocalRef<jstring> jurl(
88 ConvertUTF8ToJavaString(env, data_fetcher()->validated_url().spec())); 91 ConvertUTF8ToJavaString(env, data_fetcher()->validated_url().spec()));
89 ScopedJavaLocalRef<jstring> jpackage( 92 ScopedJavaLocalRef<jstring> jpackage(
90 ConvertUTF8ToJavaString(env, id)); 93 ConvertUTF8ToJavaString(env, id));
91 ScopedJavaLocalRef<jstring> jreferrer( 94 ScopedJavaLocalRef<jstring> jreferrer(
92 ConvertUTF8ToJavaString(env, referrer)); 95 ConvertUTF8ToJavaString(env, referrer));
93 Java_AppBannerManager_fetchAppDetails(env, jobj.obj(), jurl.obj(), 96 Java_AppBannerManager_fetchAppDetails(env, jobj.obj(), jurl.obj(),
94 jpackage.obj(), jreferrer.obj(), 97 jpackage.obj(), jreferrer.obj(),
95 ideal_icon_size()); 98 ideal_icon_size_in_dp());
96 return true; 99 return true;
97 } 100 }
98 101
99 bool AppBannerManagerAndroid::CheckPlatformAndId(const std::string& platform, 102 bool AppBannerManagerAndroid::CheckPlatformAndId(const std::string& platform,
100 const std::string& id) { 103 const std::string& id) {
101 if (platform != kPlayPlatform) { 104 if (platform != kPlayPlatform) {
102 banners::OutputDeveloperDebugMessage( 105 banners::OutputDeveloperDebugMessage(
103 web_contents(), platform + banners::kIgnoredNotSupportedOnAndroid); 106 web_contents(), platform + banners::kIgnoredNotSupportedOnAndroid);
104 return false; 107 return false;
105 } 108 }
(...skipping 28 matching lines...) Expand all
134 std::string key_str(url_spec, key.begin, key.len); 137 std::string key_str(url_spec, key.begin, key.len);
135 std::string value_str(url_spec, value.begin, value.len); 138 std::string value_str(url_spec, value.begin, value.len);
136 if (key_str == name) 139 if (key_str == name)
137 return value_str; 140 return value_str;
138 } 141 }
139 return ""; 142 return "";
140 } 143 }
141 144
142 AppBannerDataFetcher* AppBannerManagerAndroid::CreateAppBannerDataFetcher( 145 AppBannerDataFetcher* AppBannerManagerAndroid::CreateAppBannerDataFetcher(
143 base::WeakPtr<Delegate> weak_delegate, 146 base::WeakPtr<Delegate> weak_delegate,
144 const int ideal_icon_size) { 147 const int ideal_icon_size_in_dp) {
145 return new AppBannerDataFetcherAndroid(web_contents(), weak_delegate, 148 return new AppBannerDataFetcherAndroid(web_contents(), weak_delegate,
146 ideal_icon_size); 149 ideal_splash_image_size_in_dp_,
150 ideal_icon_size_in_dp);
147 } 151 }
148 152
149 bool AppBannerManagerAndroid::OnAppDetailsRetrieved(JNIEnv* env, 153 bool AppBannerManagerAndroid::OnAppDetailsRetrieved(JNIEnv* env,
150 jobject obj, 154 jobject obj,
151 jobject japp_data, 155 jobject japp_data,
152 jstring japp_title, 156 jstring japp_title,
153 jstring japp_package, 157 jstring japp_package,
154 jstring jicon_url) { 158 jstring jicon_url) {
155 if (!CheckFetcherMatchesContents()) 159 if (!CheckFetcherMatchesContents())
156 return false; 160 return false;
(...skipping 12 matching lines...) Expand all
169 173
170 bool AppBannerManagerAndroid::IsFetcherActive(JNIEnv* env, jobject obj) { 174 bool AppBannerManagerAndroid::IsFetcherActive(JNIEnv* env, jobject obj) {
171 return AppBannerManager::IsFetcherActive(); 175 return AppBannerManager::IsFetcherActive();
172 } 176 }
173 177
174 // static 178 // static
175 bool AppBannerManagerAndroid::Register(JNIEnv* env) { 179 bool AppBannerManagerAndroid::Register(JNIEnv* env) {
176 return RegisterNativesImpl(env); 180 return RegisterNativesImpl(env);
177 } 181 }
178 182
179 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj, jint icon_size) { 183 jlong Init(JNIEnv* env,
184 const JavaParamRef<jobject>& obj,
185 jint ideal_splash_image_size_in_dp,
186 jint ideal_icon_size_in_dp) {
180 AppBannerManagerAndroid* manager = 187 AppBannerManagerAndroid* manager =
181 new AppBannerManagerAndroid(env, obj, icon_size); 188 new AppBannerManagerAndroid(env, obj,
189 ideal_splash_image_size_in_dp, ideal_icon_size_in_dp);
182 return reinterpret_cast<intptr_t>(manager); 190 return reinterpret_cast<intptr_t>(manager);
183 } 191 }
184 192
185 void SetTimeDeltaForTesting(JNIEnv* env, 193 void SetTimeDeltaForTesting(JNIEnv* env,
186 const JavaParamRef<jclass>& clazz, 194 const JavaParamRef<jclass>& clazz,
187 jint days) { 195 jint days) {
188 AppBannerDataFetcher::SetTimeDeltaForTesting(days); 196 AppBannerDataFetcher::SetTimeDeltaForTesting(days);
189 } 197 }
190 198
191 void DisableSecureSchemeCheckForTesting(JNIEnv* env, 199 void DisableSecureSchemeCheckForTesting(JNIEnv* env,
192 const JavaParamRef<jclass>& clazz) { 200 const JavaParamRef<jclass>& clazz) {
193 AppBannerManager::DisableSecureSchemeCheckForTesting(); 201 AppBannerManager::DisableSecureSchemeCheckForTesting();
194 } 202 }
195 203
196 void SetEngagementWeights(JNIEnv* env, 204 void SetEngagementWeights(JNIEnv* env,
197 const JavaParamRef<jclass>& clazz, 205 const JavaParamRef<jclass>& clazz,
198 jdouble direct_engagement, 206 jdouble direct_engagement,
199 jdouble indirect_engagement) { 207 jdouble indirect_engagement) {
200 AppBannerManager::SetEngagementWeights(direct_engagement, 208 AppBannerManager::SetEngagementWeights(direct_engagement,
201 indirect_engagement); 209 indirect_engagement);
202 } 210 }
203 211
204 jboolean IsEnabled(JNIEnv* env, const JavaParamRef<jclass>& clazz) { 212 jboolean IsEnabled(JNIEnv* env, const JavaParamRef<jclass>& clazz) {
205 return base::FieldTrialList::FindFullName("AppBanners") == "Enabled"; 213 return base::FieldTrialList::FindFullName("AppBanners") == "Enabled";
206 } 214 }
207 215
208 } // namespace banners 216 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/android/banners/app_banner_manager_android.h ('k') | chrome/browser/android/shortcut_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698