Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Unified Diff: chrome/browser/android/shortcut_helper.cc

Issue 1310223002: webapps: initial addition of splash screen icon downloading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webapps-database-exp
Patch Set: Fix small issues Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8f52c8d4e68332f04a26db45f54c4cfdbaa50db3 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,37 @@ 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 splashscreen image
+ // to be downloaded so if the downloader returns false there is no fallback.
gone 2015/08/26 21:39:25 The fallback is still you setting the splash image
Lalit Maganti 2015/08/26 22:55:00 What I mean by no fallback is that I don't check t
+ 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) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ ScopedJavaLocalRef<jstring> java_webapp_id =
+ base::android::ConvertUTF8ToJavaString(env, webapp_id);
+ ScopedJavaLocalRef<jobject> java_splash_image;
+ if (!splash_image.drawsNothing())
+ java_splash_image = gfx::ConvertToJavaBitmap(&splash_image);
+
+ Java_ShortcutHelper_storeWebappData(
+ env,
+ base::android::GetApplicationContext(),
+ java_webapp_id.obj(),
+ java_splash_image.obj());
+}
+
bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
return RegisterNativesImpl(env);
}

Powered by Google App Engine
This is Rietveld 408576698