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

Side by Side Diff: chrome/browser/android/banners/app_banner_infobar_delegate_android.cc

Issue 2751423002: Remove unused open WebAPK logic in AppBannerInfoBarDelegateAndroid. (Closed)
Patch Set: Addressing comments 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
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/location.h" 9 #include "base/location.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // static 48 // static
49 bool AppBannerInfoBarDelegateAndroid::Create( 49 bool AppBannerInfoBarDelegateAndroid::Create(
50 content::WebContents* web_contents, 50 content::WebContents* web_contents,
51 base::WeakPtr<AppBannerManager> weak_manager, 51 base::WeakPtr<AppBannerManager> weak_manager,
52 const base::string16& app_title, 52 const base::string16& app_title,
53 std::unique_ptr<ShortcutInfo> shortcut_info, 53 std::unique_ptr<ShortcutInfo> shortcut_info,
54 std::unique_ptr<SkBitmap> icon, 54 std::unique_ptr<SkBitmap> icon,
55 int event_request_id, 55 int event_request_id,
56 webapk::InstallSource webapk_install_source) { 56 webapk::InstallSource webapk_install_source) {
57 bool is_webapk = ChromeWebApkHost::CanInstallWebApk(); 57 bool is_webapk = ChromeWebApkHost::CanInstallWebApk();
58 std::string webapk_package_name = "";
59 const GURL& url = shortcut_info->url;
60 if (is_webapk)
61 webapk_package_name = ShortcutHelper::QueryWebApkPackage(url);
62 bool is_webapk_already_installed = !webapk_package_name.empty();
63 auto infobar_delegate = 58 auto infobar_delegate =
64 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid( 59 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid(
65 weak_manager, app_title, std::move(shortcut_info), std::move(icon), 60 weak_manager, app_title, std::move(shortcut_info), std::move(icon),
66 event_request_id, is_webapk, is_webapk_already_installed, 61 event_request_id, is_webapk, webapk_install_source));
67 webapk_install_source));
68 auto* raw_delegate = infobar_delegate.get(); 62 auto* raw_delegate = infobar_delegate.get();
69 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>( 63 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>(
70 std::move(infobar_delegate), url, is_webapk); 64 std::move(infobar_delegate), shortcut_info->url, is_webapk);
dominickn 2017/03/19 22:56:56 Oops, I gave you bad advice here. |shortcut_info|
F 2017/03/22 18:49:23 Thanks for finding the cause! Done :)
71 if (!InfoBarService::FromWebContents(web_contents) 65 if (!InfoBarService::FromWebContents(web_contents)
72 ->AddInfoBar(std::move(infobar))) 66 ->AddInfoBar(std::move(infobar)))
73 return false; 67 return false;
74 68
75 if (is_webapk) { 69 if (is_webapk) {
76 if (webapk_install_source == webapk::INSTALL_SOURCE_MENU) { 70 if (webapk_install_source == webapk::INSTALL_SOURCE_MENU) {
77 webapk::TrackInstallInfoBarShown( 71 webapk::TrackInstallInfoBarShown(
78 webapk::WEBAPK_INFOBAR_SHOWN_FROM_MENU); 72 webapk::WEBAPK_INFOBAR_SHOWN_FROM_MENU);
79 if (is_webapk_already_installed) 73 raw_delegate->Accept();
80 raw_delegate->UpdateStateForInstalledWebAPK(webapk_package_name);
81 else
82 raw_delegate->Accept();
83 } else { 74 } else {
84 webapk::TrackInstallInfoBarShown( 75 webapk::TrackInstallInfoBarShown(
85 webapk::WEBAPK_INFOBAR_SHOWN_FROM_BANNER); 76 webapk::WEBAPK_INFOBAR_SHOWN_FROM_BANNER);
86 } 77 }
87 } 78 }
88 79
89 return true; 80 return true;
90 } 81 }
91 82
92 // static 83 // static
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 install_state_ = INSTALLED; 203 install_state_ = INSTALLED;
213 } 204 }
214 205
215 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( 206 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
216 base::WeakPtr<AppBannerManager> weak_manager, 207 base::WeakPtr<AppBannerManager> weak_manager,
217 const base::string16& app_title, 208 const base::string16& app_title,
218 std::unique_ptr<ShortcutInfo> shortcut_info, 209 std::unique_ptr<ShortcutInfo> shortcut_info,
219 std::unique_ptr<SkBitmap> icon, 210 std::unique_ptr<SkBitmap> icon,
220 int event_request_id, 211 int event_request_id,
221 bool is_webapk, 212 bool is_webapk,
222 bool is_webapk_already_installed,
223 webapk::InstallSource webapk_install_source) 213 webapk::InstallSource webapk_install_source)
224 : weak_manager_(weak_manager), 214 : weak_manager_(weak_manager),
225 app_title_(app_title), 215 app_title_(app_title),
226 shortcut_info_(std::move(shortcut_info)), 216 shortcut_info_(std::move(shortcut_info)),
227 icon_(std::move(icon)), 217 icon_(std::move(icon)),
228 event_request_id_(event_request_id), 218 event_request_id_(event_request_id),
229 has_user_interaction_(false), 219 has_user_interaction_(false),
230 is_webapk_(is_webapk), 220 is_webapk_(is_webapk),
231 is_webapk_already_installed_(is_webapk_already_installed),
232 install_state_(INSTALL_NOT_STARTED), 221 install_state_(INSTALL_NOT_STARTED),
233 webapk_install_source_(webapk_install_source), 222 webapk_install_source_(webapk_install_source),
234 weak_ptr_factory_(this) { 223 weak_ptr_factory_(this) {
235 DCHECK(!IsInfoEmpty(shortcut_info_)); 224 DCHECK(!IsInfoEmpty(shortcut_info_));
236 CreateJavaDelegate(); 225 CreateJavaDelegate();
237 } 226 }
238 227
239 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( 228 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
240 const base::string16& app_title, 229 const base::string16& app_title,
241 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, 230 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 content::WebContents* web_contents) { 294 content::WebContents* web_contents) {
306 if (IsInfoEmpty(shortcut_info_)) 295 if (IsInfoEmpty(shortcut_info_))
307 return true; 296 return true;
308 297
309 JNIEnv* env = base::android::AttachCurrentThread(); 298 JNIEnv* env = base::android::AttachCurrentThread();
310 299
311 // If the WebAPK is installed and the "Open" button is clicked, open the 300 // If the WebAPK is installed and the "Open" button is clicked, open the
312 // WebAPK. 301 // WebAPK.
313 if (install_state_ == INSTALLED) { 302 if (install_state_ == INSTALLED) {
314 Java_AppBannerInfoBarDelegateAndroid_openWebApk(env, java_delegate_); 303 Java_AppBannerInfoBarDelegateAndroid_openWebApk(env, java_delegate_);
315 if (is_webapk_already_installed_) 304 webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN);
316 webapk::TrackUserAction(webapk::USER_ACTION_OPEN);
317 else
318 webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN);
319 SendBannerAccepted(); 305 SendBannerAccepted();
320 return true; 306 return true;
321 } 307 }
322 308
323 // If the WebAPK is not installed and the "Add to Home Screen" button is 309 // If the WebAPK is not installed and the "Add to Home Screen" button is
324 // clicked, install the WebAPK. 310 // clicked, install the WebAPK.
325 timer_.reset(new base::ElapsedTimer()); 311 timer_.reset(new base::ElapsedTimer());
326 install_state_ = INSTALLING; 312 install_state_ = INSTALLING;
327 webapk::TrackInstallSource(webapk_install_source_); 313 webapk::TrackInstallSource(webapk_install_source_);
328 314
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 396
411 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents( 397 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents(
412 InstallState install_state) { 398 InstallState install_state) {
413 if (install_state == INSTALL_NOT_STARTED) { 399 if (install_state == INSTALL_NOT_STARTED) {
414 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION); 400 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION);
415 } else if (install_state == INSTALLING) { 401 } else if (install_state == INSTALLING) {
416 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION); 402 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION);
417 } else if (install_state == INSTALLED) { 403 } else if (install_state == INSTALLED) {
418 // If WebAPK is installed from this banner, TrackInstallEvent() is called in 404 // If WebAPK is installed from this banner, TrackInstallEvent() is called in
419 // OnWebApkInstallFinished(). 405 // OnWebApkInstallFinished().
420 if (is_webapk_already_installed_) 406 webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN_DISMISS);
421 webapk::TrackUserAction(webapk::USER_ACTION_OPEN_DISMISS);
422 else
423 webapk::TrackUserAction(webapk::USER_ACTION_INSTALLED_OPEN_DISMISS);
424 } 407 }
425 } 408 }
426 409
427 infobars::InfoBarDelegate::InfoBarIdentifier 410 infobars::InfoBarDelegate::InfoBarIdentifier
428 AppBannerInfoBarDelegateAndroid::GetIdentifier() const { 411 AppBannerInfoBarDelegateAndroid::GetIdentifier() const {
429 return APP_BANNER_INFOBAR_DELEGATE_ANDROID; 412 return APP_BANNER_INFOBAR_DELEGATE_ANDROID;
430 } 413 }
431 414
432 gfx::Image AppBannerInfoBarDelegateAndroid::GetIcon() const { 415 gfx::Image AppBannerInfoBarDelegateAndroid::GetIcon() const {
433 return gfx::Image::CreateFrom1xBitmap(*icon_.get()); 416 return gfx::Image::CreateFrom1xBitmap(*icon_.get());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 467
485 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); 468 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK);
486 return true; 469 return true;
487 } 470 }
488 471
489 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { 472 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) {
490 return RegisterNativesImpl(env); 473 return RegisterNativesImpl(env);
491 } 474 }
492 475
493 } // namespace banners 476 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/android/banners/app_banner_infobar_delegate_android.h ('k') | chrome/browser/android/webapk/webapk_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698