Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: chrome/browser/android/banners/app_banner_infobar_delegate_android.h

Issue 2375503003: Pass WebAPK install source to AppBannerInfobarDelegateAndroid constructor. (Closed)
Patch Set: pkotwicz@'s comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/android/banners/app_banner_infobar_delegate_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "chrome/browser/android/webapk/webapk_metrics.h"
12 #include "chrome/browser/banners/app_banner_manager.h" 13 #include "chrome/browser/banners/app_banner_manager.h"
13 #include "components/infobars/core/confirm_infobar_delegate.h" 14 #include "components/infobars/core/confirm_infobar_delegate.h"
14 #include "ui/gfx/image/image.h" 15 #include "ui/gfx/image/image.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 namespace content { 18 namespace content {
18 class WebContents; 19 class WebContents;
19 } 20 }
20 21
21 namespace infobars { 22 namespace infobars {
(...skipping 11 matching lines...) Expand all
33 // Creates an infobar and delegate for promoting the installation of a web 34 // Creates an infobar and delegate for promoting the installation of a web
34 // app, and adds the infobar to the InfoBarManager for |web_contents|. 35 // app, and adds the infobar to the InfoBarManager for |web_contents|.
35 static bool Create( 36 static bool Create(
36 content::WebContents* web_contents, 37 content::WebContents* web_contents,
37 base::WeakPtr<AppBannerManager> weak_manager, 38 base::WeakPtr<AppBannerManager> weak_manager,
38 const base::string16& app_title, 39 const base::string16& app_title,
39 std::unique_ptr<ShortcutInfo> info, 40 std::unique_ptr<ShortcutInfo> info,
40 std::unique_ptr<SkBitmap> icon, 41 std::unique_ptr<SkBitmap> icon,
41 int event_request_id, 42 int event_request_id,
42 bool is_webapk, 43 bool is_webapk,
43 bool start_install_webapk); 44 webapk::InstallSource webapk_install_source);
44 45
45 // Creates and shows the infobar for an Android app. 46 // Creates and shows the infobar for an Android app.
46 // Creates an infobar and delegate for promoting the installation of an 47 // Creates an infobar and delegate for promoting the installation of an
47 // Android app, and adds the infobar to the InfoBarManager for |web_contents|. 48 // Android app, and adds the infobar to the InfoBarManager for |web_contents|.
48 static bool Create( 49 static bool Create(
49 content::WebContents* web_contents, 50 content::WebContents* web_contents,
50 const base::string16& app_title, 51 const base::string16& app_title,
51 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, 52 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data,
52 std::unique_ptr<SkBitmap> icon, 53 std::unique_ptr<SkBitmap> icon,
53 const std::string& native_app_package, 54 const std::string& native_app_package,
(...skipping 10 matching lines...) Expand all
64 // returned to Chrome. 65 // returned to Chrome.
65 void OnInstallIntentReturned(JNIEnv* env, 66 void OnInstallIntentReturned(JNIEnv* env,
66 const base::android::JavaParamRef<jobject>& obj, 67 const base::android::JavaParamRef<jobject>& obj,
67 jboolean jis_installing); 68 jboolean jis_installing);
68 69
69 // Called when the InstallerDelegate task has finished. 70 // Called when the InstallerDelegate task has finished.
70 void OnInstallFinished(JNIEnv* env, 71 void OnInstallFinished(JNIEnv* env,
71 const base::android::JavaParamRef<jobject>& obj, 72 const base::android::JavaParamRef<jobject>& obj,
72 jboolean success); 73 jboolean success);
73 74
74 // When user accepts to install a WebAPK, this function sends a request 75 // ConfirmInfoBarDelegate:
dominickn 2016/09/27 01:36:55 Does this method need to be public? If it's only b
Xi Han 2016/09/27 13:44:04 Well, it has to be public. The AppBannerInfoBarDel
75 // to the WebAPK Server to create a WebAPK and install it. It returns 76 bool Accept() override;
76 // false to prevent infobar from disappearing when installation starts.
77 // When user clicks the Open button after the intallation is compelete, this
78 // function launches the installed WebAPK and returns true.
79 bool AcceptWebApk(content::WebContents* web_contents);
80 77
81 private: 78 private:
82 // The states of a WebAPK installation, where the infobar is displayed during 79 // The states of a WebAPK installation, where the infobar is displayed during
83 // the entire installation process. This state is used to correctly record 80 // the entire installation process. This state is used to correctly record
84 // UMA metrics. 81 // UMA metrics.
85 enum InstallState { 82 enum InstallState {
86 INSTALL_NOT_STARTED, 83 INSTALL_NOT_STARTED,
87 INSTALLING, 84 INSTALLING,
88 INSTALLED, 85 INSTALLED,
89 }; 86 };
90 87
91 // Delegate for promoting a web app. 88 // Delegate for promoting a web app.
92 AppBannerInfoBarDelegateAndroid( 89 AppBannerInfoBarDelegateAndroid(
93 base::WeakPtr<AppBannerManager> weak_manager, 90 base::WeakPtr<AppBannerManager> weak_manager,
94 const base::string16& app_title, 91 const base::string16& app_title,
95 std::unique_ptr<ShortcutInfo> info, 92 std::unique_ptr<ShortcutInfo> info,
96 std::unique_ptr<SkBitmap> icon, 93 std::unique_ptr<SkBitmap> icon,
97 int event_request_id, 94 int event_request_id,
98 bool is_webapk); 95 bool is_webapk,
96 webapk::InstallSource webapk_install_source);
99 97
100 // Delegate for promoting an Android app. 98 // Delegate for promoting an Android app.
101 AppBannerInfoBarDelegateAndroid( 99 AppBannerInfoBarDelegateAndroid(
102 const base::string16& app_title, 100 const base::string16& app_title,
103 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data, 101 const base::android::ScopedJavaGlobalRef<jobject>& native_app_data,
104 std::unique_ptr<SkBitmap> icon, 102 std::unique_ptr<SkBitmap> icon,
105 const std::string& native_app_package, 103 const std::string& native_app_package,
106 const std::string& referrer, 104 const std::string& referrer,
107 int event_request_id); 105 int event_request_id);
108 106
109 void CreateJavaDelegate(); 107 void CreateJavaDelegate();
110 bool AcceptNativeApp(content::WebContents* web_contents); 108 bool AcceptNativeApp(content::WebContents* web_contents);
111 bool AcceptWebApp(content::WebContents* web_contents); 109 bool AcceptWebApp(content::WebContents* web_contents);
110
111 // When user accepts to install a WebAPK, this function sends a request
112 // to the WebAPK Server to create a WebAPK and install it. It returns
113 // false to prevent infobar from disappearing when installation starts.
114 // When user clicks the Open button after the intallation is compelete, this
115 // function launches the installed WebAPK and returns true.
116 bool AcceptWebApk(content::WebContents* web_contents);
117
112 void SendBannerAccepted(content::WebContents* web_contents, 118 void SendBannerAccepted(content::WebContents* web_contents,
113 const std::string& platform); 119 const std::string& platform);
114 void OnWebApkInstallFinished(bool success, const std::string& webapk_package); 120 void OnWebApkInstallFinished(bool success, const std::string& webapk_package);
115 void TrackWebApkInstallationDismissEvents(InstallState install_state); 121 void TrackWebApkInstallationDismissEvents(InstallState install_state);
116 122
117 // ConfirmInfoBarDelegate: 123 // ConfirmInfoBarDelegate:
118 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; 124 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
119 gfx::Image GetIcon() const override; 125 gfx::Image GetIcon() const override;
120 void InfoBarDismissed() override; 126 void InfoBarDismissed() override;
121 base::string16 GetMessageText() const override; 127 base::string16 GetMessageText() const override;
122 int GetButtons() const override; 128 int GetButtons() const override;
123 bool Accept() override;
124 bool LinkClicked(WindowOpenDisposition disposition) override; 129 bool LinkClicked(WindowOpenDisposition disposition) override;
125 130
126 base::android::ScopedJavaGlobalRef<jobject> java_delegate_; 131 base::android::ScopedJavaGlobalRef<jobject> java_delegate_;
127 132
128 // Used to fetch the splash screen icon for webapps. 133 // Used to fetch the splash screen icon for webapps.
129 base::WeakPtr<AppBannerManager> weak_manager_; 134 base::WeakPtr<AppBannerManager> weak_manager_;
130 135
131 base::string16 app_title_; 136 base::string16 app_title_;
132 std::unique_ptr<ShortcutInfo> shortcut_info_; 137 std::unique_ptr<ShortcutInfo> shortcut_info_;
133 138
134 base::android::ScopedJavaGlobalRef<jobject> native_app_data_; 139 base::android::ScopedJavaGlobalRef<jobject> native_app_data_;
135 140
136 std::unique_ptr<SkBitmap> icon_; 141 std::unique_ptr<SkBitmap> icon_;
137 142
138 std::string native_app_package_; 143 std::string native_app_package_;
139 std::string referrer_; 144 std::string referrer_;
140 int event_request_id_; 145 int event_request_id_;
141 bool has_user_interaction_; 146 bool has_user_interaction_;
142 147
143 std::string webapk_package_name_; 148 std::string webapk_package_name_;
144 bool is_webapk_; 149 bool is_webapk_;
145 150
146 // Indicates the current state of a WebAPK installation. 151 // Indicates the current state of a WebAPK installation.
147 InstallState install_state_; 152 InstallState install_state_;
148 153
154 // Indicates the way in which a WebAPK (if applicable) is installed: from the
155 // menu or from an app banner.
156 webapk::InstallSource webapk_install_source_;
157
149 base::WeakPtrFactory<AppBannerInfoBarDelegateAndroid> weak_ptr_factory_; 158 base::WeakPtrFactory<AppBannerInfoBarDelegateAndroid> weak_ptr_factory_;
150 159
151 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid); 160 DISALLOW_COPY_AND_ASSIGN(AppBannerInfoBarDelegateAndroid);
152 }; 161 };
153 162
154 // Register native methods. 163 // Register native methods.
155 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env); 164 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env);
156 165
157 } // namespace banners 166 } // namespace banners
158 167
159 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_ 168 #endif // CHROME_BROWSER_ANDROID_BANNERS_APP_BANNER_INFOBAR_DELEGATE_ANDROID_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/banners/app_banner_infobar_delegate_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698