| 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_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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 registry->RegisterInt64Pref(prefs::kSearchGeolocationDisclosureLastShowDate, | 83 registry->RegisterInt64Pref(prefs::kSearchGeolocationDisclosureLastShowDate, |
| 84 0); | 84 0); |
| 85 registry->RegisterBooleanPref( | 85 registry->RegisterBooleanPref( |
| 86 prefs::kSearchGeolocationPreDisclosureMetricsRecorded, false); | 86 prefs::kSearchGeolocationPreDisclosureMetricsRecorded, false); |
| 87 registry->RegisterBooleanPref( | 87 registry->RegisterBooleanPref( |
| 88 prefs::kSearchGeolocationPostDisclosureMetricsRecorded, false); | 88 prefs::kSearchGeolocationPostDisclosureMetricsRecorded, false); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void SearchGeolocationDisclosureTabHelper:: | 91 void SearchGeolocationDisclosureTabHelper:: |
| 92 MaybeShowDefaultSearchGeolocationDisclosure(const GURL& gurl) { | 92 MaybeShowDefaultSearchGeolocationDisclosure(const GURL& gurl) { |
| 93 // Don't show in incognito. |
| 94 if (GetProfile()->IsOffTheRecord()) |
| 95 return; |
| 96 |
| 93 // Only show the disclosure for default search navigations from the omnibox. | 97 // Only show the disclosure for default search navigations from the omnibox. |
| 94 TemplateURLService* template_url_service = | 98 TemplateURLService* template_url_service = |
| 95 TemplateURLServiceFactory::GetForProfile(GetProfile()); | 99 TemplateURLServiceFactory::GetForProfile(GetProfile()); |
| 96 bool is_search_url = | 100 bool is_search_url = |
| 97 template_url_service->IsSearchResultsPageFromDefaultSearchProvider( | 101 template_url_service->IsSearchResultsPageFromDefaultSearchProvider( |
| 98 gurl); | 102 gurl); |
| 99 if (!is_search_url) | 103 if (!is_search_url) |
| 100 return; | 104 return; |
| 101 | 105 |
| 102 // Only show the disclosure if Google is the default search engine. | 106 // Only show the disclosure if Google is the default search engine. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 blink::mojom::PermissionStatus::LAST) + | 197 blink::mojom::PermissionStatus::LAST) + |
| 194 1); | 198 1); |
| 195 prefs->SetBoolean(prefs::kSearchGeolocationPostDisclosureMetricsRecorded, | 199 prefs->SetBoolean(prefs::kSearchGeolocationPostDisclosureMetricsRecorded, |
| 196 true); | 200 true); |
| 197 } | 201 } |
| 198 } | 202 } |
| 199 | 203 |
| 200 Profile* SearchGeolocationDisclosureTabHelper::GetProfile() { | 204 Profile* SearchGeolocationDisclosureTabHelper::GetProfile() { |
| 201 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 205 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 202 } | 206 } |
| OLD | NEW |