| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ |
| 6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ | 6 #define CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 jboolean success); | 72 jboolean success); |
| 73 | 73 |
| 74 // When user accepts to install a WebAPK, this function sends a request | 74 // When user accepts to install a WebAPK, this function sends a request |
| 75 // to the WebAPK Server to create a WebAPK and install it. It returns | 75 // to the WebAPK Server to create a WebAPK and install it. It returns |
| 76 // false to prevent infobar from disappearing when installation starts. | 76 // false to prevent infobar from disappearing when installation starts. |
| 77 // When user clicks the Open button after the intallation is compelete, this | 77 // When user clicks the Open button after the intallation is compelete, this |
| 78 // function launches the installed WebAPK and returns true. | 78 // function launches the installed WebAPK and returns true. |
| 79 bool AcceptWebApk(content::WebContents* web_contents); | 79 bool AcceptWebApk(content::WebContents* web_contents); |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 // The states of a WebAPK installation, where the infobar is displayed during |
| 83 // the entire installation process. This state is used to correctly record |
| 84 // UMA metrics. |
| 85 enum InstallState { |
| 86 INSTALL_NOT_STARTED, |
| 87 INSTALLING, |
| 88 INSTALLED, |
| 89 }; |
| 90 |
| 82 // Delegate for promoting a web app. | 91 // Delegate for promoting a web app. |
| 83 AppBannerInfoBarDelegateAndroid( | 92 AppBannerInfoBarDelegateAndroid( |
| 84 base::WeakPtr<AppBannerManager> weak_manager, | 93 base::WeakPtr<AppBannerManager> weak_manager, |
| 85 const base::string16& app_title, | 94 const base::string16& app_title, |
| 86 std::unique_ptr<ShortcutInfo> info, | 95 std::unique_ptr<ShortcutInfo> info, |
| 87 std::unique_ptr<SkBitmap> icon, | 96 std::unique_ptr<SkBitmap> icon, |
| 88 int event_request_id, | 97 int event_request_id, |
| 89 bool is_webapk); | 98 bool is_webapk); |
| 90 | 99 |
| 91 // Delegate for promoting an Android app. | 100 // Delegate for promoting an Android app. |
| 92 AppBannerInfoBarDelegateAndroid( | 101 AppBannerInfoBarDelegateAndroid( |
| 93 const base::string16& app_title, | 102 const base::string16& app_title, |
| 94 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, | 103 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, |
| 95 std::unique_ptr<SkBitmap> icon, | 104 std::unique_ptr<SkBitmap> icon, |
| 96 const std::string& native_app_package, | 105 const std::string& native_app_package, |
| 97 const std::string& referrer, | 106 const std::string& referrer, |
| 98 int event_request_id); | 107 int event_request_id); |
| 99 | 108 |
| 100 void CreateJavaDelegate(); | 109 void CreateJavaDelegate(); |
| 101 bool AcceptNativeApp(content::WebContents* web_contents); | 110 bool AcceptNativeApp(content::WebContents* web_contents); |
| 102 bool AcceptWebApp(content::WebContents* web_contents); | 111 bool AcceptWebApp(content::WebContents* web_contents); |
| 103 void SendBannerAccepted(content::WebContents* web_contents, | 112 void SendBannerAccepted(content::WebContents* web_contents, |
| 104 const std::string& platform); | 113 const std::string& platform); |
| 105 void OnWebApkInstallFinished(bool success, const std::string& webapk_package); | 114 void OnWebApkInstallFinished(bool success, const std::string& webapk_package); |
| 115 void TrackWebApkInstallationDismissEvents(InstallState install_state); |
| 106 | 116 |
| 107 // ConfirmInfoBarDelegate: | 117 // ConfirmInfoBarDelegate: |
| 108 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 118 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
| 109 gfx::Image GetIcon() const override; | 119 gfx::Image GetIcon() const override; |
| 110 void InfoBarDismissed() override; | 120 void InfoBarDismissed() override; |
| 111 base::string16 GetMessageText() const override; | 121 base::string16 GetMessageText() const override; |
| 112 int GetButtons() const override; | 122 int GetButtons() const override; |
| 113 bool Accept() override; | 123 bool Accept() override; |
| 114 bool LinkClicked(WindowOpenDisposition disposition) override; | 124 bool LinkClicked(WindowOpenDisposition disposition) override; |
| 115 | 125 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 126 std::unique_ptr<SkBitmap> icon_; | 136 std::unique_ptr<SkBitmap> icon_; |
| 127 | 137 |
| 128 std::string native_app_package_; | 138 std::string native_app_package_; |
| 129 std::string referrer_; | 139 std::string referrer_; |
| 130 int event_request_id_; | 140 int event_request_id_; |
| 131 bool has_user_interaction_; | 141 bool has_user_interaction_; |
| 132 | 142 |
| 133 std::string webapk_package_name_; | 143 std::string webapk_package_name_; |
| 134 bool is_webapk_; | 144 bool is_webapk_; |
| 135 | 145 |
| 146 // Indicates the current state of a WebAPK installation. |
| 147 InstallState install_state_; |
| 148 |
| 136 base::WeakPtrFactory<AppBannerInfoBarDelegateAndroid> weak_ptr_factory_; | 149 base::WeakPtrFactory<AppBannerInfoBarDelegateAndroid> weak_ptr_factory_; |
| 137 | 150 |
| 138 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); | 151 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); |
| 139 }; | 152 }; |
| 140 | 153 |
| 141 // Register native methods. | 154 // Register native methods. |
| 142 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); | 155 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); |
| 143 | 156 |
| 144 } // namespace banners | 157 } // namespace banners |
| 145 | 158 |
| 146 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ | 159 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ |
| OLD | NEW |