Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/search_geolocation/search_geolocation_disclosur e_tab_helper.h" | 5 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur e_tab_helper.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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 prefs::kSearchGeolocationPreDisclosureMetricsRecorded)) { | 200 prefs::kSearchGeolocationPreDisclosureMetricsRecorded)) { |
| 201 ContentSetting status = | 201 ContentSetting status = |
| 202 HostContentSettingsMapFactory::GetForProfile(GetProfile()) | 202 HostContentSettingsMapFactory::GetForProfile(GetProfile()) |
| 203 ->GetContentSetting(gurl, gurl, CONTENT_SETTINGS_TYPE_GEOLOCATION, | 203 ->GetContentSetting(gurl, gurl, CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 204 std::string()); | 204 std::string()); |
| 205 UMA_HISTOGRAM_ENUMERATION( | 205 UMA_HISTOGRAM_ENUMERATION( |
| 206 "GeolocationDisclosure.PreDisclosureContentSetting", | 206 "GeolocationDisclosure.PreDisclosureContentSetting", |
| 207 static_cast<base::HistogramBase::Sample>(status), | 207 static_cast<base::HistogramBase::Sample>(status), |
| 208 static_cast<base::HistogramBase::Sample>(CONTENT_SETTING_NUM_SETTINGS) + | 208 static_cast<base::HistogramBase::Sample>(CONTENT_SETTING_NUM_SETTINGS) + |
| 209 1); | 209 1); |
| 210 | |
| 211 SearchGeolocationService* service = | |
| 212 SearchGeolocationService::Factory::GetForBrowserContext(GetProfile()); | |
| 213 UMA_HISTOGRAM_BOOLEAN("GeolocationDisclosure.PreDisclosureDSESetting", | |
| 214 service->GetDSEGeolocationSetting()); | |
| 215 | |
| 210 prefs->SetBoolean(prefs::kSearchGeolocationPreDisclosureMetricsRecorded, | 216 prefs->SetBoolean(prefs::kSearchGeolocationPreDisclosureMetricsRecorded, |
| 211 true); | 217 true); |
| 212 } | 218 } |
| 213 } | 219 } |
| 214 | 220 |
| 215 void SearchGeolocationDisclosureTabHelper::RecordPostDisclosureMetrics( | 221 void SearchGeolocationDisclosureTabHelper::RecordPostDisclosureMetrics( |
| 216 const GURL& gurl) { | 222 const GURL& gurl) { |
| 217 PrefService* prefs = GetProfile()->GetPrefs(); | 223 PrefService* prefs = GetProfile()->GetPrefs(); |
| 218 if (!prefs->GetBoolean( | 224 if (!prefs->GetBoolean( |
| 219 prefs::kSearchGeolocationPostDisclosureMetricsRecorded)) { | 225 prefs::kSearchGeolocationPostDisclosureMetricsRecorded)) { |
| 220 ContentSetting status = | 226 ContentSetting status = |
| 221 HostContentSettingsMapFactory::GetForProfile(GetProfile()) | 227 HostContentSettingsMapFactory::GetForProfile(GetProfile()) |
| 222 ->GetContentSetting(gurl, gurl, CONTENT_SETTINGS_TYPE_GEOLOCATION, | 228 ->GetContentSetting(gurl, gurl, CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 223 std::string()); | 229 std::string()); |
| 224 UMA_HISTOGRAM_ENUMERATION( | 230 UMA_HISTOGRAM_ENUMERATION( |
| 225 "GeolocationDisclosure.PostDisclosureContentSetting", | 231 "GeolocationDisclosure.PostDisclosureContentSetting", |
| 226 static_cast<base::HistogramBase::Sample>(status), | 232 static_cast<base::HistogramBase::Sample>(status), |
| 227 static_cast<base::HistogramBase::Sample>(CONTENT_SETTING_NUM_SETTINGS) + | 233 static_cast<base::HistogramBase::Sample>(CONTENT_SETTING_NUM_SETTINGS) + |
| 228 1); | 234 1); |
| 235 | |
| 236 SearchGeolocationService* service = | |
| 237 SearchGeolocationService::Factory::GetForBrowserContext(GetProfile()); | |
| 238 UMA_HISTOGRAM_BOOLEAN("GeolocationDisclosure.PostDisclosureDSESetting", | |
| 239 service->GetDSEGeolocationSetting()); | |
|
raymes
2017/04/04 22:36:39
Sorry my memory on this code isn't the best. Is it
benwells
2017/04/05 08:39:49
Yes that's right, but not a problem. What we're tr
| |
| 240 | |
| 229 prefs->SetBoolean(prefs::kSearchGeolocationPostDisclosureMetricsRecorded, | 241 prefs->SetBoolean(prefs::kSearchGeolocationPostDisclosureMetricsRecorded, |
| 230 true); | 242 true); |
| 231 } | 243 } |
| 232 } | 244 } |
| 233 | 245 |
| 234 Profile* SearchGeolocationDisclosureTabHelper::GetProfile() { | 246 Profile* SearchGeolocationDisclosureTabHelper::GetProfile() { |
| 235 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 247 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 236 } | 248 } |
| 237 | 249 |
| 238 // static | 250 // static |
| 239 void SetIgnoreUrlChecksForTesting( | 251 void SetIgnoreUrlChecksForTesting( |
| 240 JNIEnv* env, | 252 JNIEnv* env, |
| 241 const base::android::JavaParamRef<jclass>& clazz) { | 253 const base::android::JavaParamRef<jclass>& clazz) { |
| 242 gIgnoreUrlChecksForTesting = true; | 254 gIgnoreUrlChecksForTesting = true; |
| 243 } | 255 } |
| 244 | 256 |
| 245 // static | 257 // static |
| 246 void SetDayOffsetForTesting(JNIEnv* env, | 258 void SetDayOffsetForTesting(JNIEnv* env, |
| 247 const base::android::JavaParamRef<jclass>& clazz, | 259 const base::android::JavaParamRef<jclass>& clazz, |
| 248 jint days) { | 260 jint days) { |
| 249 gDayOffsetForTesting = days; | 261 gDayOffsetForTesting = days; |
| 250 } | 262 } |
| OLD | NEW |