Chromium Code Reviews| Index: chrome/browser/android/shortcut_helper.cc |
| diff --git a/chrome/browser/android/shortcut_helper.cc b/chrome/browser/android/shortcut_helper.cc |
| index 4c7a38362706a7fd0fec07b057b764b8327d084a..0d111bd0999d9d55fc44215fc06e96e5e3784b8f 100644 |
| --- a/chrome/browser/android/shortcut_helper.cc |
| +++ b/chrome/browser/android/shortcut_helper.cc |
| @@ -9,16 +9,13 @@ |
| #include "base/android/jni_android.h" |
| #include "base/android/jni_string.h" |
| #include "base/basictypes.h" |
| -#include "base/location.h" |
| #include "base/strings/string16.h" |
| #include "base/strings/utf_string_conversions.h" |
| -#include "chrome/browser/banners/app_banner_settings_helper.h" |
| +#include "chrome/browser/manifest/manifest_icon_downloader.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/web_contents.h" |
| -#include "content/public/common/manifest.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; |
| @@ -26,11 +23,14 @@ using content::Manifest; |
| // static |
| void ShortcutHelper::AddShortcutInBackgroundWithSkBitmap( |
| const ShortcutInfo& info, |
| + const std::string& webapp_id, |
| const SkBitmap& icon_bitmap) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| // Send the data to the Java side to create the shortcut. |
| JNIEnv* env = base::android::AttachCurrentThread(); |
| + ScopedJavaLocalRef<jstring> java_webapp_id = |
| + base::android::ConvertUTF8ToJavaString(env, webapp_id); |
| ScopedJavaLocalRef<jstring> java_url = |
| base::android::ConvertUTF8ToJavaString(env, info.url.spec()); |
| ScopedJavaLocalRef<jstring> java_user_title = |
| @@ -46,6 +46,7 @@ void ShortcutHelper::AddShortcutInBackgroundWithSkBitmap( |
| Java_ShortcutHelper_addShortcut( |
| env, |
| base::android::GetApplicationContext(), |
| + java_webapp_id.obj(), |
| java_url.obj(), |
| java_user_title.obj(), |
| java_name.obj(), |
| @@ -58,6 +59,39 @@ void ShortcutHelper::AddShortcutInBackgroundWithSkBitmap( |
| info.background_color); |
| } |
| +void ShortcutHelper::FetchSplashScreenImage( |
| + content::WebContents* web_contents, |
| + const GURL& image_url, |
| + const int ideal_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. |
| + ManifestIconDownloader::Download( |
| + web_contents, |
| + image_url, |
| + ideal_splash_image_size_in_dp, |
| + base::Bind(&ShortcutHelper::StoreWebappData, webapp_id)); |
| +} |
| + |
| +void ShortcutHelper::StoreWebappData( |
| + const std::string& webapp_id, |
| + const SkBitmap& splash_image) { |
| + if (splash_image.drawsNothing()) |
| + return; |
| + |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| + ScopedJavaLocalRef<jstring> java_webapp_id = |
| + base::android::ConvertUTF8ToJavaString(env, webapp_id); |
| + ScopedJavaLocalRef<jobject> java_splash_image = |
| + gfx::ConvertToJavaBitmap(&splash_image); |
| + |
| + Java_ShortcutHelper_storeWebappData( |
|
mlamouri (slow - plz ping)
2015/09/02 16:56:57
Maybe you could rename that createWebappDataInfo?
Lalit Maganti
2015/09/02 17:15:42
Done but with createWebappData - Info seems redund
gone
2015/09/02 20:47:21
nit: you're not really creating web app data, you'
Lalit Maganti
2015/09/03 11:12:32
Switched back and haven't changed anything else.
|
| + env, |
| + base::android::GetApplicationContext(), |
| + java_webapp_id.obj(), |
| + java_splash_image.obj()); |
| +} |
| + |
| bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |