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

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

Issue 2811073003: Revert of Don't use the DSE geolocation setting when chrome doesn't have location. (Closed)
Patch Set: Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_service.h " 5 #include "chrome/browser/android/search_geolocation/search_geolocation_service.h "
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/android/location_settings_impl.h"
11 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur e_tab_helper.h" 10 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur e_tab_helper.h"
12 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 11 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
13 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/search_engines/template_url_service_factory.h" 13 #include "chrome/browser/search_engines/template_url_service_factory.h"
15 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 14 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
16 #include "chrome/common/chrome_features.h" 15 #include "chrome/common/chrome_features.h"
17 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
18 #include "components/content_settings/core/browser/content_settings_utils.h" 17 #include "components/content_settings/core/browser/content_settings_utils.h"
19 #include "components/content_settings/core/browser/host_content_settings_map.h" 18 #include "components/content_settings/core/browser/host_content_settings_map.h"
20 #include "components/content_settings/core/common/content_settings_types.h" 19 #include "components/content_settings/core/common/content_settings_types.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 127
129 void SearchGeolocationService::Factory::RegisterProfilePrefs( 128 void SearchGeolocationService::Factory::RegisterProfilePrefs(
130 user_prefs::PrefRegistrySyncable* registry) { 129 user_prefs::PrefRegistrySyncable* registry) {
131 registry->RegisterDictionaryPref(prefs::kGoogleDSEGeolocationSetting); 130 registry->RegisterDictionaryPref(prefs::kGoogleDSEGeolocationSetting);
132 } 131 }
133 132
134 SearchGeolocationService::SearchGeolocationService(Profile* profile) 133 SearchGeolocationService::SearchGeolocationService(Profile* profile)
135 : profile_(profile), 134 : profile_(profile),
136 pref_service_(profile_->GetPrefs()), 135 pref_service_(profile_->GetPrefs()),
137 host_content_settings_map_( 136 host_content_settings_map_(
138 HostContentSettingsMapFactory::GetForProfile(profile_)), 137 HostContentSettingsMapFactory::GetForProfile(profile_)) {
139 location_settings_(new LocationSettingsImpl()) {
140 // This class should never be constructed in incognito. 138 // This class should never be constructed in incognito.
141 DCHECK(!profile_->IsOffTheRecord()); 139 DCHECK(!profile_->IsOffTheRecord());
142 140
143 if (!UseConsistentSearchGeolocation()) 141 if (!UseConsistentSearchGeolocation())
144 return; 142 return;
145 143
146 delegate_.reset(new SearchEngineDelegateImpl(profile_)); 144 delegate_.reset(new SearchEngineDelegateImpl(profile_));
147 delegate_->SetDSEChangedCallback(base::Bind( 145 delegate_->SetDSEChangedCallback(base::Bind(
148 &SearchGeolocationService::OnDSEChanged, base::Unretained(this))); 146 &SearchGeolocationService::OnDSEChanged, base::Unretained(this)));
149 147
(...skipping 16 matching lines...) Expand all
166 if (!requesting_origin.IsSameOriginWith(delegate_->GetGoogleDSECCTLD())) 164 if (!requesting_origin.IsSameOriginWith(delegate_->GetGoogleDSECCTLD()))
167 return false; 165 return false;
168 166
169 // If the content setting for the DSE CCTLD is controlled by policy, and is st 167 // If the content setting for the DSE CCTLD is controlled by policy, and is st
170 // to ASK, don't use the DSE geolocation setting. 168 // to ASK, don't use the DSE geolocation setting.
171 if (!IsContentSettingUserSettable() && 169 if (!IsContentSettingUserSettable() &&
172 GetCurrentContentSetting() == CONTENT_SETTING_ASK) { 170 GetCurrentContentSetting() == CONTENT_SETTING_ASK) {
173 return false; 171 return false;
174 } 172 }
175 173
176 if (!location_settings_->HasAndroidLocationPermission())
177 return false;
178
179 return true; 174 return true;
180 } 175 }
181 176
182 bool SearchGeolocationService::GetDSEGeolocationSetting() { 177 bool SearchGeolocationService::GetDSEGeolocationSetting() {
183 // Make sure the setting is valid, in case enterprise policy has changed. 178 // Make sure the setting is valid, in case enterprise policy has changed.
184 // TODO(benwells): Check if enterprise policy can change while Chrome is 179 // TODO(benwells): Check if enterprise policy can change while Chrome is
185 // running. If it can't this call is probably not needed. 180 // running. If it can't this call is probably not needed.
186 EnsureDSEGeolocationSettingIsValid(); 181 EnsureDSEGeolocationSettingIsValid();
187 182
188 return GetDSEGeolocationPref().setting; 183 return GetDSEGeolocationPref().setting;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 bool SearchGeolocationService::UseConsistentSearchGeolocation() { 312 bool SearchGeolocationService::UseConsistentSearchGeolocation() {
318 return base::FeatureList::IsEnabled(features::kConsistentOmniboxGeolocation); 313 return base::FeatureList::IsEnabled(features::kConsistentOmniboxGeolocation);
319 } 314 }
320 315
321 void SearchGeolocationService::SetSearchEngineDelegateForTest( 316 void SearchGeolocationService::SetSearchEngineDelegateForTest(
322 std::unique_ptr<SearchEngineDelegate> delegate) { 317 std::unique_ptr<SearchEngineDelegate> delegate) {
323 delegate_ = std::move(delegate); 318 delegate_ = std::move(delegate);
324 delegate_->SetDSEChangedCallback(base::Bind( 319 delegate_->SetDSEChangedCallback(base::Bind(
325 &SearchGeolocationService::OnDSEChanged, base::Unretained(this))); 320 &SearchGeolocationService::OnDSEChanged, base::Unretained(this)));
326 } 321 }
327
328 void SearchGeolocationService::SetLocationSettingsForTest(
329 std::unique_ptr<LocationSettings> settings) {
330 location_settings_ = std::move(settings);
331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698