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

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 compile Created 5 years, 3 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..cead81b0d9f22a05e0c5ef072dfd7b067508c017 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,41 @@ void ShortcutHelper::AddShortcutInBackgroundWithSkBitmap(
info.background_color);
}
+// static
+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));
+}
+
+// static
+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(
+ env,
+ base::android::GetApplicationContext(),
+ java_webapp_id.obj(),
+ java_splash_image.obj());
+}
+
bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
return RegisterNativesImpl(env);
}
« no previous file with comments | « chrome/browser/android/shortcut_helper.h ('k') | chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698