| OLD | NEW |
| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/test/scoped_feature_list.h" | 13 #include "base/test/scoped_feature_list.h" |
| 14 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur
e_tab_helper.h" | 14 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur
e_tab_helper.h" |
| 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 16 #include "chrome/browser/permissions/permission_decision_auto_blocker.h" |
| 17 #include "chrome/browser/permissions/permission_result.h" |
| 16 #include "chrome/common/chrome_features.h" | 18 #include "chrome/common/chrome_features.h" |
| 17 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 19 #include "components/content_settings/core/browser/host_content_settings_map.h" | 21 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 20 #include "components/content_settings/core/common/pref_names.h" | 22 #include "components/content_settings/core/common/pref_names.h" |
| 21 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
| 22 #include "components/sync_preferences/testing_pref_service_syncable.h" | 24 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 23 #include "content/public/test/test_browser_thread_bundle.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "url/origin.h" | 27 #include "url/origin.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 EXPECT_TRUE(SearchGeolocationDisclosureTabHelper::IsDisclosureResetForTests( | 369 EXPECT_TRUE(SearchGeolocationDisclosureTabHelper::IsDisclosureResetForTests( |
| 368 profile())); | 370 profile())); |
| 369 SearchGeolocationDisclosureTabHelper::FakeShowingDisclosureForTests( | 371 SearchGeolocationDisclosureTabHelper::FakeShowingDisclosureForTests( |
| 370 profile()); | 372 profile()); |
| 371 | 373 |
| 372 // Go back to google.com.au. The disclosure should again be reset. | 374 // Go back to google.com.au. The disclosure should again be reset. |
| 373 test_delegate()->SetDSEOrigin(kGoogleAusURL); | 375 test_delegate()->SetDSEOrigin(kGoogleAusURL); |
| 374 EXPECT_TRUE(SearchGeolocationDisclosureTabHelper::IsDisclosureResetForTests( | 376 EXPECT_TRUE(SearchGeolocationDisclosureTabHelper::IsDisclosureResetForTests( |
| 375 profile())); | 377 profile())); |
| 376 } | 378 } |
| 379 |
| 380 TEST_F(SearchGeolocationServiceTest, Embargo) { |
| 381 test_delegate()->SetDSEOrigin(kGoogleURL); |
| 382 |
| 383 // Place another origin under embargo. |
| 384 GURL google_aus_url(kGoogleAusURL); |
| 385 PermissionDecisionAutoBlocker* auto_blocker = |
| 386 PermissionDecisionAutoBlocker::GetForProfile(profile()); |
| 387 auto_blocker->RecordDismissAndEmbargo(google_aus_url, |
| 388 CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 389 auto_blocker->RecordDismissAndEmbargo(google_aus_url, |
| 390 CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 391 auto_blocker->RecordDismissAndEmbargo(google_aus_url, |
| 392 CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 393 PermissionResult result = auto_blocker->GetEmbargoResult( |
| 394 GURL(kGoogleAusURL), CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 395 EXPECT_EQ(result.source, PermissionStatusSource::MULTIPLE_DISMISSALS); |
| 396 EXPECT_EQ(result.content_setting, CONTENT_SETTING_BLOCK); |
| 397 |
| 398 // Now change the DSE to this origin and make sure the embargo is cleared. |
| 399 test_delegate()->SetDSEOrigin(kGoogleAusURL); |
| 400 result = auto_blocker->GetEmbargoResult(GURL(kGoogleAusURL), |
| 401 CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 402 EXPECT_EQ(result.source, PermissionStatusSource::UNSPECIFIED); |
| 403 EXPECT_EQ(result.content_setting, CONTENT_SETTING_ASK); |
| 404 } |
| OLD | NEW |