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

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

Issue 2718313003: Add switch to disable showing the search geolocation disclosure UI. (Closed)
Patch Set: Created 3 years, 9 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
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/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/feature_list.h" 10 #include "base/feature_list.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "base/time/time.h" 14 #include "base/time/time.h"
14 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur e_infobar_delegate.h" 15 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur e_infobar_delegate.h"
15 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h " 16 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h "
16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/chrome_features.h" 19 #include "chrome/common/chrome_features.h"
20 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
20 #include "components/content_settings/core/browser/host_content_settings_map.h" 22 #include "components/content_settings/core/browser/host_content_settings_map.h"
21 #include "components/content_settings/core/common/content_settings.h" 23 #include "components/content_settings/core/common/content_settings.h"
22 #include "components/content_settings/core/common/content_settings_types.h" 24 #include "components/content_settings/core/common/content_settings_types.h"
23 #include "components/pref_registry/pref_registry_syncable.h" 25 #include "components/pref_registry/pref_registry_syncable.h"
24 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
25 #include "components/variations/variations_associated_data.h" 27 #include "components/variations/variations_associated_data.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
27 #include "jni/GeolocationHeader_jni.h" 29 #include "jni/GeolocationHeader_jni.h"
28 #include "jni/SearchGeolocationDisclosureTabHelper_jni.h" 30 #include "jni/SearchGeolocationDisclosureTabHelper_jni.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return base::Time::Now() + base::TimeDelta::FromDays(gDayOffsetForTesting); 65 return base::Time::Now() + base::TimeDelta::FromDays(gDayOffsetForTesting);
64 } 66 }
65 67
66 } // namespace 68 } // namespace
67 69
68 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SearchGeolocationDisclosureTabHelper); 70 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SearchGeolocationDisclosureTabHelper);
69 71
70 SearchGeolocationDisclosureTabHelper::SearchGeolocationDisclosureTabHelper( 72 SearchGeolocationDisclosureTabHelper::SearchGeolocationDisclosureTabHelper(
71 content::WebContents* contents) 73 content::WebContents* contents)
72 : content::WebContentsObserver(contents) { 74 : content::WebContentsObserver(contents) {
73 consistent_geolocation_enabled_ = 75 consistent_geolocation_disclosure_enabled_ =
74 base::FeatureList::IsEnabled(features::kConsistentOmniboxGeolocation); 76 base::FeatureList::IsEnabled(features::kConsistentOmniboxGeolocation) &&
77 !base::CommandLine::ForCurrentProcess()->HasSwitch(
78 switches::kDisableSearchGeolocationDisclosure);
75 } 79 }
76 80
77 SearchGeolocationDisclosureTabHelper::~SearchGeolocationDisclosureTabHelper() {} 81 SearchGeolocationDisclosureTabHelper::~SearchGeolocationDisclosureTabHelper() {}
78 82
79 void SearchGeolocationDisclosureTabHelper::NavigationEntryCommitted( 83 void SearchGeolocationDisclosureTabHelper::NavigationEntryCommitted(
80 const content::LoadCommittedDetails& load_details) { 84 const content::LoadCommittedDetails& load_details) {
81 MaybeShowDisclosure(web_contents()->GetVisibleURL()); 85 MaybeShowDisclosure(web_contents()->GetVisibleURL());
82 } 86 }
83 87
84 void SearchGeolocationDisclosureTabHelper::MaybeShowDisclosure( 88 void SearchGeolocationDisclosureTabHelper::MaybeShowDisclosure(
85 const GURL& gurl) { 89 const GURL& gurl) {
86 if (!consistent_geolocation_enabled_) 90 if (!consistent_geolocation_disclosure_enabled_)
87 return; 91 return;
88 92
89 if (!ShouldShowDisclosureForUrl(gurl)) 93 if (!ShouldShowDisclosureForUrl(gurl))
90 return; 94 return;
91 95
92 // Don't show the infobar if the user has dismissed it, or they've seen it 96 // Don't show the infobar if the user has dismissed it, or they've seen it
93 // enough times already. 97 // enough times already.
94 PrefService* prefs = GetProfile()->GetPrefs(); 98 PrefService* prefs = GetProfile()->GetPrefs();
95 bool dismissed_already = 99 bool dismissed_already =
96 prefs->GetBoolean(prefs::kSearchGeolocationDisclosureDismissed); 100 prefs->GetBoolean(prefs::kSearchGeolocationDisclosureDismissed);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 const base::android::JavaParamRef<jclass>& clazz) { 241 const base::android::JavaParamRef<jclass>& clazz) {
238 gIgnoreUrlChecksForTesting = true; 242 gIgnoreUrlChecksForTesting = true;
239 } 243 }
240 244
241 // static 245 // static
242 void SetDayOffsetForTesting(JNIEnv* env, 246 void SetDayOffsetForTesting(JNIEnv* env,
243 const base::android::JavaParamRef<jclass>& clazz, 247 const base::android::JavaParamRef<jclass>& clazz,
244 jint days) { 248 jint days) {
245 gDayOffsetForTesting = days; 249 gDayOffsetForTesting = days;
246 } 250 }
OLDNEW
« no previous file with comments | « chrome/browser/android/search_geolocation/search_geolocation_disclosure_tab_helper.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698