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

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

Issue 939263002: [App banners] Add RAPPOR support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Swapped out for new call Created 5 years, 10 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_manager.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 #include "chrome/browser/android/banners/app_banner_infobar_delegate.h" 5 #include "chrome/browser/android/banners/app_banner_infobar_delegate.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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/threading/worker_pool.h" 12 #include "base/threading/worker_pool.h"
13 #include "chrome/browser/android/banners/app_banner_manager.h" 13 #include "chrome/browser/android/banners/app_banner_manager.h"
14 #include "chrome/browser/android/shortcut_helper.h" 14 #include "chrome/browser/android/shortcut_helper.h"
15 #include "chrome/browser/android/shortcut_info.h" 15 #include "chrome/browser/android/shortcut_info.h"
16 #include "chrome/browser/android/tab_android.h" 16 #include "chrome/browser/android/tab_android.h"
17 #include "chrome/browser/banners/app_banner_metrics.h" 17 #include "chrome/browser/banners/app_banner_metrics.h"
18 #include "chrome/browser/banners/app_banner_settings_helper.h" 18 #include "chrome/browser/banners/app_banner_settings_helper.h"
19 #include "chrome/browser/infobars/infobar_service.h" 19 #include "chrome/browser/infobars/infobar_service.h"
20 #include "chrome/browser/metrics/rappor/sampling.h"
20 #include "chrome/browser/ui/android/infobars/app_banner_infobar.h" 21 #include "chrome/browser/ui/android/infobars/app_banner_infobar.h"
21 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
22 #include "components/infobars/core/infobar.h" 23 #include "components/infobars/core/infobar.h"
23 #include "components/infobars/core/infobar_manager.h" 24 #include "components/infobars/core/infobar_manager.h"
24 #include "content/public/common/manifest.h" 25 #include "content/public/common/manifest.h"
25 #include "jni/AppBannerInfoBarDelegate_jni.h" 26 #include "jni/AppBannerInfoBarDelegate_jni.h"
26 #include "ui/gfx/android/java_bitmap.h" 27 #include "ui/gfx/android/java_bitmap.h"
27 28
28 using base::android::ConvertJavaStringToUTF8; 29 using base::android::ConvertJavaStringToUTF8;
29 using base::android::ConvertJavaStringToUTF16; 30 using base::android::ConvertJavaStringToUTF16;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return; 115 return;
115 116
116 TrackDismissEvent(DISMISS_EVENT_CLOSE_BUTTON); 117 TrackDismissEvent(DISMISS_EVENT_CLOSE_BUTTON);
117 118
118 if (!native_app_data_.is_null()) { 119 if (!native_app_data_.is_null()) {
119 AppBannerSettingsHelper::RecordBannerEvent( 120 AppBannerSettingsHelper::RecordBannerEvent(
120 web_contents, web_contents->GetURL(), 121 web_contents, web_contents->GetURL(),
121 native_app_package_, 122 native_app_package_,
122 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK, 123 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK,
123 AppBannerManager::GetCurrentTime()); 124 AppBannerManager::GetCurrentTime());
125
126 rappor::SampleDomainAndRegistryFromGURL("AppBanner.NativeApp.Dismissed",
127 web_contents->GetURL());
124 } else if (!web_app_data_.IsEmpty()) { 128 } else if (!web_app_data_.IsEmpty()) {
125 AppBannerSettingsHelper::RecordBannerEvent( 129 AppBannerSettingsHelper::RecordBannerEvent(
126 web_contents, web_contents->GetURL(), 130 web_contents, web_contents->GetURL(),
127 web_app_data_.start_url.spec(), 131 web_app_data_.start_url.spec(),
128 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK, 132 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_BLOCK,
129 AppBannerManager::GetCurrentTime()); 133 AppBannerManager::GetCurrentTime());
134
135 rappor::SampleDomainAndRegistryFromGURL("AppBanner.WebApp.Dismissed",
136 web_contents->GetURL());
130 } 137 }
131 } 138 }
132 139
133 bool AppBannerInfoBarDelegate::Accept() { 140 bool AppBannerInfoBarDelegate::Accept() {
134 content::WebContents* web_contents = 141 content::WebContents* web_contents =
135 InfoBarService::WebContentsFromInfoBar(infobar()); 142 InfoBarService::WebContentsFromInfoBar(infobar());
136 if (!web_contents) { 143 if (!web_contents) {
137 TrackDismissEvent(DISMISS_EVENT_ERROR); 144 TrackDismissEvent(DISMISS_EVENT_ERROR);
138 return true; 145 return true;
139 } 146 }
(...skipping 29 matching lines...) Expand all
169 ShortcutInfo info; 176 ShortcutInfo info;
170 info.UpdateFromManifest(web_app_data_); 177 info.UpdateFromManifest(web_app_data_);
171 base::WorkerPool::PostTask( 178 base::WorkerPool::PostTask(
172 FROM_HERE, 179 FROM_HERE,
173 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap, 180 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap,
174 info, 181 info,
175 *app_icon_.get()), 182 *app_icon_.get()),
176 true); 183 true);
177 184
178 TrackInstallEvent(INSTALL_EVENT_WEB_APP_INSTALLED); 185 TrackInstallEvent(INSTALL_EVENT_WEB_APP_INSTALLED);
186 rappor::SampleDomainAndRegistryFromGURL("AppBanner.WebApp.Installed",
187 web_contents->GetURL());
179 return true; 188 return true;
180 } 189 }
181 190
182 return true; 191 return true;
183 } 192 }
184 193
185 bool AppBannerInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { 194 bool AppBannerInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
186 if (native_app_data_.is_null()) 195 if (native_app_data_.is_null())
187 return false; 196 return false;
188 197
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 230
222 if (jis_installing) { 231 if (jis_installing) {
223 AppBannerSettingsHelper::RecordBannerEvent( 232 AppBannerSettingsHelper::RecordBannerEvent(
224 web_contents, 233 web_contents,
225 web_contents->GetURL(), 234 web_contents->GetURL(),
226 native_app_package_, 235 native_app_package_,
227 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN, 236 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN,
228 AppBannerManager::GetCurrentTime()); 237 AppBannerManager::GetCurrentTime());
229 238
230 TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_STARTED); 239 TrackInstallEvent(INSTALL_EVENT_NATIVE_APP_INSTALL_STARTED);
240 rappor::SampleDomainAndRegistryFromGURL("AppBanner.NativeApp.Installed",
241 web_contents->GetURL());
231 } 242 }
232 243
233 UpdateInstallState(env, obj); 244 UpdateInstallState(env, obj);
234 } 245 }
235 246
236 void AppBannerInfoBarDelegate::OnInstallFinished(JNIEnv* env, 247 void AppBannerInfoBarDelegate::OnInstallFinished(JNIEnv* env,
237 jobject obj, 248 jobject obj,
238 jboolean success) { 249 jboolean success) {
239 if (!infobar()) 250 if (!infobar())
240 return; 251 return;
(...skipping 17 matching lines...) Expand all
258 native_app_data_.obj()); 269 native_app_data_.obj());
259 static_cast<AppBannerInfoBar*>(infobar())->OnInstallStateChanged(newState); 270 static_cast<AppBannerInfoBar*>(infobar())->OnInstallStateChanged(newState);
260 } 271 }
261 272
262 273
263 bool RegisterAppBannerInfoBarDelegate(JNIEnv* env) { 274 bool RegisterAppBannerInfoBarDelegate(JNIEnv* env) {
264 return RegisterNativesImpl(env); 275 return RegisterNativesImpl(env);
265 } 276 }
266 277
267 } // namespace banners 278 } // namespace banners
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/banners/app_banner_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698