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

Unified Diff: chrome/browser/android/webapps/add_to_homescreen_dialog_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/webapps/add_to_homescreen_dialog_helper.cc
diff --git a/chrome/browser/android/webapps/add_to_homescreen_dialog_helper.cc b/chrome/browser/android/webapps/add_to_homescreen_dialog_helper.cc
index 03f310df77862c70d77693472cc0a6d7b0d92444..d8ddb15f632e83db3d990d73078d9d69330526b3 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_dialog_helper.cc
+++ b/chrome/browser/android/webapps/add_to_homescreen_dialog_helper.cc
@@ -9,6 +9,7 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/basictypes.h"
+#include "base/guid.h"
#include "base/location.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
@@ -24,19 +25,30 @@
using content::Manifest;
-jlong Initialize(JNIEnv* env, jobject obj, jobject java_web_contents) {
+jlong Initialize(JNIEnv* env,
+ jobject obj,
+ jobject java_web_contents,
+ jint ideal_splash_icon_size_in_dp,
Lalit Maganti 2015/08/26 21:18:21 And here.
Lalit Maganti 2015/08/26 22:55:00 Done.
+ jint ideal_icon_size_in_dp) {
content::WebContents* web_contents =
content::WebContents::FromJavaWebContents(java_web_contents);
AddToHomescreenDialogHelper* add_to_homescreen_helper =
- new AddToHomescreenDialogHelper(env, obj, web_contents);
+ new AddToHomescreenDialogHelper(env, obj, web_contents,
+ ideal_splash_icon_size_in_dp, ideal_icon_size_in_dp);
return reinterpret_cast<intptr_t>(add_to_homescreen_helper);
}
-AddToHomescreenDialogHelper::AddToHomescreenDialogHelper(JNIEnv* env,
- jobject obj,
- content::WebContents* web_contents)
+AddToHomescreenDialogHelper::AddToHomescreenDialogHelper(
+ JNIEnv* env,
+ jobject obj,
+ content::WebContents* web_contents,
+ int ideal_splash_icon_size_in_dp,
Lalit Maganti 2015/08/26 21:18:21 And here.
Lalit Maganti 2015/08/26 22:55:00 Done.
+ int ideal_icon_size_in_dp)
: add_shortcut_pending_(false),
- data_fetcher_(new AddToHomescreenDataFetcher(web_contents, this)) {
+ data_fetcher_(new AddToHomescreenDataFetcher(web_contents,
+ ideal_splash_icon_size_in_dp,
+ ideal_icon_size_in_dp,
+ this)) {
java_ref_.Reset(env, obj);
}
@@ -56,7 +68,7 @@ void AddToHomescreenDialogHelper::OnUserTitleAvailable(
}
void AddToHomescreenDialogHelper::OnDataAvailable(const ShortcutInfo& info,
- const SkBitmap& icon) {
+ const SkBitmap& icon) {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> java_bitmap;
if (icon.getSize())
@@ -122,7 +134,7 @@ void AddToHomescreenDialogHelper::AddShortcut(JNIEnv* env,
}
void AddToHomescreenDialogHelper::AddShortcut(const ShortcutInfo& info,
- const SkBitmap& icon) {
+ const SkBitmap& icon) {
DCHECK(add_shortcut_pending_);
if (!add_shortcut_pending_)
return;
@@ -130,12 +142,16 @@ void AddToHomescreenDialogHelper::AddShortcut(const ShortcutInfo& info,
RecordAddToHomescreen();
+ const std::string& uid = base::GenerateGUID();
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap,
info,
+ uid,
icon));
+
+ data_fetcher_->FetchSplashscreenImage(uid);
}
bool AddToHomescreenDialogHelper::RegisterAddToHomescreenDialogHelper(

Powered by Google App Engine
This is Rietveld 408576698