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

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

Powered by Google App Engine
This is Rietveld 408576698