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

Side by Side Diff: chrome/browser/android/banners/app_banner_infobar_delegate_android.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 | « no previous file | chrome/browser/android/banners/app_banner_manager_android.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/banners/app_banner_infobar_delegate_android.h" 5 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/guid.h"
10 #include "base/location.h" 9 #include "base/location.h"
11 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
12 #include "base/timer/elapsed_timer.h" 11 #include "base/timer/elapsed_timer.h"
13 #include "chrome/browser/android/shortcut_helper.h" 12 #include "chrome/browser/android/shortcut_helper.h"
14 #include "chrome/browser/android/shortcut_info.h" 13 #include "chrome/browser/android/shortcut_info.h"
15 #include "chrome/browser/android/tab_android.h" 14 #include "chrome/browser/android/tab_android.h"
16 #include "chrome/browser/android/webapk/chrome_webapk_host.h" 15 #include "chrome/browser/android/webapk/chrome_webapk_host.h"
17 #include "chrome/browser/android/webapk/webapk_installer.h" 16 #include "chrome/browser/android/webapk/webapk_installer.h"
18 #include "chrome/browser/banners/app_banner_manager.h" 17 #include "chrome/browser/banners/app_banner_manager.h"
19 #include "chrome/browser/banners/app_banner_metrics.h" 18 #include "chrome/browser/banners/app_banner_metrics.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 287
289 bool AppBannerInfoBarDelegateAndroid::AcceptWebApp( 288 bool AppBannerInfoBarDelegateAndroid::AcceptWebApp(
290 content::WebContents* web_contents) { 289 content::WebContents* web_contents) {
291 if (IsInfoEmpty(shortcut_info_)) 290 if (IsInfoEmpty(shortcut_info_))
292 return true; 291 return true;
293 TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED); 292 TrackUserResponse(USER_RESPONSE_WEB_APP_ACCEPTED);
294 293
295 AppBannerSettingsHelper::RecordBannerInstallEvent( 294 AppBannerSettingsHelper::RecordBannerInstallEvent(
296 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB); 295 web_contents, shortcut_info_->url.spec(), AppBannerSettingsHelper::WEB);
297 296
298 if (weak_manager_) { 297 ShortcutHelper::AddToLauncherWithSkBitmap(web_contents, *shortcut_info_,
299 const std::string& uid = base::GenerateGUID(); 298 *icon_.get());
300 ShortcutHelper::AddToLauncherWithSkBitmap(
301 web_contents->GetBrowserContext(), *shortcut_info_, uid,
302 *icon_.get(), weak_manager_->FetchWebappSplashScreenImageCallback(uid));
303 }
304 299
305 SendBannerAccepted(); 300 SendBannerAccepted();
306 return true; 301 return true;
307 } 302 }
308 303
309 bool AppBannerInfoBarDelegateAndroid::AcceptWebApk( 304 bool AppBannerInfoBarDelegateAndroid::AcceptWebApk(
310 content::WebContents* web_contents) { 305 content::WebContents* web_contents) {
311 if (IsInfoEmpty(shortcut_info_)) 306 if (IsInfoEmpty(shortcut_info_))
312 return true; 307 return true;
313 308
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 342 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
348 AppBannerManager::GetCurrentTime()); 343 AppBannerManager::GetCurrentTime());
349 } 344 }
350 345
351 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState( 346 Java_AppBannerInfoBarDelegateAndroid_setWebApkInstallingState(
352 env, java_delegate_, true); 347 env, java_delegate_, true);
353 UpdateInstallState(env, nullptr); 348 UpdateInstallState(env, nullptr);
354 WebApkInstaller::FinishCallback callback = 349 WebApkInstaller::FinishCallback callback =
355 base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished, 350 base::Bind(&AppBannerInfoBarDelegateAndroid::OnWebApkInstallFinished,
356 weak_ptr_factory_.GetWeakPtr()); 351 weak_ptr_factory_.GetWeakPtr());
357 ShortcutHelper::InstallWebApkWithSkBitmap(web_contents->GetBrowserContext(), 352 ShortcutHelper::InstallWebApkWithSkBitmap(web_contents, *shortcut_info_,
358 *shortcut_info_,
359 *icon_.get(), callback); 353 *icon_.get(), callback);
360 SendBannerAccepted(); 354 SendBannerAccepted();
361 355
362 // Prevent the infobar from disappearing, because the infobar will show 356 // Prevent the infobar from disappearing, because the infobar will show
363 // "Adding" during the installation process. 357 // "Adding" during the installation process.
364 return false; 358 return false;
365 } 359 }
366 360
367 bool AppBannerInfoBarDelegateAndroid::TriggeredFromBanner() const { 361 bool AppBannerInfoBarDelegateAndroid::TriggeredFromBanner() const {
368 return !is_webapk_ || webapk_install_source_ == webapk::INSTALL_SOURCE_BANNER; 362 return !is_webapk_ || webapk_install_source_ == webapk::INSTALL_SOURCE_BANNER;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 467
474 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); 468 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK);
475 return true; 469 return true;
476 } 470 }
477 471
478 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { 472 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) {
479 return RegisterNativesImpl(env); 473 return RegisterNativesImpl(env);
480 } 474 }
481 475
482 } // namespace banners 476 } // namespace banners
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/banners/app_banner_manager_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698