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); |
73 | 78 |
74 // ConfirmInfoBarDelegate: | 79 // ConfirmInfoBarDelegate: |
75 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 80 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
76 gfx::Image GetIcon() const override; | 81 gfx::Image GetIcon() const override; |
77 void InfoBarDismissed() override; | 82 void InfoBarDismissed() override; |
78 base::string16 GetMessageText() const override; | 83 base::string16 GetMessageText() const override; |
79 int GetButtons() const override; | 84 int GetButtons() const override; |
80 bool Accept() override; | 85 bool Accept() override; |
81 bool LinkClicked(WindowOpenDisposition disposition) override; | 86 bool LinkClicked(WindowOpenDisposition disposition) override; |
82 | 87 |
83 base::android::ScopedJavaGlobalRef<jobject> java_delegate_; | 88 base::android::ScopedJavaGlobalRef<jobject> java_delegate_; |
84 | 89 |
85 // Used to fetch the splash screen icon for webapps. | 90 // Used to fetch the splash screen icon for webapps. |
86 base::WeakPtr<AppBannerManager> weak_manager_; | 91 base::WeakPtr<AppBannerManager> weak_manager_; |
87 | 92 |
88 base::string16 app_title_; | 93 base::string16 app_title_; |
89 GURL manifest_url_; | 94 GURL manifest_url_; |
90 content::Manifest manifest_; | 95 content::Manifest manifest_; |
91 | 96 |
92 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; | 97 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; |
93 | 98 |
94 GURL icon_url_; | 99 GURL icon_url_; |
95 std::unique_ptr<SkBitmap> icon_; | 100 std::unique_ptr<SkBitmap> icon_; |
96 | 101 |
97 std::string native_app_package_; | 102 std::string native_app_package_; |
98 std::string referrer_; | 103 std::string referrer_; |
99 int event_request_id_; | 104 int event_request_id_; |
100 bool has_user_interaction_; | 105 bool has_user_interaction_; |
101 | 106 |
| 107 std::string webapk_package_name_; |
| 108 bool is_webapk_; |
| 109 |
| 110 base::WeakPtrFactory<AppBannerInfoBarDelegateAndroid> weak_ptr_factory_; |
| 111 |
102 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); | 112 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); |
103 }; // AppBannerInfoBarDelegateAndroid | 113 }; // AppBannerInfoBarDelegateAndroid |
104 | 114 |
105 // Register native methods. | 115 // Register native methods. |
106 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); | 116 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); |
107 | 117 |
108 } // namespace banners | 118 } // namespace banners |
109 | 119 |
110 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ | 120 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ |
OLD | NEW |