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

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

Issue 2724723002: [WebAPKs]: Reduce the parameters of ShortcutHelper::AddToLauncherWithSkBitmap() (Closed)
Patch Set: Merge branch 'master' into refactor_shortcut_helper2 Created 3 years, 9 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') | chrome/browser/android/shortcut_info.h » ('j') | 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"
11 #include "base/android/jni_array.h" 11 #include "base/android/jni_array.h"
12 #include "base/android/jni_string.h" 12 #include "base/android/jni_string.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/command_line.h" 15 #include "base/guid.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/threading/sequenced_worker_pool.h" 18 #include "base/threading/sequenced_worker_pool.h"
19 #include "chrome/browser/android/webapk/chrome_webapk_host.h" 19 #include "chrome/browser/android/webapk/chrome_webapk_host.h"
20 #include "chrome/browser/android/webapk/webapk_install_service.h" 20 #include "chrome/browser/android/webapk/webapk_install_service.h"
21 #include "chrome/browser/android/webapk/webapk_metrics.h" 21 #include "chrome/browser/android/webapk/webapk_metrics.h"
22 #include "chrome/browser/manifest/manifest_icon_downloader.h" 22 #include "chrome/browser/manifest/manifest_icon_downloader.h"
23 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
24 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); 126 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap);
127 127
128 Java_ShortcutHelper_addShortcut(env, java_id, java_url, java_user_title, 128 Java_ShortcutHelper_addShortcut(env, java_id, java_url, java_user_title,
129 java_bitmap, info.source); 129 java_bitmap, info.source);
130 } 130 }
131 131
132 } // anonymous namespace 132 } // anonymous namespace
133 133
134 // static 134 // static
135 void ShortcutHelper::AddToLauncherWithSkBitmap( 135 void ShortcutHelper::AddToLauncherWithSkBitmap(
136 content::BrowserContext* browser_context, 136 content::WebContents* web_contents,
137 const ShortcutInfo& info, 137 const ShortcutInfo& info,
138 const std::string& webapp_id, 138 const SkBitmap& icon_bitmap) {
139 const SkBitmap& icon_bitmap, 139 std::string webapp_id = base::GenerateGUID();
140 const base::Closure& splash_image_callback) {
141 if (info.display == blink::WebDisplayModeStandalone || 140 if (info.display == blink::WebDisplayModeStandalone ||
142 info.display == blink::WebDisplayModeFullscreen) { 141 info.display == blink::WebDisplayModeFullscreen) {
143 AddWebappWithSkBitmap(info, webapp_id, icon_bitmap, splash_image_callback); 142 AddWebappWithSkBitmap(
143 info, webapp_id, icon_bitmap,
144 base::Bind(&ShortcutHelper::FetchSplashScreenImage, web_contents,
145 info.splash_image_url, info.ideal_splash_image_size_in_px,
146 info.minimum_splash_image_size_in_px, webapp_id));
144 GooglePlayInstallState state = 147 GooglePlayInstallState state =
145 ChromeWebApkHost::GetGooglePlayInstallState(); 148 ChromeWebApkHost::GetGooglePlayInstallState();
146 if (state != GooglePlayInstallState::SUPPORTED) 149 if (state != GooglePlayInstallState::SUPPORTED)
147 webapk::TrackGooglePlayInstallState(state); 150 webapk::TrackGooglePlayInstallState(state);
148 return; 151 return;
149 } 152 }
150 AddShortcutWithSkBitmap(info, webapp_id, icon_bitmap); 153 AddShortcutWithSkBitmap(info, webapp_id, icon_bitmap);
151 } 154 }
152 155
153 // static 156 // static
154 void ShortcutHelper::InstallWebApkWithSkBitmap( 157 void ShortcutHelper::InstallWebApkWithSkBitmap(
155 content::BrowserContext* browser_context, 158 content::WebContents* web_contents,
156 const ShortcutInfo& info, 159 const ShortcutInfo& info,
157 const SkBitmap& icon_bitmap, 160 const SkBitmap& icon_bitmap,
158 const WebApkInstaller::FinishCallback& callback) { 161 const WebApkInstaller::FinishCallback& callback) {
159 WebApkInstallService::Get(browser_context) 162 WebApkInstallService::Get(web_contents->GetBrowserContext())
160 ->InstallAsync(info, icon_bitmap, callback); 163 ->InstallAsync(info, icon_bitmap, callback);
161 // Don't record metric for users who install WebAPKs via "unsigned sources" 164 // Don't record metric for users who install WebAPKs via "unsigned sources"
162 // flow. 165 // flow.
163 if (ChromeWebApkHost::GetGooglePlayInstallState() == 166 if (ChromeWebApkHost::GetGooglePlayInstallState() ==
164 GooglePlayInstallState::SUPPORTED) { 167 GooglePlayInstallState::SUPPORTED) {
165 webapk::TrackGooglePlayInstallState(GooglePlayInstallState::SUPPORTED); 168 webapk::TrackGooglePlayInstallState(GooglePlayInstallState::SUPPORTED);
166 } 169 }
167 } 170 }
168 171
169 void ShortcutHelper::ShowWebApkInstallInProgressToast() { 172 void ShortcutHelper::ShowWebApkInstallInProgressToast() {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 369
367 ShortcutHelper::WebApkInfoCallback* webapk_list_callback = 370 ShortcutHelper::WebApkInfoCallback* webapk_list_callback =
368 reinterpret_cast<ShortcutHelper::WebApkInfoCallback*>(jcallback_pointer); 371 reinterpret_cast<ShortcutHelper::WebApkInfoCallback*>(jcallback_pointer);
369 webapk_list_callback->Run(webapk_list); 372 webapk_list_callback->Run(webapk_list);
370 delete webapk_list_callback; 373 delete webapk_list_callback;
371 } 374 }
372 375
373 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { 376 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
374 return RegisterNativesImpl(env); 377 return RegisterNativesImpl(env);
375 } 378 }
OLDNEW
« no previous file with comments | « chrome/browser/android/shortcut_helper.h ('k') | chrome/browser/android/shortcut_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698