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

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

Issue 2689993002: Refactor the INSTALL_SHORTCUT broadcast code into ChromeShortcutManager (Closed)
Patch Set: Change according to review comments. Created 3 years, 10 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
« no previous file with comments | « chrome/browser/android/shortcut_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <utility> 8 #include <utility>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 content::BrowserContext* browser_context, 72 content::BrowserContext* browser_context,
73 const ShortcutInfo& info, 73 const ShortcutInfo& info,
74 const std::string& webapp_id, 74 const std::string& webapp_id,
75 const SkBitmap& icon_bitmap, 75 const SkBitmap& icon_bitmap,
76 const base::Closure& splash_image_callback) { 76 const base::Closure& splash_image_callback) {
77 if (info.display == blink::WebDisplayModeStandalone || 77 if (info.display == blink::WebDisplayModeStandalone ||
78 info.display == blink::WebDisplayModeFullscreen) { 78 info.display == blink::WebDisplayModeFullscreen) {
79 AddWebappWithSkBitmap(info, webapp_id, icon_bitmap, splash_image_callback); 79 AddWebappWithSkBitmap(info, webapp_id, icon_bitmap, splash_image_callback);
80 return; 80 return;
81 } 81 }
82 AddShortcutWithSkBitmap(info, icon_bitmap); 82 AddShortcutWithSkBitmap(info, webapp_id, icon_bitmap);
83 } 83 }
84 84
85 // static 85 // static
86 void ShortcutHelper::InstallWebApkWithSkBitmap( 86 void ShortcutHelper::InstallWebApkWithSkBitmap(
87 content::BrowserContext* browser_context, 87 content::BrowserContext* browser_context,
88 const ShortcutInfo& info, 88 const ShortcutInfo& info,
89 const SkBitmap& icon_bitmap, 89 const SkBitmap& icon_bitmap,
90 const WebApkInstaller::FinishCallback& callback) { 90 const WebApkInstaller::FinishCallback& callback) {
91 WebApkInstallService::Get(browser_context) 91 WebApkInstallService::Get(browser_context)
92 ->InstallAsync(info, icon_bitmap, callback); 92 ->InstallAsync(info, icon_bitmap, callback);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 reinterpret_cast<uintptr_t>(new base::Closure(splash_image_callback)); 127 reinterpret_cast<uintptr_t>(new base::Closure(splash_image_callback));
128 128
129 Java_ShortcutHelper_addWebapp( 129 Java_ShortcutHelper_addWebapp(
130 env, java_webapp_id, java_url, java_scope_url, java_user_title, java_name, 130 env, java_webapp_id, java_url, java_scope_url, java_user_title, java_name,
131 java_short_name, java_best_primary_icon_url, java_bitmap, info.display, 131 java_short_name, java_best_primary_icon_url, java_bitmap, info.display,
132 info.orientation, info.source, info.theme_color, info.background_color, 132 info.orientation, info.source, info.theme_color, info.background_color,
133 callback_pointer); 133 callback_pointer);
134 } 134 }
135 135
136 void ShortcutHelper::AddShortcutWithSkBitmap(const ShortcutInfo& info, 136 void ShortcutHelper::AddShortcutWithSkBitmap(const ShortcutInfo& info,
137 const std::string& id,
137 const SkBitmap& icon_bitmap) { 138 const SkBitmap& icon_bitmap) {
138 JNIEnv* env = base::android::AttachCurrentThread(); 139 JNIEnv* env = base::android::AttachCurrentThread();
140 ScopedJavaLocalRef<jstring> java_id =
141 base::android::ConvertUTF8ToJavaString(env, id);
139 ScopedJavaLocalRef<jstring> java_url = 142 ScopedJavaLocalRef<jstring> java_url =
140 base::android::ConvertUTF8ToJavaString(env, info.url.spec()); 143 base::android::ConvertUTF8ToJavaString(env, info.url.spec());
141 ScopedJavaLocalRef<jstring> java_user_title = 144 ScopedJavaLocalRef<jstring> java_user_title =
142 base::android::ConvertUTF16ToJavaString(env, info.user_title); 145 base::android::ConvertUTF16ToJavaString(env, info.user_title);
143 ScopedJavaLocalRef<jobject> java_bitmap; 146 ScopedJavaLocalRef<jobject> java_bitmap;
144 if (icon_bitmap.getSize()) 147 if (icon_bitmap.getSize())
145 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); 148 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap);
146 149
147 Java_ShortcutHelper_addShortcut(env, java_url, java_user_title, java_bitmap, 150 Java_ShortcutHelper_addShortcut(env, java_id, java_url, java_user_title,
148 info.source); 151 java_bitmap, info.source);
149 } 152 }
150 153
151 void ShortcutHelper::ShowWebApkInstallInProgressToast() { 154 void ShortcutHelper::ShowWebApkInstallInProgressToast() {
152 Java_ShortcutHelper_showWebApkInstallInProgressToast( 155 Java_ShortcutHelper_showWebApkInstallInProgressToast(
153 base::android::AttachCurrentThread()); 156 base::android::AttachCurrentThread());
154 } 157 }
155 158
156 int ShortcutHelper::GetIdealHomescreenIconSizeInPx() { 159 int ShortcutHelper::GetIdealHomescreenIconSizeInPx() {
157 if (g_ideal_homescreen_icon_size == -1) 160 if (g_ideal_homescreen_icon_size == -1)
158 GetHomescreenIconAndSplashImageSizes(); 161 GetHomescreenIconAndSplashImageSizes();
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 351
349 ShortcutHelper::WebApkInfoCallback* webapk_list_callback = 352 ShortcutHelper::WebApkInfoCallback* webapk_list_callback =
350 reinterpret_cast<ShortcutHelper::WebApkInfoCallback*>(jcallback_pointer); 353 reinterpret_cast<ShortcutHelper::WebApkInfoCallback*>(jcallback_pointer);
351 webapk_list_callback->Run(webapk_list); 354 webapk_list_callback->Run(webapk_list);
352 delete webapk_list_callback; 355 delete webapk_list_callback;
353 } 356 }
354 357
355 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { 358 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
356 return RegisterNativesImpl(env); 359 return RegisterNativesImpl(env);
357 } 360 }
OLDNEW
« no previous file with comments | « chrome/browser/android/shortcut_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698