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

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

Issue 2259553002: Make AppBannerInfoBar install WebAPK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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_array.h" 10 #include "base/android/jni_array.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 // static 67 // static
68 void ShortcutHelper::AddToLauncherWithSkBitmap( 68 void ShortcutHelper::AddToLauncherWithSkBitmap(
69 content::BrowserContext* browser_context, 69 content::BrowserContext* browser_context,
70 const ShortcutInfo& info, 70 const ShortcutInfo& info,
71 const std::string& webapp_id, 71 const std::string& webapp_id,
72 const SkBitmap& icon_bitmap, 72 const SkBitmap& icon_bitmap,
73 const base::Closure& splash_image_callback) { 73 const base::Closure& splash_image_callback) {
74 if (info.display == blink::WebDisplayModeStandalone || 74 if (info.display == blink::WebDisplayModeStandalone ||
75 info.display == blink::WebDisplayModeFullscreen) { 75 info.display == blink::WebDisplayModeFullscreen) {
76 if (ChromeWebApkHost::AreWebApkEnabled()) {
77 InstallWebApkWithSkBitmap(browser_context, info, icon_bitmap);
78 return;
79 }
80 AddWebappWithSkBitmap(info, webapp_id, icon_bitmap, splash_image_callback); 76 AddWebappWithSkBitmap(info, webapp_id, icon_bitmap, splash_image_callback);
81 return; 77 return;
82 } 78 }
83 AddShortcutWithSkBitmap(info, icon_bitmap); 79 AddShortcutWithSkBitmap(info, icon_bitmap);
84 } 80 }
85 81
86 // static 82 // static
87 void ShortcutHelper::InstallWebApkWithSkBitmap( 83 void ShortcutHelper::InstallWebApkWithSkBitmap(
88 content::BrowserContext* browser_context, 84 content::BrowserContext* browser_context,
89 const ShortcutInfo& info, 85 const ShortcutInfo& info,
90 const SkBitmap& icon_bitmap) { 86 const SkBitmap& icon_bitmap,
87 const WebApkInstaller::FinishCallback& callback) {
91 // WebApkInstaller destroys itself when it is done. 88 // WebApkInstaller destroys itself when it is done.
92 WebApkInstaller* installer = new WebApkInstaller(info, icon_bitmap); 89 WebApkInstaller* installer = new WebApkInstaller(info, icon_bitmap);
93 installer->InstallAsync(browser_context, 90 installer->InstallAsync(browser_context, callback);
94 base::Bind(&ShortcutHelper::OnBuiltWebApk));
95 } 91 }
96 92
97 // static 93 // static
98 void ShortcutHelper::AddWebappWithSkBitmap( 94 void ShortcutHelper::AddWebappWithSkBitmap(
99 const ShortcutInfo& info, 95 const ShortcutInfo& info,
100 const std::string& webapp_id, 96 const std::string& webapp_id,
101 const SkBitmap& icon_bitmap, 97 const SkBitmap& icon_bitmap,
102 const base::Closure& splash_image_callback) { 98 const base::Closure& splash_image_callback) {
103 // Send the data to the Java side to create the shortcut. 99 // Send the data to the Java side to create the shortcut.
104 JNIEnv* env = base::android::AttachCurrentThread(); 100 JNIEnv* env = base::android::AttachCurrentThread();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 ScopedJavaLocalRef<jstring> java_user_title = 139 ScopedJavaLocalRef<jstring> java_user_title =
144 base::android::ConvertUTF16ToJavaString(env, info.user_title); 140 base::android::ConvertUTF16ToJavaString(env, info.user_title);
145 ScopedJavaLocalRef<jobject> java_bitmap; 141 ScopedJavaLocalRef<jobject> java_bitmap;
146 if (icon_bitmap.getSize()) 142 if (icon_bitmap.getSize())
147 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); 143 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap);
148 144
149 Java_ShortcutHelper_addShortcut(env, java_url, java_user_title, java_bitmap, 145 Java_ShortcutHelper_addShortcut(env, java_url, java_user_title, java_bitmap,
150 info.source); 146 info.source);
151 } 147 }
152 148
153 void ShortcutHelper::OnBuiltWebApk(bool success) {
154 if (success) {
155 DVLOG(1) << "Sent request to install WebAPK. Seems to have worked.";
156 } else {
157 LOG(ERROR) << "WebAPK install failed.";
158 }
159 // TODO(pkotwicz): Figure out what to do when installing WebAPK fails.
160 // (crbug.com/626950)
161 }
162
163 int ShortcutHelper::GetIdealHomescreenIconSizeInDp() { 149 int ShortcutHelper::GetIdealHomescreenIconSizeInDp() {
164 if (kIdealHomescreenIconSize == -1) 150 if (kIdealHomescreenIconSize == -1)
165 GetHomescreenIconAndSplashImageSizes(); 151 GetHomescreenIconAndSplashImageSizes();
166 return kIdealHomescreenIconSize; 152 return kIdealHomescreenIconSize;
167 } 153 }
168 154
169 int ShortcutHelper::GetMinimumHomescreenIconSizeInDp() { 155 int ShortcutHelper::GetMinimumHomescreenIconSizeInDp() {
170 if (kMinimumHomescreenIconSize == -1) 156 if (kMinimumHomescreenIconSize == -1)
171 GetHomescreenIconAndSplashImageSizes(); 157 GetHomescreenIconAndSplashImageSizes();
172 return kMinimumHomescreenIconSize; 158 return kMinimumHomescreenIconSize;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 DCHECK(jsplash_image_callback); 273 DCHECK(jsplash_image_callback);
288 base::Closure* splash_image_callback = 274 base::Closure* splash_image_callback =
289 reinterpret_cast<base::Closure*>(jsplash_image_callback); 275 reinterpret_cast<base::Closure*>(jsplash_image_callback);
290 splash_image_callback->Run(); 276 splash_image_callback->Run();
291 delete splash_image_callback; 277 delete splash_image_callback;
292 } 278 }
293 279
294 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { 280 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
295 return RegisterNativesImpl(env); 281 return RegisterNativesImpl(env);
296 } 282 }
OLDNEW
« no previous file with comments | « chrome/browser/android/shortcut_helper.h ('k') | chrome/browser/android/webapk/webapk_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698