| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shortcut_helper.h" | 5 #include "chrome/browser/android/shortcut_helper.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 GetHomescreenIconAndSplashImageSizes(); | 121 GetHomescreenIconAndSplashImageSizes(); |
| 122 return kMinimumSplashImageSize; | 122 return kMinimumSplashImageSize; |
| 123 } | 123 } |
| 124 | 124 |
| 125 // static | 125 // static |
| 126 void ShortcutHelper::FetchSplashScreenImage( | 126 void ShortcutHelper::FetchSplashScreenImage( |
| 127 content::WebContents* web_contents, | 127 content::WebContents* web_contents, |
| 128 const GURL& image_url, | 128 const GURL& image_url, |
| 129 const int ideal_splash_image_size_in_dp, | 129 const int ideal_splash_image_size_in_dp, |
| 130 const int minimum_splash_image_size_in_dp, | 130 const int minimum_splash_image_size_in_dp, |
| 131 const std::string& webapp_id) { | 131 const std::string& webapp_id, |
| 132 const std::string& webapp_scope) { |
| 132 // This is a fire and forget task. It is not vital for the splash screen image | 133 // This is a fire and forget task. It is not vital for the splash screen image |
| 133 // to be downloaded so if the downloader returns false there is no fallback. | 134 // to be downloaded so if the downloader returns false there is no fallback. |
| 134 ManifestIconDownloader::Download( | 135 ManifestIconDownloader::Download( |
| 135 web_contents, | 136 web_contents, image_url, ideal_splash_image_size_in_dp, |
| 136 image_url, | |
| 137 ideal_splash_image_size_in_dp, | |
| 138 minimum_splash_image_size_in_dp, | 137 minimum_splash_image_size_in_dp, |
| 139 base::Bind(&ShortcutHelper::StoreWebappData, webapp_id)); | 138 base::Bind(&ShortcutHelper::StoreWebappData, webapp_id, webapp_scope)); |
| 140 } | 139 } |
| 141 | 140 |
| 142 // static | 141 // static |
| 143 void ShortcutHelper::StoreWebappData( | 142 void ShortcutHelper::StoreWebappData( |
| 144 const std::string& webapp_id, | 143 const std::string& webapp_id, |
| 144 const std::string& webapp_url, |
| 145 const SkBitmap& splash_image) { | 145 const SkBitmap& splash_image) { |
| 146 if (splash_image.drawsNothing()) | 146 if (splash_image.drawsNothing()) |
| 147 return; | 147 return; |
| 148 | 148 |
| 149 JNIEnv* env = base::android::AttachCurrentThread(); | 149 JNIEnv* env = base::android::AttachCurrentThread(); |
| 150 ScopedJavaLocalRef<jstring> java_webapp_id = | 150 ScopedJavaLocalRef<jstring> java_webapp_id = |
| 151 base::android::ConvertUTF8ToJavaString(env, webapp_id); | 151 base::android::ConvertUTF8ToJavaString(env, webapp_id); |
| 152 ScopedJavaLocalRef<jstring> java_webapp_url = |
| 153 base::android::ConvertUTF8ToJavaString(env, webapp_url); |
| 152 ScopedJavaLocalRef<jobject> java_splash_image = | 154 ScopedJavaLocalRef<jobject> java_splash_image = |
| 153 gfx::ConvertToJavaBitmap(&splash_image); | 155 gfx::ConvertToJavaBitmap(&splash_image); |
| 154 | 156 |
| 155 Java_ShortcutHelper_storeWebappData( | 157 Java_ShortcutHelper_storeWebappData( |
| 156 env, | 158 env, |
| 157 base::android::GetApplicationContext(), | 159 base::android::GetApplicationContext(), |
| 158 java_webapp_id.obj(), | 160 java_webapp_id.obj(), |
| 161 java_webapp_url.obj(), |
| 159 java_splash_image.obj()); | 162 java_splash_image.obj()); |
| 160 } | 163 } |
| 161 | 164 |
| 162 // static | 165 // static |
| 163 SkBitmap ShortcutHelper::FinalizeLauncherIcon(const SkBitmap& bitmap, | 166 SkBitmap ShortcutHelper::FinalizeLauncherIcon(const SkBitmap& bitmap, |
| 164 const GURL& url, | 167 const GURL& url, |
| 165 bool* is_generated) { | 168 bool* is_generated) { |
| 166 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 169 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 167 | 170 |
| 168 JNIEnv* env = base::android::AttachCurrentThread(); | 171 JNIEnv* env = base::android::AttachCurrentThread(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 195 SkColorGetR(mean_color), SkColorGetG(mean_color), | 198 SkColorGetR(mean_color), SkColorGetG(mean_color), |
| 196 SkColorGetB(mean_color)); | 199 SkColorGetB(mean_color)); |
| 197 } | 200 } |
| 198 | 201 |
| 199 return gfx::CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(result.obj())); | 202 return gfx::CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(result.obj())); |
| 200 } | 203 } |
| 201 | 204 |
| 202 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { | 205 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { |
| 203 return RegisterNativesImpl(env); | 206 return RegisterNativesImpl(env); |
| 204 } | 207 } |
| OLD | NEW |