| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // Manages installation of an app being promoted by a page. | 35 // Manages installation of an app being promoted by a page. |
| 36 class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { | 36 class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { |
| 37 public: | 37 public: |
| 38 // Creates an infobar and delegate for promoting the installation of a web | 38 // Creates an infobar and delegate for promoting the installation of a web |
| 39 // app, and adds the infobar to the InfoBarManager for |web_contents|. | 39 // app, and adds the infobar to the InfoBarManager for |web_contents|. |
| 40 static bool Create(content::WebContents* web_contents, | 40 static bool Create(content::WebContents* web_contents, |
| 41 base::WeakPtr<AppBannerManager> weak_manager, | 41 base::WeakPtr<AppBannerManager> weak_manager, |
| 42 std::unique_ptr<ShortcutInfo> info, | 42 std::unique_ptr<ShortcutInfo> info, |
| 43 const SkBitmap& primary_icon, | 43 const SkBitmap& primary_icon, |
| 44 const SkBitmap& badge_icon, | 44 const SkBitmap& badge_icon, |
| 45 int event_request_id, | |
| 46 bool is_webapk, | 45 bool is_webapk, |
| 47 webapk::InstallSource webapk_install_source); | 46 webapk::InstallSource webapk_install_source); |
| 48 | 47 |
| 49 // Creates an infobar and delegate for promoting the installation of an | 48 // Creates an infobar and delegate for promoting the installation of an |
| 50 // Android app, and adds the infobar to the InfoBarManager for |web_contents|. | 49 // Android app, and adds the infobar to the InfoBarManager for |web_contents|. |
| 51 static bool Create( | 50 static bool Create( |
| 52 content::WebContents* web_contents, | 51 content::WebContents* web_contents, |
| 53 const base::string16& app_title, | 52 const base::string16& app_title, |
| 54 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, | 53 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, |
| 55 const SkBitmap& icon, | 54 const SkBitmap& icon, |
| 56 const std::string& native_app_package, | 55 const std::string& native_app_package, |
| 57 const std::string& referrer, | 56 const std::string& referrer); |
| 58 int event_request_id); | |
| 59 | 57 |
| 60 ~AppBannerInfoBarDelegateAndroid() override; | 58 ~AppBannerInfoBarDelegateAndroid() override; |
| 61 | 59 |
| 62 // Called when the AppBannerInfoBarAndroid's button needs to be updated. | 60 // Called when the AppBannerInfoBarAndroid's button needs to be updated. |
| 63 void UpdateInstallState(JNIEnv* env, | 61 void UpdateInstallState(JNIEnv* env, |
| 64 const base::android::JavaParamRef<jobject>& obj); | 62 const base::android::JavaParamRef<jobject>& obj); |
| 65 | 63 |
| 66 // Called when the native app installation Intent has been handled and focus | 64 // Called when the native app installation Intent has been handled and focus |
| 67 // has been returned to Chrome. | 65 // has been returned to Chrome. |
| 68 void OnInstallIntentReturned(JNIEnv* env, | 66 void OnInstallIntentReturned(JNIEnv* env, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 89 INSTALLING, | 87 INSTALLING, |
| 90 INSTALLED, | 88 INSTALLED, |
| 91 }; | 89 }; |
| 92 | 90 |
| 93 // Delegate for promoting a web app. | 91 // Delegate for promoting a web app. |
| 94 AppBannerInfoBarDelegateAndroid( | 92 AppBannerInfoBarDelegateAndroid( |
| 95 base::WeakPtr<AppBannerManager> weak_manager, | 93 base::WeakPtr<AppBannerManager> weak_manager, |
| 96 std::unique_ptr<ShortcutInfo> info, | 94 std::unique_ptr<ShortcutInfo> info, |
| 97 const SkBitmap& primary_icon, | 95 const SkBitmap& primary_icon, |
| 98 const SkBitmap& badge_icon, | 96 const SkBitmap& badge_icon, |
| 99 int event_request_id, | |
| 100 bool is_webapk, | 97 bool is_webapk, |
| 101 webapk::InstallSource webapk_install_source); | 98 webapk::InstallSource webapk_install_source); |
| 102 | 99 |
| 103 // Delegate for promoting an Android app. | 100 // Delegate for promoting an Android app. |
| 104 AppBannerInfoBarDelegateAndroid( | 101 AppBannerInfoBarDelegateAndroid( |
| 105 const base::string16& app_title, | 102 const base::string16& app_title, |
| 106 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, | 103 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, |
| 107 const SkBitmap& icon, | 104 const SkBitmap& icon, |
| 108 const std::string& native_app_package, | 105 const std::string& native_app_package, |
| 109 const std::string& referrer, | 106 const std::string& referrer); |
| 110 int event_request_id); | |
| 111 | 107 |
| 112 void CreateJavaDelegate(); | 108 void CreateJavaDelegate(); |
| 113 bool AcceptNativeApp(content::WebContents* web_contents); | 109 bool AcceptNativeApp(content::WebContents* web_contents); |
| 114 bool AcceptWebApp(content::WebContents* web_contents); | 110 bool AcceptWebApp(content::WebContents* web_contents); |
| 115 | 111 |
| 116 // Called when the OK button on a WebAPK infobar is pressed. If the WebAPK is | 112 // Called when the OK button on a WebAPK infobar is pressed. If the WebAPK is |
| 117 // already installed, opens it; otherwise, installs it. Returns whether the | 113 // already installed, opens it; otherwise, installs it. Returns whether the |
| 118 // infobar should be closed as a result of the button press. | 114 // infobar should be closed as a result of the button press. |
| 119 bool AcceptWebApk(content::WebContents* web_contents); | 115 bool AcceptWebApk(content::WebContents* web_contents); |
| 120 | 116 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 151 base::string16 app_title_; | 147 base::string16 app_title_; |
| 152 std::unique_ptr<ShortcutInfo> shortcut_info_; | 148 std::unique_ptr<ShortcutInfo> shortcut_info_; |
| 153 | 149 |
| 154 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; | 150 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; |
| 155 | 151 |
| 156 const SkBitmap primary_icon_; | 152 const SkBitmap primary_icon_; |
| 157 const SkBitmap badge_icon_; | 153 const SkBitmap badge_icon_; |
| 158 | 154 |
| 159 std::string native_app_package_; | 155 std::string native_app_package_; |
| 160 std::string referrer_; | 156 std::string referrer_; |
| 161 int event_request_id_; | |
| 162 bool has_user_interaction_; | 157 bool has_user_interaction_; |
| 163 | 158 |
| 164 bool is_webapk_; | 159 bool is_webapk_; |
| 165 | 160 |
| 166 // Indicates the current state of a WebAPK installation. | 161 // Indicates the current state of a WebAPK installation. |
| 167 InstallState install_state_; | 162 InstallState install_state_; |
| 168 | 163 |
| 169 // Indicates the way in which a WebAPK (if applicable) is installed: from the | 164 // Indicates the way in which a WebAPK (if applicable) is installed: from the |
| 170 // menu or from an app banner. | 165 // menu or from an app banner. |
| 171 webapk::InstallSource webapk_install_source_; | 166 webapk::InstallSource webapk_install_source_; |
| 172 | 167 |
| 173 base::WeakPtrFactory<AppBannerInfoBarDelegateAndroid> weak_ptr_factory_; | 168 base::WeakPtrFactory<AppBannerInfoBarDelegateAndroid> weak_ptr_factory_; |
| 174 | 169 |
| 175 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); | 170 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); |
| 176 }; | 171 }; |
| 177 | 172 |
| 178 // Register native methods. | 173 // Register native methods. |
| 179 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); | 174 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); |
| 180 | 175 |
| 181 } // namespace banners | 176 } // namespace banners |
| 182 | 177 |
| 183 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ | 178 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ |
| OLD | NEW |