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

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

Issue 2941753002: Reset geolocation permission embargo for an origin when it becomes DSE (Closed)
Patch Set: Feedback Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/android/search_geolocation/search_geolocation_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/search_geolocation/search_geolocation_disclosur e_tab_helper.h" 10 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur e_tab_helper.h"
11 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 11 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
12 #include "chrome/browser/permissions/permission_decision_auto_blocker.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/search_engines/template_url_service_factory.h" 14 #include "chrome/browser/search_engines/template_url_service_factory.h"
14 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 15 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
15 #include "chrome/common/chrome_features.h" 16 #include "chrome/common/chrome_features.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "components/content_settings/core/browser/content_settings_utils.h" 18 #include "components/content_settings/core/browser/content_settings_utils.h"
18 #include "components/content_settings/core/browser/host_content_settings_map.h" 19 #include "components/content_settings/core/browser/host_content_settings_map.h"
19 #include "components/content_settings/core/common/content_settings_types.h" 20 #include "components/content_settings/core/common/content_settings_types.h"
20 #include "components/keyed_service/content/browser_context_dependency_manager.h" 21 #include "components/keyed_service/content/browser_context_dependency_manager.h"
21 #include "components/pref_registry/pref_registry_syncable.h" 22 #include "components/pref_registry/pref_registry_syncable.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 delegate_.reset(); 215 delegate_.reset();
215 } 216 }
216 217
217 SearchGeolocationService::~SearchGeolocationService() {} 218 SearchGeolocationService::~SearchGeolocationService() {}
218 219
219 void SearchGeolocationService::OnDSEChanged() { 220 void SearchGeolocationService::OnDSEChanged() {
220 base::string16 new_dse_name = delegate_->GetDSEName(); 221 base::string16 new_dse_name = delegate_->GetDSEName();
221 PrefValue pref = GetDSEGeolocationPref(); 222 PrefValue pref = GetDSEGeolocationPref();
222 ContentSetting content_setting = GetCurrentContentSetting(); 223 ContentSetting content_setting = GetCurrentContentSetting();
223 224
225 // Remove any geolocation embargo on the URL.
226 PermissionDecisionAutoBlocker::GetForProfile(profile_)->RemoveEmbargoByUrl(
227 delegate_->GetDSEOrigin().GetURL(), CONTENT_SETTINGS_TYPE_GEOLOCATION);
224 if (content_setting == CONTENT_SETTING_BLOCK && pref.setting) { 228 if (content_setting == CONTENT_SETTING_BLOCK && pref.setting) {
225 pref.setting = false; 229 pref.setting = false;
226 } else if (content_setting == CONTENT_SETTING_ALLOW && !pref.setting) { 230 } else if (content_setting == CONTENT_SETTING_ALLOW && !pref.setting) {
227 ResetContentSetting(); 231 ResetContentSetting();
228 } 232 }
229 233
230 if (new_dse_name != pref.dse_name && pref.setting) 234 if (new_dse_name != pref.dse_name && pref.setting)
231 SearchGeolocationDisclosureTabHelper::ResetDisclosure(profile_); 235 SearchGeolocationDisclosureTabHelper::ResetDisclosure(profile_);
232 236
233 pref.dse_name = new_dse_name; 237 pref.dse_name = new_dse_name;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 bool SearchGeolocationService::UseConsistentSearchGeolocation() { 348 bool SearchGeolocationService::UseConsistentSearchGeolocation() {
345 return base::FeatureList::IsEnabled(features::kConsistentOmniboxGeolocation); 349 return base::FeatureList::IsEnabled(features::kConsistentOmniboxGeolocation);
346 } 350 }
347 351
348 void SearchGeolocationService::SetSearchEngineDelegateForTest( 352 void SearchGeolocationService::SetSearchEngineDelegateForTest(
349 std::unique_ptr<SearchEngineDelegate> delegate) { 353 std::unique_ptr<SearchEngineDelegate> delegate) {
350 delegate_ = std::move(delegate); 354 delegate_ = std::move(delegate);
351 delegate_->SetDSEChangedCallback(base::Bind( 355 delegate_->SetDSEChangedCallback(base::Bind(
352 &SearchGeolocationService::OnDSEChanged, base::Unretained(this))); 356 &SearchGeolocationService::OnDSEChanged, base::Unretained(this)));
353 } 357 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/search_geolocation/search_geolocation_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698