| Index: chrome/browser/android/shortcut_helper.cc
|
| diff --git a/chrome/browser/android/shortcut_helper.cc b/chrome/browser/android/shortcut_helper.cc
|
| index de75b8a9bbe9c38311932b53b6fff658e2de592d..c39462a32ef556f9aa02ce89660df20018ab7429 100644
|
| --- a/chrome/browser/android/shortcut_helper.cc
|
| +++ b/chrome/browser/android/shortcut_helper.cc
|
| @@ -17,6 +17,7 @@
|
| #include "content/public/browser/web_contents.h"
|
| #include "jni/ShortcutHelper_jni.h"
|
| #include "ui/gfx/android/java_bitmap.h"
|
| +#include "ui/gfx/color_analysis.h"
|
| #include "url/gurl.h"
|
|
|
| using content::Manifest;
|
| @@ -28,6 +29,8 @@ static int kMinimumHomescreenIconSize = -1;
|
| static int kIdealSplashImageSize = -1;
|
| static int kMinimumSplashImageSize = -1;
|
|
|
| +static int kDefaultRGBIconValue = 145;
|
| +
|
| // Retrieves and caches the ideal and minimum sizes of the Home screen icon
|
| // and the splash screen image.
|
| void GetHomescreenIconAndSplashImageSizes() {
|
| @@ -91,7 +94,8 @@ void ShortcutHelper::AddShortcutInBackgroundWithSkBitmap(
|
| info.orientation,
|
| info.source,
|
| info.theme_color,
|
| - info.background_color);
|
| + info.background_color,
|
| + info.is_icon_generated);
|
| }
|
|
|
| int ShortcutHelper::GetIdealHomescreenIconSizeInDp() {
|
| @@ -155,6 +159,44 @@ void ShortcutHelper::StoreWebappData(
|
| java_splash_image.obj());
|
| }
|
|
|
| +// static
|
| +SkBitmap ShortcutHelper::FinalizeLauncherIcon(const SkBitmap& bitmap,
|
| + const GURL& url,
|
| + bool* is_generated) {
|
| + DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
| +
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| + ScopedJavaLocalRef<jobject> result;
|
| + *is_generated = false;
|
| +
|
| + if (!bitmap.isNull()) {
|
| + ScopedJavaLocalRef<jobject> java_bitmap = gfx::ConvertToJavaBitmap(&bitmap);
|
| + if (Java_ShortcutHelper_isIconLargeEnoughForLauncher(
|
| + env, base::android::GetApplicationContext(), java_bitmap.obj())) {
|
| + result = Java_ShortcutHelper_modifyIconForLauncher(
|
| + env, base::android::GetApplicationContext(), java_bitmap.obj());
|
| + }
|
| + }
|
| +
|
| + if (result.is_null()) {
|
| + ScopedJavaLocalRef<jstring> java_url =
|
| + base::android::ConvertUTF8ToJavaString(env, url.spec());
|
| + SkColor mean_color = SkColorSetRGB(
|
| + kDefaultRGBIconValue, kDefaultRGBIconValue, kDefaultRGBIconValue);
|
| +
|
| + if (!bitmap.isNull())
|
| + mean_color = color_utils::CalculateKMeanColorOfBitmap(bitmap);
|
| +
|
| + *is_generated = true;
|
| + result = Java_ShortcutHelper_generateLauncherIcon(
|
| + env, base::android::GetApplicationContext(), java_url.obj(),
|
| + SkColorGetR(mean_color), SkColorGetG(mean_color),
|
| + SkColorGetB(mean_color));
|
| + }
|
| +
|
| + return gfx::CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(result.obj()));
|
| +}
|
| +
|
| bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
|
| return RegisterNativesImpl(env);
|
| }
|
|
|