| 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 |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "chrome/browser/android/webapk/webapk_metrics.h" | 15 #include "chrome/browser/android/webapk/webapk_metrics.h" |
| 16 #include "components/infobars/core/confirm_infobar_delegate.h" | 16 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" |
| 17 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 class WebContents; | 21 class WebContents; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace infobars { | 24 namespace infobars { |
| 24 class InfoBarManager; | 25 class InfoBarManager; |
| 25 } | 26 } |
| 26 | 27 |
| 27 enum class WebApkInstallResult; | 28 enum class WebApkInstallResult; |
| 28 struct ShortcutInfo; | 29 struct ShortcutInfo; |
| 29 | 30 |
| 30 namespace banners { | 31 namespace banners { |
| 31 | 32 |
| 32 class AppBannerManager; | 33 class AppBannerManager; |
| 33 | 34 |
| 34 // Manages installation of an app being promoted by a page. | 35 // Manages installation of an app being promoted by a page. |
| 35 class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { | 36 class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { |
| 36 public: | 37 public: |
| 37 // 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 |
| 38 // app, and adds the infobar to the InfoBarManager for |web_contents|. | 39 // app, and adds the infobar to the InfoBarManager for |web_contents|. |
| 39 static bool Create( | 40 static bool Create(content::WebContents* web_contents, |
| 40 content::WebContents* web_contents, | 41 base::WeakPtr<AppBannerManager> weak_manager, |
| 41 base::WeakPtr<AppBannerManager> weak_manager, | 42 const base::string16& app_title, |
| 42 const base::string16& app_title, | 43 std::unique_ptr<ShortcutInfo> info, |
| 43 std::unique_ptr<ShortcutInfo> info, | 44 const SkBitmap& primary_icon, |
| 44 std::unique_ptr<SkBitmap> icon, | 45 const SkBitmap& badge_icon, |
| 45 int event_request_id, | 46 int event_request_id, |
| 46 webapk::InstallSource webapk_install_source); | 47 webapk::InstallSource webapk_install_source); |
| 47 | 48 |
| 48 // Creates an infobar and delegate for promoting the installation of an | 49 // Creates an infobar and delegate for promoting the installation of an |
| 49 // Android app, and adds the infobar to the InfoBarManager for |web_contents|. | 50 // Android app, and adds the infobar to the InfoBarManager for |web_contents|. |
| 50 static bool Create( | 51 static bool Create( |
| 51 content::WebContents* web_contents, | 52 content::WebContents* web_contents, |
| 52 const base::string16& app_title, | 53 const base::string16& app_title, |
| 53 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, | 54 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, |
| 54 std::unique_ptr<SkBitmap> icon, | 55 const SkBitmap& icon, |
| 55 const std::string& native_app_package, | 56 const std::string& native_app_package, |
| 56 const std::string& referrer, | 57 const std::string& referrer, |
| 57 int event_request_id); | 58 int event_request_id); |
| 58 | 59 |
| 59 ~AppBannerInfoBarDelegateAndroid() override; | 60 ~AppBannerInfoBarDelegateAndroid() override; |
| 60 | 61 |
| 61 // Called when the AppBannerInfoBarAndroid's button needs to be updated. | 62 // Called when the AppBannerInfoBarAndroid's button needs to be updated. |
| 62 void UpdateInstallState(JNIEnv* env, | 63 void UpdateInstallState(JNIEnv* env, |
| 63 const base::android::JavaParamRef<jobject>& obj); | 64 const base::android::JavaParamRef<jobject>& obj); |
| 64 | 65 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 87 INSTALL_NOT_STARTED, | 88 INSTALL_NOT_STARTED, |
| 88 INSTALLING, | 89 INSTALLING, |
| 89 INSTALLED, | 90 INSTALLED, |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 // Delegate for promoting a web app. | 93 // Delegate for promoting a web app. |
| 93 AppBannerInfoBarDelegateAndroid( | 94 AppBannerInfoBarDelegateAndroid( |
| 94 base::WeakPtr<AppBannerManager> weak_manager, | 95 base::WeakPtr<AppBannerManager> weak_manager, |
| 95 const base::string16& app_title, | 96 const base::string16& app_title, |
| 96 std::unique_ptr<ShortcutInfo> info, | 97 std::unique_ptr<ShortcutInfo> info, |
| 97 std::unique_ptr<SkBitmap> icon, | 98 const SkBitmap& primary_icon, |
| 99 const SkBitmap& badge_icon, |
| 98 int event_request_id, | 100 int event_request_id, |
| 99 bool is_webapk, | 101 bool is_webapk, |
| 100 webapk::InstallSource webapk_install_source); | 102 webapk::InstallSource webapk_install_source); |
| 101 | 103 |
| 102 // Delegate for promoting an Android app. | 104 // Delegate for promoting an Android app. |
| 103 AppBannerInfoBarDelegateAndroid( | 105 AppBannerInfoBarDelegateAndroid( |
| 104 const base::string16& app_title, | 106 const base::string16& app_title, |
| 105 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, | 107 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, |
| 106 std::unique_ptr<SkBitmap> icon, | 108 const SkBitmap& icon, |
| 107 const std::string& native_app_package, | 109 const std::string& native_app_package, |
| 108 const std::string& referrer, | 110 const std::string& referrer, |
| 109 int event_request_id); | 111 int event_request_id); |
| 110 | 112 |
| 111 void CreateJavaDelegate(); | 113 void CreateJavaDelegate(); |
| 112 bool AcceptNativeApp(content::WebContents* web_contents); | 114 bool AcceptNativeApp(content::WebContents* web_contents); |
| 113 bool AcceptWebApp(content::WebContents* web_contents); | 115 bool AcceptWebApp(content::WebContents* web_contents); |
| 114 | 116 |
| 115 // Called when the OK button on a WebAPK infobar is pressed. If the WebAPK is | 117 // Called when the OK button on a WebAPK infobar is pressed. If the WebAPK is |
| 116 // already installed, opens it; otherwise, installs it. Returns whether the | 118 // already installed, opens it; otherwise, installs it. Returns whether the |
| (...skipping 24 matching lines...) Expand all Loading... |
| 141 base::android::ScopedJavaGlobalRef<jobject> java_delegate_; | 143 base::android::ScopedJavaGlobalRef<jobject> java_delegate_; |
| 142 | 144 |
| 143 // Used to fetch the splash screen icon for webapps. | 145 // Used to fetch the splash screen icon for webapps. |
| 144 base::WeakPtr<AppBannerManager> weak_manager_; | 146 base::WeakPtr<AppBannerManager> weak_manager_; |
| 145 | 147 |
| 146 base::string16 app_title_; | 148 base::string16 app_title_; |
| 147 std::unique_ptr<ShortcutInfo> shortcut_info_; | 149 std::unique_ptr<ShortcutInfo> shortcut_info_; |
| 148 | 150 |
| 149 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; | 151 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; |
| 150 | 152 |
| 151 std::unique_ptr<SkBitmap> icon_; | 153 const SkBitmap primary_icon_; |
| 154 const SkBitmap badge_icon_; |
| 152 | 155 |
| 153 std::string native_app_package_; | 156 std::string native_app_package_; |
| 154 std::string referrer_; | 157 std::string referrer_; |
| 155 int event_request_id_; | 158 int event_request_id_; |
| 156 bool has_user_interaction_; | 159 bool has_user_interaction_; |
| 157 | 160 |
| 158 bool is_webapk_; | 161 bool is_webapk_; |
| 159 | 162 |
| 160 // Indicates the current state of a WebAPK installation. | 163 // Indicates the current state of a WebAPK installation. |
| 161 InstallState install_state_; | 164 InstallState install_state_; |
| 162 | 165 |
| 163 // Indicates the way in which a WebAPK (if applicable) is installed: from the | 166 // Indicates the way in which a WebAPK (if applicable) is installed: from the |
| 164 // menu or from an app banner. | 167 // menu or from an app banner. |
| 165 webapk::InstallSource webapk_install_source_; | 168 webapk::InstallSource webapk_install_source_; |
| 166 | 169 |
| 167 base::WeakPtrFactory<AppBannerInfoBarDelegateAndroid> weak_ptr_factory_; | 170 base::WeakPtrFactory<AppBannerInfoBarDelegateAndroid> weak_ptr_factory_; |
| 168 | 171 |
| 169 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); | 172 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); |
| 170 }; | 173 }; |
| 171 | 174 |
| 172 // Register native methods. | 175 // Register native methods. |
| 173 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); | 176 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); |
| 174 | 177 |
| 175 } // namespace banners | 178 } // namespace banners |
| 176 | 179 |
| 177 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ | 180 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ |
| OLD | NEW |