| 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/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 ScopedJavaLocalRef<jstring> java_user_title = | 139 ScopedJavaLocalRef<jstring> java_user_title = |
| 140 base::android::ConvertUTF16ToJavaString(env, info.user_title); | 140 base::android::ConvertUTF16ToJavaString(env, info.user_title); |
| 141 ScopedJavaLocalRef<jobject> java_bitmap; | 141 ScopedJavaLocalRef<jobject> java_bitmap; |
| 142 if (icon_bitmap.getSize()) | 142 if (icon_bitmap.getSize()) |
| 143 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); | 143 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); |
| 144 | 144 |
| 145 Java_ShortcutHelper_addShortcut(env, java_url, java_user_title, java_bitmap, | 145 Java_ShortcutHelper_addShortcut(env, java_url, java_user_title, java_bitmap, |
| 146 info.source); | 146 info.source); |
| 147 } | 147 } |
| 148 | 148 |
| 149 int ShortcutHelper::GetIdealHomescreenIconSizeInDp() { | 149 int ShortcutHelper::GetIdealHomescreenIconSizeInPx() { |
| 150 if (kIdealHomescreenIconSize == -1) | 150 if (kIdealHomescreenIconSize == -1) |
| 151 GetHomescreenIconAndSplashImageSizes(); | 151 GetHomescreenIconAndSplashImageSizes(); |
| 152 return kIdealHomescreenIconSize; | 152 return kIdealHomescreenIconSize; |
| 153 } | 153 } |
| 154 | 154 |
| 155 int ShortcutHelper::GetMinimumHomescreenIconSizeInDp() { | 155 int ShortcutHelper::GetMinimumHomescreenIconSizeInPx() { |
| 156 if (kMinimumHomescreenIconSize == -1) | 156 if (kMinimumHomescreenIconSize == -1) |
| 157 GetHomescreenIconAndSplashImageSizes(); | 157 GetHomescreenIconAndSplashImageSizes(); |
| 158 return kMinimumHomescreenIconSize; | 158 return kMinimumHomescreenIconSize; |
| 159 } | 159 } |
| 160 | 160 |
| 161 int ShortcutHelper::GetIdealSplashImageSizeInDp() { | 161 int ShortcutHelper::GetIdealSplashImageSizeInPx() { |
| 162 if (kIdealSplashImageSize == -1) | 162 if (kIdealSplashImageSize == -1) |
| 163 GetHomescreenIconAndSplashImageSizes(); | 163 GetHomescreenIconAndSplashImageSizes(); |
| 164 return kIdealSplashImageSize; | 164 return kIdealSplashImageSize; |
| 165 } | 165 } |
| 166 | 166 |
| 167 int ShortcutHelper::GetMinimumSplashImageSizeInDp() { | 167 int ShortcutHelper::GetMinimumSplashImageSizeInPx() { |
| 168 if (kMinimumSplashImageSize == -1) | 168 if (kMinimumSplashImageSize == -1) |
| 169 GetHomescreenIconAndSplashImageSizes(); | 169 GetHomescreenIconAndSplashImageSizes(); |
| 170 return kMinimumSplashImageSize; | 170 return kMinimumSplashImageSize; |
| 171 } | 171 } |
| 172 | 172 |
| 173 // static | 173 // static |
| 174 void ShortcutHelper::FetchSplashScreenImage( | 174 void ShortcutHelper::FetchSplashScreenImage( |
| 175 content::WebContents* web_contents, | 175 content::WebContents* web_contents, |
| 176 const GURL& image_url, | 176 const GURL& image_url, |
| 177 const int ideal_splash_image_size_in_dp, | 177 const int ideal_splash_image_size_in_px, |
| 178 const int minimum_splash_image_size_in_dp, | 178 const int minimum_splash_image_size_in_px, |
| 179 const std::string& webapp_id) { | 179 const std::string& webapp_id) { |
| 180 // This is a fire and forget task. It is not vital for the splash screen image | 180 // This is a fire and forget task. It is not vital for the splash screen image |
| 181 // to be downloaded so if the downloader returns false there is no fallback. | 181 // to be downloaded so if the downloader returns false there is no fallback. |
| 182 ManifestIconDownloader::Download( | 182 ManifestIconDownloader::Download( |
| 183 web_contents, image_url, ideal_splash_image_size_in_dp, | 183 web_contents, image_url, ideal_splash_image_size_in_px, |
| 184 minimum_splash_image_size_in_dp, | 184 minimum_splash_image_size_in_px, |
| 185 base::Bind(&ShortcutHelper::StoreWebappSplashImage, webapp_id)); | 185 base::Bind(&ShortcutHelper::StoreWebappSplashImage, webapp_id)); |
| 186 } | 186 } |
| 187 | 187 |
| 188 // static | 188 // static |
| 189 void ShortcutHelper::StoreWebappSplashImage( | 189 void ShortcutHelper::StoreWebappSplashImage( |
| 190 const std::string& webapp_id, | 190 const std::string& webapp_id, |
| 191 const SkBitmap& splash_image) { | 191 const SkBitmap& splash_image) { |
| 192 if (splash_image.drawsNothing()) | 192 if (splash_image.drawsNothing()) |
| 193 return; | 193 return; |
| 194 | 194 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 DCHECK(jsplash_image_callback); | 286 DCHECK(jsplash_image_callback); |
| 287 base::Closure* splash_image_callback = | 287 base::Closure* splash_image_callback = |
| 288 reinterpret_cast<base::Closure*>(jsplash_image_callback); | 288 reinterpret_cast<base::Closure*>(jsplash_image_callback); |
| 289 splash_image_callback->Run(); | 289 splash_image_callback->Run(); |
| 290 delete splash_image_callback; | 290 delete splash_image_callback; |
| 291 } | 291 } |
| 292 | 292 |
| 293 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { | 293 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { |
| 294 return RegisterNativesImpl(env); | 294 return RegisterNativesImpl(env); |
| 295 } | 295 } |
| OLD | NEW |