| Index: chrome/browser/android/shortcut_helper.cc
|
| diff --git a/chrome/browser/android/shortcut_helper.cc b/chrome/browser/android/shortcut_helper.cc
|
| index cead81b0d9f22a05e0c5ef072dfd7b067508c017..628926ff54a3f898cc2685eb98278a6479378a22 100644
|
| --- a/chrome/browser/android/shortcut_helper.cc
|
| +++ b/chrome/browser/android/shortcut_helper.cc
|
| @@ -7,6 +7,7 @@
|
| #include <jni.h>
|
|
|
| #include "base/android/jni_android.h"
|
| +#include "base/android/jni_array.h"
|
| #include "base/android/jni_string.h"
|
| #include "base/basictypes.h"
|
| #include "base/strings/string16.h"
|
| @@ -20,6 +21,36 @@
|
|
|
| using content::Manifest;
|
|
|
| +namespace {
|
| +static int kIdealIconSize = -1;
|
| +static int kMinimumIconSize = -1;
|
| +static int kIdealSplashImageSize = -1;
|
| +static int kMinimumSplashImageSize = -1;
|
| +
|
| +// Retrieves and caches the ideal and minimum sizes of the Home screen icon
|
| +// and the splash screen image.
|
| +void GetIconAndSplashImageSizes() {
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| + ScopedJavaLocalRef<jintArray> java_size_array =
|
| + Java_ShortcutHelper_getIconAndSplashImageSizes(env,
|
| + base::android::GetApplicationContext());
|
| + std::vector<int> size_vector;
|
| + base::android::JavaIntArrayToIntVector(
|
| + env, java_size_array.obj(), &size_vector);
|
| +
|
| + // This ordering must be kept up to date with the Java ShortcutHelper.
|
| + kIdealIconSize = size_vector[0];
|
| + kMinimumIconSize = size_vector[1];
|
| + kIdealSplashImageSize = size_vector[2];
|
| + kMinimumSplashImageSize = size_vector[3];
|
| +
|
| + // Try to ensure that the data returned is sane.
|
| + DCHECK(size_vector.size() == 4);
|
| + DCHECK(kMinimumIconSize <= kIdealIconSize);
|
| + DCHECK(kMinimumSplashImageSize <= kIdealSplashImageSize);
|
| +}
|
| +} // namespace
|
| +
|
| // static
|
| void ShortcutHelper::AddShortcutInBackgroundWithSkBitmap(
|
| const ShortcutInfo& info,
|
| @@ -59,11 +90,36 @@ void ShortcutHelper::AddShortcutInBackgroundWithSkBitmap(
|
| info.background_color);
|
| }
|
|
|
| +int ShortcutHelper::GetIdealSplashImageSizeInDp() {
|
| + if (kIdealIconSize == -1)
|
| + GetIconAndSplashImageSizes();
|
| + return kIdealIconSize;
|
| +}
|
| +
|
| +int ShortcutHelper::GetMinimumSplashImageSizeInDp() {
|
| + if (kMinimumIconSize == -1)
|
| + GetIconAndSplashImageSizes();
|
| + return kMinimumIconSize;
|
| +}
|
| +
|
| +int ShortcutHelper::GetIdealIconSizeInDp() {
|
| + if (kIdealSplashImageSize == -1)
|
| + GetIconAndSplashImageSizes();
|
| + return kIdealSplashImageSize;
|
| +}
|
| +
|
| +int ShortcutHelper::GetMinimumIconSizeInDp() {
|
| + if (kMinimumSplashImageSize == -1)
|
| + GetIconAndSplashImageSizes();
|
| + return kMinimumSplashImageSize;
|
| +}
|
| +
|
| // static
|
| void ShortcutHelper::FetchSplashScreenImage(
|
| content::WebContents* web_contents,
|
| const GURL& image_url,
|
| const int ideal_splash_image_size_in_dp,
|
| + const int minimum_splash_image_size_in_dp,
|
| const std::string& webapp_id) {
|
| // This is a fire and forget task. It is not vital for the splash screen image
|
| // to be downloaded so if the downloader returns false there is no fallback.
|
| @@ -71,6 +127,7 @@ void ShortcutHelper::FetchSplashScreenImage(
|
| web_contents,
|
| image_url,
|
| ideal_splash_image_size_in_dp,
|
| + minimum_splash_image_size_in_dp,
|
| base::Bind(&ShortcutHelper::StoreWebappData, webapp_id));
|
| }
|
|
|
|
|