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

Side by Side Diff: chrome/browser/android/shortcut_helper.cc

Issue 1308533006: webapps: allow callers of icon downloader/selector to specify a minimum size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webapps-splashscreen-icon
Patch Set: Fix non-compiling test 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/shortcut_helper.h" 5 #include "chrome/browser/android/shortcut_helper.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 info.source, 57 info.source,
58 info.theme_color, 58 info.theme_color,
59 info.background_color); 59 info.background_color);
60 } 60 }
61 61
62 // static 62 // static
63 void ShortcutHelper::FetchSplashScreenImage( 63 void ShortcutHelper::FetchSplashScreenImage(
64 content::WebContents* web_contents, 64 content::WebContents* web_contents,
65 const GURL& image_url, 65 const GURL& image_url,
66 const int ideal_splash_image_size_in_dp, 66 const int ideal_splash_image_size_in_dp,
67 const int minimum_splash_image_size_in_dp,
67 const std::string& webapp_id) { 68 const std::string& webapp_id) {
68 // This is a fire and forget task. It is not vital for the splash screen image 69 // This is a fire and forget task. It is not vital for the splash screen image
69 // to be downloaded so if the downloader returns false there is no fallback. 70 // to be downloaded so if the downloader returns false there is no fallback.
70 ManifestIconDownloader::Download( 71 ManifestIconDownloader::Download(
71 web_contents, 72 web_contents,
72 image_url, 73 image_url,
73 ideal_splash_image_size_in_dp, 74 ideal_splash_image_size_in_dp,
75 minimum_splash_image_size_in_dp,
74 base::Bind(&ShortcutHelper::StoreWebappData, webapp_id)); 76 base::Bind(&ShortcutHelper::StoreWebappData, webapp_id));
75 } 77 }
76 78
79 int ShortcutHelper::GetIdealSplashImageSizeInDp() {
80 JNIEnv* env = base::android::AttachCurrentThread();
81 return Java_ShortcutHelper_getIdealSplashImageSizeInDp(
82 env, base::android::GetApplicationContext());
83 }
84
85 int ShortcutHelper::GetMinimumSplashImageSizeInDp() {
86 JNIEnv* env = base::android::AttachCurrentThread();
87 return Java_ShortcutHelper_getMinimumSplashImageSizeInDp(
88 env, base::android::GetApplicationContext());
89 }
90
91 int ShortcutHelper::GetIdealIconSizeInDp() {
92 JNIEnv* env = base::android::AttachCurrentThread();
93 return Java_ShortcutHelper_getIdealIconSizeInDp(
94 env, base::android::GetApplicationContext());
95 }
96
97 int ShortcutHelper::GetMinimumIconSizeInDp() {
98 JNIEnv* env = base::android::AttachCurrentThread();
99 return Java_ShortcutHelper_getMinimumIconSizeInDp(
100 env, base::android::GetApplicationContext());
101 }
102
77 // static 103 // static
78 void ShortcutHelper::StoreWebappData( 104 void ShortcutHelper::StoreWebappData(
79 const std::string& webapp_id, 105 const std::string& webapp_id,
80 const SkBitmap& splash_image) { 106 const SkBitmap& splash_image) {
81 if (splash_image.drawsNothing()) 107 if (splash_image.drawsNothing())
82 return; 108 return;
83 109
84 JNIEnv* env = base::android::AttachCurrentThread(); 110 JNIEnv* env = base::android::AttachCurrentThread();
85 ScopedJavaLocalRef<jstring> java_webapp_id = 111 ScopedJavaLocalRef<jstring> java_webapp_id =
86 base::android::ConvertUTF8ToJavaString(env, webapp_id); 112 base::android::ConvertUTF8ToJavaString(env, webapp_id);
87 ScopedJavaLocalRef<jobject> java_splash_image = 113 ScopedJavaLocalRef<jobject> java_splash_image =
88 gfx::ConvertToJavaBitmap(&splash_image); 114 gfx::ConvertToJavaBitmap(&splash_image);
89 115
90 Java_ShortcutHelper_storeWebappData( 116 Java_ShortcutHelper_storeWebappData(
91 env, 117 env,
92 base::android::GetApplicationContext(), 118 base::android::GetApplicationContext(),
93 java_webapp_id.obj(), 119 java_webapp_id.obj(),
94 java_splash_image.obj()); 120 java_splash_image.obj());
95 } 121 }
96 122
97 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { 123 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
98 return RegisterNativesImpl(env); 124 return RegisterNativesImpl(env);
99 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698