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

Side by Side Diff: chrome/browser/android/search_geolocation_disclosure_tab_helper.cc

Issue 2585153002: Record search geolocation pre-disclosure metrics earlier (Closed)
Patch Set: Created 4 years 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_disclosure_tab_helper.h" 5 #include "chrome/browser/android/search_geolocation_disclosure_tab_helper.h"
6 6
7 #include "base/feature_list.h" 7 #include "base/feature_list.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (base::Time::Now() - last_shown < 131 if (base::Time::Now() - last_shown <
132 base::TimeDelta::FromDays(GetDaysPerShow())) { 132 base::TimeDelta::FromDays(GetDaysPerShow())) {
133 return; 133 return;
134 } 134 }
135 135
136 // Check that the Chrome app has geolocation permission. 136 // Check that the Chrome app has geolocation permission.
137 JNIEnv* env = base::android::AttachCurrentThread(); 137 JNIEnv* env = base::android::AttachCurrentThread();
138 if (!Java_GeolocationHeader_hasGeolocationPermission(env)) 138 if (!Java_GeolocationHeader_hasGeolocationPermission(env))
139 return; 139 return;
140 140
141 // Record metrics for the state of permissions before the disclosure has been
142 // shown.
143 RecordPreDisclosureMetrics(gurl);
144
141 // Only show the disclosure if the geolocation permission is set to ASK 145 // Only show the disclosure if the geolocation permission is set to ASK
142 // (i.e. has not been explicitly set or revoked). 146 // (i.e. has not been explicitly set or revoked).
143 blink::mojom::PermissionStatus status = 147 blink::mojom::PermissionStatus status =
144 PermissionManager::Get(GetProfile()) 148 PermissionManager::Get(GetProfile())
145 ->GetPermissionStatus(content::PermissionType::GEOLOCATION, gurl, 149 ->GetPermissionStatus(content::PermissionType::GEOLOCATION, gurl,
146 gurl); 150 gurl);
147 if (status != blink::mojom::PermissionStatus::ASK) 151 if (status != blink::mojom::PermissionStatus::ASK)
148 return; 152 return;
149 153
150 // Record metrics for the state of permissions before the disclosure has been
151 // shown.
152 RecordPreDisclosureMetrics(gurl);
153
154 // All good, let's show the disclosure and increment the shown count. 154 // All good, let's show the disclosure and increment the shown count.
155 SearchGeolocationDisclosureInfoBarDelegate::Create(web_contents(), gurl); 155 SearchGeolocationDisclosureInfoBarDelegate::Create(web_contents(), gurl);
156 shown_count++; 156 shown_count++;
157 prefs->SetInteger(prefs::kSearchGeolocationDisclosureShownCount, shown_count); 157 prefs->SetInteger(prefs::kSearchGeolocationDisclosureShownCount, shown_count);
158 prefs->SetInt64(prefs::kSearchGeolocationDisclosureLastShowDate, 158 prefs->SetInt64(prefs::kSearchGeolocationDisclosureLastShowDate,
159 base::Time::Now().ToInternalValue()); 159 base::Time::Now().ToInternalValue());
160 } 160 }
161 161
162 void SearchGeolocationDisclosureTabHelper::RecordPreDisclosureMetrics( 162 void SearchGeolocationDisclosureTabHelper::RecordPreDisclosureMetrics(
163 const GURL& gurl) { 163 const GURL& gurl) {
(...skipping 29 matching lines...) Expand all
193 blink::mojom::PermissionStatus::LAST) + 193 blink::mojom::PermissionStatus::LAST) +
194 1); 194 1);
195 prefs->SetBoolean(prefs::kSearchGeolocationPostDisclosureMetricsRecorded, 195 prefs->SetBoolean(prefs::kSearchGeolocationPostDisclosureMetricsRecorded,
196 true); 196 true);
197 } 197 }
198 } 198 }
199 199
200 Profile* SearchGeolocationDisclosureTabHelper::GetProfile() { 200 Profile* SearchGeolocationDisclosureTabHelper::GetProfile() {
201 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 201 return Profile::FromBrowserContext(web_contents()->GetBrowserContext());
202 } 202 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698