| Index: chrome/browser/android/search_geolocation_disclosure_tab_helper.cc
|
| diff --git a/chrome/browser/android/search_geolocation_disclosure_tab_helper.cc b/chrome/browser/android/search_geolocation_disclosure_tab_helper.cc
|
| index 5bfdc99258369fb57a5b27c9db64a018ad576558..82942d1b19893444835be1d0c20694626e245dbb 100644
|
| --- a/chrome/browser/android/search_geolocation_disclosure_tab_helper.cc
|
| +++ b/chrome/browser/android/search_geolocation_disclosure_tab_helper.cc
|
| @@ -4,8 +4,6 @@
|
|
|
| #include "chrome/browser/android/search_geolocation_disclosure_tab_helper.h"
|
|
|
| -#include "base/android/jni_android.h"
|
| -#include "base/android/jni_string.h"
|
| #include "base/feature_list.h"
|
| #include "base/logging.h"
|
| #include "base/metrics/histogram_macros.h"
|
| @@ -25,7 +23,6 @@
|
| #include "content/public/browser/permission_type.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "jni/GeolocationHeader_jni.h"
|
| -#include "jni/SearchGeolocationDisclosureTabHelper_jni.h"
|
| #include "third_party/WebKit/public/platform/modules/permissions/permission_status.mojom.h"
|
|
|
| namespace {
|
| @@ -34,9 +31,6 @@
|
| const int kDefaultDaysPerShow = 1;
|
| const char kMaxShowCountVariation[] = "MaxShowCount";
|
| const char kDaysPerShowVariation[] = "DaysPerShow";
|
| -
|
| -bool gIgnoreUrlChecksForTesting = false;
|
| -int gDayOffsetForTesting = 0;
|
|
|
| int GetMaxShowCount() {
|
| std::string variation = variations::GetVariationParamValueByFeature(
|
| @@ -56,10 +50,6 @@
|
| return days_per_show;
|
|
|
| return kDefaultDaysPerShow;
|
| -}
|
| -
|
| -base::Time GetTimeNow() {
|
| - return base::Time::Now() + base::TimeDelta::FromDays(gDayOffsetForTesting);
|
| }
|
|
|
| } // namespace
|
| @@ -98,19 +88,29 @@
|
| prefs::kSearchGeolocationPostDisclosureMetricsRecorded, false);
|
| }
|
|
|
| -// static
|
| -bool SearchGeolocationDisclosureTabHelper::Register(JNIEnv* env) {
|
| - return RegisterNativesImpl(env);
|
| -}
|
| -
|
| void SearchGeolocationDisclosureTabHelper::
|
| MaybeShowDefaultSearchGeolocationDisclosure(const GURL& gurl) {
|
| // Don't show in incognito.
|
| if (GetProfile()->IsOffTheRecord())
|
| return;
|
|
|
| - if (!ShouldShowDisclosureForUrl(gurl))
|
| - return;
|
| + // Only show the disclosure for default search navigations from the omnibox.
|
| + TemplateURLService* template_url_service =
|
| + TemplateURLServiceFactory::GetForProfile(GetProfile());
|
| + bool is_search_url =
|
| + template_url_service->IsSearchResultsPageFromDefaultSearchProvider(
|
| + gurl);
|
| + if (!is_search_url)
|
| + return;
|
| +
|
| + // Only show the disclosure if Google is the default search engine.
|
| + TemplateURL* default_search =
|
| + template_url_service->GetDefaultSearchProvider();
|
| + if (!default_search ||
|
| + !default_search->url_ref().HasGoogleBaseURLs(
|
| + template_url_service->search_terms_data())) {
|
| + return;
|
| + }
|
|
|
| // Don't show the infobar if the user has dismissed it, or they've seen it
|
| // enough times already.
|
| @@ -132,7 +132,8 @@
|
| // Or if it has been shown too recently.
|
| base::Time last_shown = base::Time::FromInternalValue(
|
| prefs->GetInt64(prefs::kSearchGeolocationDisclosureLastShowDate));
|
| - if (GetTimeNow() - last_shown < base::TimeDelta::FromDays(GetDaysPerShow())) {
|
| + if (base::Time::Now() - last_shown <
|
| + base::TimeDelta::FromDays(GetDaysPerShow())) {
|
| return;
|
| }
|
|
|
| @@ -159,33 +160,7 @@
|
| shown_count++;
|
| prefs->SetInteger(prefs::kSearchGeolocationDisclosureShownCount, shown_count);
|
| prefs->SetInt64(prefs::kSearchGeolocationDisclosureLastShowDate,
|
| - GetTimeNow().ToInternalValue());
|
| -}
|
| -
|
| -bool SearchGeolocationDisclosureTabHelper::ShouldShowDisclosureForUrl(
|
| - const GURL& gurl) {
|
| - if (gIgnoreUrlChecksForTesting)
|
| - return true;
|
| -
|
| - // Only show the disclosure for default search navigations from the omnibox.
|
| - TemplateURLService* template_url_service =
|
| - TemplateURLServiceFactory::GetForProfile(GetProfile());
|
| - bool is_search_url =
|
| - template_url_service->IsSearchResultsPageFromDefaultSearchProvider(
|
| - gurl);
|
| - if (!is_search_url)
|
| - return false;
|
| -
|
| - // Only show the disclosure if Google is the default search engine.
|
| - TemplateURL* default_search =
|
| - template_url_service->GetDefaultSearchProvider();
|
| - if (!default_search ||
|
| - !default_search->url_ref().HasGoogleBaseURLs(
|
| - template_url_service->search_terms_data())) {
|
| - return false;
|
| - }
|
| -
|
| - return true;
|
| + base::Time::Now().ToInternalValue());
|
| }
|
|
|
| void SearchGeolocationDisclosureTabHelper::RecordPreDisclosureMetrics(
|
| @@ -229,17 +204,3 @@
|
| Profile* SearchGeolocationDisclosureTabHelper::GetProfile() {
|
| return Profile::FromBrowserContext(web_contents()->GetBrowserContext());
|
| }
|
| -
|
| -// static
|
| -void SetIgnoreUrlChecksForTesting(
|
| - JNIEnv* env,
|
| - const base::android::JavaParamRef<jclass>& clazz) {
|
| - gIgnoreUrlChecksForTesting = true;
|
| -}
|
| -
|
| -// static
|
| -void SetDayOffsetForTesting(JNIEnv* env,
|
| - const base::android::JavaParamRef<jclass>& clazz,
|
| - jint days) {
|
| - gDayOffsetForTesting = days;
|
| -}
|
|
|