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

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: Moving feature enabling to existing #ifs 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( 158 web_contents->GetMainFrame()->Send(
161 new ChromeViewMsg_AppBannerDismissed( 159 new ChromeViewMsg_AppBannerDismissed(
162 web_contents->GetMainFrame()->GetRoutingID(), 160 web_contents->GetMainFrame()->GetRoutingID(),
163 event_request_id_)); 161 event_request_id_));
164 162
165 if (!native_app_data_.is_null()) { 163 if (!native_app_data_.is_null()) {
166 AppBannerSettingsHelper::RecordBannerEvent( 164 AppBannerSettingsHelper::RecordBannerDismissEvent(
167 web_contents, web_contents->GetURL(), 165 web_contents, native_app_package_, AppBannerSettingsHelper::NATIVE);
168 native_app_package_,
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()) { 166 } else if (!web_app_data_.IsEmpty()) {
176 AppBannerSettingsHelper::RecordBannerEvent( 167 AppBannerSettingsHelper::RecordBannerDismissEvent(
177 web_contents, web_contents->GetURL(), 168 web_contents, web_app_data_.start_url.spec(),
178 web_app_data_.start_url.spec(), 169 AppBannerSettingsHelper::WEB);
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 } 170 }
186 } 171 }
187 172
188 base::string16 AppBannerInfoBarDelegateAndroid::GetMessageText() const { 173 base::string16 AppBannerInfoBarDelegateAndroid::GetMessageText() const {
189 return app_title_; 174 return app_title_;
190 } 175 }
191 176
192 int AppBannerInfoBarDelegateAndroid::GetButtons() const { 177 int AppBannerInfoBarDelegateAndroid::GetButtons() const {
193 return BUTTON_OK; 178 return BUTTON_OK;
194 } 179 }
(...skipping 22 matching lines...) Expand all
217 native_app_data_.obj()); 202 native_app_data_.obj());
218 203
219 if (was_opened) { 204 if (was_opened) {
220 TrackDismissEvent(DISMISS_EVENT_APP_OPEN); 205 TrackDismissEvent(DISMISS_EVENT_APP_OPEN);
221 } else { 206 } else {
222 TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_TRIGGERED); 207 TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_TRIGGERED);
223 } 208 }
224 SendBannerAccepted(web_contents, "play"); 209 SendBannerAccepted(web_contents, "play");
225 return was_opened; 210 return was_opened;
226 } else if (!web_app_data_.IsEmpty()) { 211 } else if (!web_app_data_.IsEmpty()) {
227 AppBannerSettingsHelper::RecordBannerEvent( 212 AppBannerSettingsHelper::RecordBannerInstallEvent(
228 web_contents, web_contents->GetURL(), 213 web_contents, web_app_data_.start_url.spec(),
229 web_app_data_.start_url.spec(), 214 AppBannerSettingsHelper::WEB);
230 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
231 AppBannerDataFetcher::GetCurrentTime());
232 215
233 ShortcutInfo info; 216 ShortcutInfo info;
234 info.UpdateFromManifest(web_app_data_); 217 info.UpdateFromManifest(web_app_data_);
235 content::BrowserThread::PostTask( 218 content::BrowserThread::PostTask(
236 content::BrowserThread::IO, 219 content::BrowserThread::IO,
237 FROM_HERE, 220 FROM_HERE,
238 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap, 221 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap,
239 info, 222 info,
240 *app_icon_.get())); 223 *app_icon_.get()));
241 224
242 TrackInstallEvent(INSTALL_EVENT_WEB_APP_INSTALLED);
243 SendBannerAccepted(web_contents, "web"); 225 SendBannerAccepted(web_contents, "web");
244 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
245 "AppBanner.WebApp.Installed",
246 web_contents->GetURL());
247 return true; 226 return true;
248 } 227 }
249 228
250 return true; 229 return true;
251 } 230 }
252 231
253 bool AppBannerInfoBarDelegateAndroid::LinkClicked( 232 bool AppBannerInfoBarDelegateAndroid::LinkClicked(
254 WindowOpenDisposition disposition) { 233 WindowOpenDisposition disposition) {
255 if (native_app_data_.is_null()) 234 if (native_app_data_.is_null())
256 return false; 235 return false;
(...skipping 17 matching lines...) Expand all
274 253
275 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK); 254 TrackDismissEvent(DISMISS_EVENT_BANNER_CLICK);
276 return true; 255 return true;
277 } 256 }
278 257
279 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) { 258 bool RegisterAppBannerInfoBarDelegateAndroid(JNIEnv* env) {
280 return RegisterNativesImpl(env); 259 return RegisterNativesImpl(env);
281 } 260 }
282 261
283 } // namespace banners 262 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/android/banners/app_banner_data_fetcher_android.cc ('k') | chrome/browser/banners/app_banner_data_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698