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

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

Issue 1161233005: Implement app banner info bars on desktop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stop-icon-overgeneration
Patch Set: Fixing display bug on Android Created 5 years, 6 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
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 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h" 5 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 gfx::Image AppBannerInfoBarDelegateAndroid::GetIcon() const { 148 gfx::Image AppBannerInfoBarDelegateAndroid::GetIcon() const {
149 return gfx::Image::CreateFrom1xBitmap(*app_icon_.get()); 149 return gfx::Image::CreateFrom1xBitmap(*app_icon_.get());
150 } 150 }
151 151
152 void AppBannerInfoBarDelegateAndroid::InfoBarDismissed() { 152 void AppBannerInfoBarDelegateAndroid::InfoBarDismissed() {
153 content::WebContents* web_contents = 153 content::WebContents* web_contents =
154 InfoBarService::WebContentsFromInfoBar(infobar()); 154 InfoBarService::WebContentsFromInfoBar(infobar());
155 if (!web_contents) 155 if (!web_contents)
156 return; 156 return;
157 157
158 TrackDismissEvent(DISMISS_EVENT_CLOSE_BUTTON);
159
160 web_contents->GetMainFrame()->Send(
161 new ChromeViewMsg_AppBannerDismissed(
162 web_contents->GetMainFrame()->GetRoutingID(),
163 event_request_id_));
164
165 if (!native_app_data_.is_null()) { 158 if (!native_app_data_.is_null()) {
166 AppBannerSettingsHelper::RecordBannerEvent( 159 AppBannerSettingsHelper::RecordBannerDismissEvent(
167 web_contents, web_contents->GetURL(), 160 web_contents, native_app_package_, "AppBanner.NativeApp.Dismissed",
168 native_app_package_, 161 event_request_id_);
169 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK,
170 AppBannerDataFetcher::GetCurrentTime());
171
172 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
173 "AppBanner.NativeApp.Dismissed",
174 web_contents->GetURL());
175 } else if (!web_app_data_.IsEmpty()) { 162 } else if (!web_app_data_.IsEmpty()) {
176 AppBannerSettingsHelper::RecordBannerEvent( 163 AppBannerSettingsHelper::RecordBannerDismissEvent(
177 web_contents, web_contents->GetURL(), 164 web_contents, web_app_data_.start_url.spec(),
178 web_app_data_.start_url.spec(), 165 "AppBanner.WebApp.Dismissed", event_request_id_);
179 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK,
180 AppBannerDataFetcher::GetCurrentTime());
181
182 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
183 "AppBanner.WebApp.Dismissed",
184 web_contents->GetURL());
185 } 166 }
186 } 167 }
187 168
188 base::string16 AppBannerInfoBarDelegateAndroid::GetMessageText() const { 169 base::string16 AppBannerInfoBarDelegateAndroid::GetMessageText() const {
189 return app_title_; 170 return app_title_;
190 } 171 }
191 172
192 int AppBannerInfoBarDelegateAndroid::GetButtons() const { 173 int AppBannerInfoBarDelegateAndroid::GetButtons() const {
193 return BUTTON_OK; 174 return BUTTON_OK;
194 } 175 }
(...skipping 22 matching lines...) Expand all
217 native_app_data_.obj()); 198 native_app_data_.obj());
218 199
219 if (was_opened) { 200 if (was_opened) {
220 TrackDismissEvent(DISMISS_EVENT_APP_OPEN); 201 TrackDismissEvent(DISMISS_EVENT_APP_OPEN);
221 } else { 202 } else {
222 TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_TRIGGERED); 203 TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_TRIGGERED);
223 } 204 }
224 SendBannerAccepted(web_contents, "play"); 205 SendBannerAccepted(web_contents, "play");
225 return was_opened; 206 return was_opened;
226 } else if (!web_app_data_.IsEmpty()) { 207 } else if (!web_app_data_.IsEmpty()) {
227 AppBannerSettingsHelper::RecordBannerEvent( 208 AppBannerSettingsHelper::RecordBannerWebInstallEvent(
228 web_contents, web_contents->GetURL(), 209 web_contents, web_app_data_.start_url.spec(),
229 web_app_data_.start_url.spec(), 210 "AppBanner.WebApp.Installed", event_request_id_);
230 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
231 AppBannerDataFetcher::GetCurrentTime());
232 211
233 ShortcutInfo info; 212 ShortcutInfo info;
234 info.UpdateFromManifest(web_app_data_); 213 info.UpdateFromManifest(web_app_data_);
235 content::BrowserThread::PostTask( 214 content::BrowserThread::PostTask(
236 content::BrowserThread::IO, 215 content::BrowserThread::IO,
237 FROM_HERE, 216 FROM_HERE,
238 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap, 217 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap,
239 info, 218 info,
240 *app_icon_.get())); 219 *app_icon_.get()));
241 220
242 TrackInstallEvent(INSTALL_EVENT_WEB_APP_INSTALLED);
243 SendBannerAccepted(web_contents, "web"); 221 SendBannerAccepted(web_contents, "web");
244 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
245 "AppBanner.WebApp.Installed",
246 web_contents->GetURL());
247 return true; 222 return true;
248 } 223 }
249 224
250 return true; 225 return true;
251 } 226 }
252 227
253 bool AppBannerInfoBarDelegateAndroid::LinkClicked( 228 bool AppBannerInfoBarDelegateAndroid::LinkClicked(
254 WindowOpenDisposition disposition) { 229 WindowOpenDisposition disposition) {
255 if (native_app_data_.is_null()) 230 if (native_app_data_.is_null())
256 return false; 231 return false;
(...skipping 17 matching lines...) Expand all
274 249
275 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); 250 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK);
276 return true; 251 return true;
277 } 252 }
278 253
279 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { 254 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) {
280 return RegisterNativesImpl(env); 255 return RegisterNativesImpl(env);
281 } 256 }
282 257
283 } // namespace banners 258 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698