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

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: Creating url variable 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 = ""; 58 const GURL url = shortcut_info->url;
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 = 59 auto infobar_delegate =
64 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid( 60 base::WrapUnique(new banners::AppBannerInfoBarDelegateAndroid(
65 weak_manager, app_title, std::move(shortcut_info), std::move(icon), 61 weak_manager, app_title, std::move(shortcut_info), std::move(icon),
66 event_request_id, is_webapk, is_webapk_already_installed, 62 event_request_id, is_webapk, webapk_install_source));
67 webapk_install_source));
68 auto* raw_delegate = infobar_delegate.get(); 63 auto* raw_delegate = infobar_delegate.get();
69 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>( 64 auto infobar = base::MakeUnique<AppBannerInfoBarAndroid>(
70 std::move(infobar_delegate), url, is_webapk); 65 std::move(infobar_delegate), url, is_webapk);
71 if (!InfoBarService::FromWebContents(web_contents) 66 if (!InfoBarService::FromWebContents(web_contents)
72 ->AddInfoBar(std::move(infobar))) 67 ->AddInfoBar(std::move(infobar)))
73 return false; 68 return false;
74 69
75 if (is_webapk) { 70 if (is_webapk) {
76 if (webapk_install_source == webapk::INSTALL_SOURCE_MENU) { 71 if (webapk_install_source == webapk::INSTALL_SOURCE_MENU) {
77 webapk::TrackInstallInfoBarShown( 72 webapk::TrackInstallInfoBarShown(
78 webapk::WEBAPK_INFOBAR_SHOWN_FROM_MENU); 73 webapk::WEBAPK_INFOBAR_SHOWN_FROM_MENU);
79 if (is_webapk_already_installed) 74 raw_delegate->Accept();
80 raw_delegate->UpdateStateForInstalledWebAPK(webapk_package_name);
81 else
82 raw_delegate->Accept();
83 } else { 75 } else {
84 webapk::TrackInstallInfoBarShown( 76 webapk::TrackInstallInfoBarShown(
85 webapk::WEBAPK_INFOBAR_SHOWN_FROM_BANNER); 77 webapk::WEBAPK_INFOBAR_SHOWN_FROM_BANNER);
86 } 78 }
87 } 79 }
88 80
89 return true; 81 return true;
90 } 82 }
91 83
92 // static 84 // static
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 install_state_ = INSTALLED; 204 install_state_ = INSTALLED;
213 } 205 }
214 206
215 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( 207 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
216 base::WeakPtr<AppBannerManager> weak_manager, 208 base::WeakPtr<AppBannerManager> weak_manager,
217 const base::string16& app_title, 209 const base::string16& app_title,
218 std::unique_ptr<ShortcutInfo> shortcut_info, 210 std::unique_ptr<ShortcutInfo> shortcut_info,
219 std::unique_ptr<SkBitmap> icon, 211 std::unique_ptr<SkBitmap> icon,
220 int event_request_id, 212 int event_request_id,
221 bool is_webapk, 213 bool is_webapk,
222 bool is_webapk_already_installed,
223 webapk::InstallSource webapk_install_source) 214 webapk::InstallSource webapk_install_source)
224 : weak_manager_(weak_manager), 215 : weak_manager_(weak_manager),
225 app_title_(app_title), 216 app_title_(app_title),
226 shortcut_info_(std::move(shortcut_info)), 217 shortcut_info_(std::move(shortcut_info)),
227 icon_(std::move(icon)), 218 icon_(std::move(icon)),
228 event_request_id_(event_request_id), 219 event_request_id_(event_request_id),
229 has_user_interaction_(false), 220 has_user_interaction_(false),
230 is_webapk_(is_webapk), 221 is_webapk_(is_webapk),
231 is_webapk_already_installed_(is_webapk_already_installed),
232 install_state_(INSTALL_NOT_STARTED), 222 install_state_(INSTALL_NOT_STARTED),
233 webapk_install_source_(webapk_install_source), 223 webapk_install_source_(webapk_install_source),
234 weak_ptr_factory_(this) { 224 weak_ptr_factory_(this) {
235 DCHECK(!IsInfoEmpty(shortcut_info_)); 225 DCHECK(!IsInfoEmpty(shortcut_info_));
236 CreateJavaDelegate(); 226 CreateJavaDelegate();
237 } 227 }
238 228
239 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid( 229 AppBannerInfoBarDelegateAndroid::AppBannerInfoBarDelegateAndroid(
240 const base::string16& app_title, 230 const base::string16& app_title,
241 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, 231 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) { 295 content::WebContents* web_contents) {
306 if (IsInfoEmpty(shortcut_info_)) 296 if (IsInfoEmpty(shortcut_info_))
307 return true; 297 return true;
308 298
309 JNIEnv* env = base::android::AttachCurrentThread(); 299 JNIEnv* env = base::android::AttachCurrentThread();
310 300
311 // If the WebAPK is installed and the "Open" button is clicked, open the 301 // If the WebAPK is installed and the "Open" button is clicked, open the
312 // WebAPK. 302 // WebAPK.
313 if (install_state_ == INSTALLED) { 303 if (install_state_ == INSTALLED) {
314 Java_AppBannerInfoBarDelegateAndroid_openWebApk(env, java_delegate_); 304 Java_AppBannerInfoBarDelegateAndroid_openWebApk(env, java_delegate_);
315 if (is_webapk_already_installed_) 305 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(); 306 SendBannerAccepted();
320 return true; 307 return true;
321 } 308 }
322 309
323 // If the WebAPK is not installed and the "Add to Home Screen" button is 310 // If the WebAPK is not installed and the "Add to Home Screen" button is
324 // clicked, install the WebAPK. 311 // clicked, install the WebAPK.
325 timer_.reset(new base::ElapsedTimer()); 312 timer_.reset(new base::ElapsedTimer());
326 install_state_ = INSTALLING; 313 install_state_ = INSTALLING;
327 webapk::TrackInstallSource(webapk_install_source_); 314 webapk::TrackInstallSource(webapk_install_source_);
328 315
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 397
411 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents( 398 void AppBannerInfoBarDelegateAndroid::TrackWebApkInstallationDismissEvents(
412 InstallState install_state) { 399 InstallState install_state) {
413 if (install_state == INSTALL_NOT_STARTED) { 400 if (install_state == INSTALL_NOT_STARTED) {
414 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION); 401 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_BEFORE_INSTALLATION);
415 } else if (install_state == INSTALLING) { 402 } else if (install_state == INSTALLING) {
416 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION); 403 webapk::TrackInstallEvent(webapk::INFOBAR_DISMISSED_DURING_INSTALLATION);
417 } else if (install_state == INSTALLED) { 404 } else if (install_state == INSTALLED) {
418 // If WebAPK is installed from this banner, TrackInstallEvent() is called in 405 // If WebAPK is installed from this banner, TrackInstallEvent() is called in
419 // OnWebApkInstallFinished(). 406 // OnWebApkInstallFinished().
420 if (is_webapk_already_installed_) 407 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 } 408 }
425 } 409 }
426 410
427 infobars::InfoBarDelegate::InfoBarIdentifier 411 infobars::InfoBarDelegate::InfoBarIdentifier
428 AppBannerInfoBarDelegateAndroid::GetIdentifier() const { 412 AppBannerInfoBarDelegateAndroid::GetIdentifier() const {
429 return APP_BANNER_INFOBAR_DELEGATE_ANDROID; 413 return APP_BANNER_INFOBAR_DELEGATE_ANDROID;
430 } 414 }
431 415
432 gfx::Image AppBannerInfoBarDelegateAndroid::GetIcon() const { 416 gfx::Image AppBannerInfoBarDelegateAndroid::GetIcon() const {
433 return gfx::Image::CreateFrom1xBitmap(*icon_.get()); 417 return gfx::Image::CreateFrom1xBitmap(*icon_.get());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 468
485 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); 469 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK);
486 return true; 470 return true;
487 } 471 }
488 472
489 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { 473 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) {
490 return RegisterNativesImpl(env); 474 return RegisterNativesImpl(env);
491 } 475 }
492 476
493 } // namespace banners 477 } // 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