| 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 20 matching lines...) Expand all Loading... |
| 31 class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { | 31 class AppBannerInfoBarDelegateAndroid : public ConfirmInfoBarDelegate { |
| 32 public: | 32 public: |
| 33 // Delegate for promoting a web app. | 33 // Delegate for promoting a web app. |
| 34 AppBannerInfoBarDelegateAndroid( | 34 AppBannerInfoBarDelegateAndroid( |
| 35 base::WeakPtr<AppBannerManager> weak_manager, | 35 base::WeakPtr<AppBannerManager> weak_manager, |
| 36 const base::string16& app_title, | 36 const base::string16& app_title, |
| 37 const GURL& manifest_url, | 37 const GURL& manifest_url, |
| 38 const content::Manifest& manifest, | 38 const content::Manifest& manifest, |
| 39 const GURL& icon_url, | 39 const GURL& icon_url, |
| 40 std::unique_ptr<SkBitmap> icon, | 40 std::unique_ptr<SkBitmap> icon, |
| 41 int event_request_id); | 41 int event_request_id, |
| 42 bool is_webapk); |
| 42 | 43 |
| 43 // Delegate for promoting an Android app. | 44 // Delegate for promoting an Android app. |
| 44 AppBannerInfoBarDelegateAndroid( | 45 AppBannerInfoBarDelegateAndroid( |
| 45 const base::string16& app_title, | 46 const base::string16& app_title, |
| 46 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, | 47 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, |
| 47 std::unique_ptr<SkBitmap> icon, | 48 std::unique_ptr<SkBitmap> icon, |
| 48 const std::string& native_app_package, | 49 const std::string& native_app_package, |
| 49 const std::string& referrer, | 50 const std::string& referrer, |
| 50 int event_request_id); | 51 int event_request_id); |
| 51 | 52 |
| 52 ~AppBannerInfoBarDelegateAndroid() override; | 53 ~AppBannerInfoBarDelegateAndroid() override; |
| 53 | 54 |
| 54 // Called when the AppBannerInfoBar's button needs to be updated. | 55 // Called when the AppBannerInfoBar's button needs to be updated. |
| 55 void UpdateInstallState(JNIEnv* env, | 56 void UpdateInstallState(JNIEnv* env, |
| 56 const base::android::JavaParamRef<jobject>& obj); | 57 const base::android::JavaParamRef<jobject>& obj); |
| 57 | 58 |
| 58 // Called when the installation Intent has been handled and focus has been | 59 // Called when the installation Intent has been handled and focus has been |
| 59 // returned to Chrome. | 60 // returned to Chrome. |
| 60 void OnInstallIntentReturned(JNIEnv* env, | 61 void OnInstallIntentReturned(JNIEnv* env, |
| 61 const base::android::JavaParamRef<jobject>& obj, | 62 const base::android::JavaParamRef<jobject>& obj, |
| 62 jboolean jis_installing); | 63 jboolean jis_installing); |
| 63 | 64 |
| 64 // Called when the InstallerDelegate task has finished. | 65 // Called when the InstallerDelegate task has finished. |
| 65 void OnInstallFinished(JNIEnv* env, | 66 void OnInstallFinished(JNIEnv* env, |
| 66 const base::android::JavaParamRef<jobject>& obj, | 67 const base::android::JavaParamRef<jobject>& obj, |
| 67 jboolean success); | 68 jboolean success); |
| 68 | 69 |
| 69 private: | 70 private: |
| 70 void CreateJavaDelegate(); | 71 void CreateJavaDelegate(); |
| 72 bool AcceptNativeApp(content::WebContents* web_contents); |
| 73 bool AcceptWebApp(content::WebContents* web_contents); |
| 74 bool AcceptWebApk(content::WebContents* web_contents); |
| 71 void SendBannerAccepted(content::WebContents* web_contents, | 75 void SendBannerAccepted(content::WebContents* web_contents, |
| 72 const std::string& platform); | 76 const std::string& platform); |
| 77 void OnWebApkInstallFinished(bool success, const std::string& webapk_package); |
| 78 void RemoveInfoBarOnUIThread(); |
| 73 | 79 |
| 74 // ConfirmInfoBarDelegate: | 80 // ConfirmInfoBarDelegate: |
| 75 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 81 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
| 76 gfx::Image GetIcon() const override; | 82 gfx::Image GetIcon() const override; |
| 77 void InfoBarDismissed() override; | 83 void InfoBarDismissed() override; |
| 78 base::string16 GetMessageText() const override; | 84 base::string16 GetMessageText() const override; |
| 79 int GetButtons() const override; | 85 int GetButtons() const override; |
| 80 bool Accept() override; | 86 bool Accept() override; |
| 81 bool LinkClicked(WindowOpenDisposition disposition) override; | 87 bool LinkClicked(WindowOpenDisposition disposition) override; |
| 82 | 88 |
| 83 base::android::ScopedJavaGlobalRef<jobject> java_delegate_; | 89 base::android::ScopedJavaGlobalRef<jobject> java_delegate_; |
| 84 | 90 |
| 85 // Used to fetch the splash screen icon for webapps. | 91 // Used to fetch the splash screen icon for webapps. |
| 86 base::WeakPtr<AppBannerManager> weak_manager_; | 92 base::WeakPtr<AppBannerManager> weak_manager_; |
| 87 | 93 |
| 88 base::string16 app_title_; | 94 base::string16 app_title_; |
| 89 GURL manifest_url_; | 95 GURL manifest_url_; |
| 90 content::Manifest manifest_; | 96 content::Manifest manifest_; |
| 91 | 97 |
| 92 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; | 98 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; |
| 93 | 99 |
| 94 GURL icon_url_; | 100 GURL icon_url_; |
| 95 std::unique_ptr<SkBitmap> icon_; | 101 std::unique_ptr<SkBitmap> icon_; |
| 96 | 102 |
| 97 std::string native_app_package_; | 103 std::string native_app_package_; |
| 98 std::string referrer_; | 104 std::string referrer_; |
| 99 int event_request_id_; | 105 int event_request_id_; |
| 100 bool has_user_interaction_; | 106 bool has_user_interaction_; |
| 101 | 107 |
| 108 std::string webapk_package_name_; |
| 109 bool is_webapk_; |
| 110 |
| 102 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); | 111 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); |
| 103 }; // AppBannerInfoBarDelegateAndroid | 112 }; // AppBannerInfoBarDelegateAndroid |
| 104 | 113 |
| 105 // Register native methods. | 114 // Register native methods. |
| 106 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); | 115 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); |
| 107 | 116 |
| 108 } // namespace banners | 117 } // namespace banners |
| 109 | 118 |
| 110 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ | 119 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ |
| OLD | NEW |