| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/content_settings/content_settings_pref_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/browser/content_settings/content_settings_mock_observer.h" | 9 #include "chrome/browser/content_settings/content_settings_mock_observer.h" |
| 10 #include "chrome/browser/prefs/browser_prefs.h" | 10 #include "chrome/browser/prefs/browser_prefs.h" |
| 11 #include "chrome/browser/prefs/default_pref_store.h" | 11 #include "chrome/browser/prefs/default_pref_store.h" |
| 12 #include "chrome/browser/prefs/incognito_user_pref_store.h" | 12 #include "chrome/browser/prefs/incognito_user_pref_store.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 14 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
| 15 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 15 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 16 #include "chrome/browser/prefs/testing_pref_store.h" | 16 #include "chrome/browser/prefs/testing_pref_store.h" |
| 17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 20 #include "chrome/test/base/testing_browser_process_test.h" | |
| 21 #include "chrome/test/base/testing_pref_service.h" | 20 #include "chrome/test/base/testing_pref_service.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 23 #include "content/browser/browser_thread.h" | 22 #include "content/browser/browser_thread.h" |
| 24 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 25 |
| 27 using ::testing::_; | 26 using ::testing::_; |
| 28 | 27 |
| 29 namespace { | 28 namespace { |
| 30 | 29 |
| 31 void ExpectObsoleteGeolocationSetting( | 30 void ExpectObsoleteGeolocationSetting( |
| 32 const DictionaryValue& geo_settings_dictionary, | 31 const DictionaryValue& geo_settings_dictionary, |
| 33 const GURL& primary_origin, | 32 const GURL& primary_origin, |
| 34 const GURL& secondary_origin, | 33 const GURL& secondary_origin, |
| 35 ContentSetting expected_setting) { | 34 ContentSetting expected_setting) { |
| 36 | 35 |
| 37 DictionaryValue* one_origin_settings; | 36 DictionaryValue* one_origin_settings; |
| 38 ASSERT_TRUE(geo_settings_dictionary.GetDictionaryWithoutPathExpansion( | 37 ASSERT_TRUE(geo_settings_dictionary.GetDictionaryWithoutPathExpansion( |
| 39 std::string(primary_origin.spec()), &one_origin_settings)); | 38 std::string(primary_origin.spec()), &one_origin_settings)); |
| 40 int setting_value; | 39 int setting_value; |
| 41 ASSERT_TRUE(one_origin_settings->GetIntegerWithoutPathExpansion( | 40 ASSERT_TRUE(one_origin_settings->GetIntegerWithoutPathExpansion( |
| 42 std::string(secondary_origin.spec()), &setting_value)); | 41 std::string(secondary_origin.spec()), &setting_value)); |
| 43 EXPECT_EQ(expected_setting, setting_value); | 42 EXPECT_EQ(expected_setting, setting_value); |
| 44 } | 43 } |
| 45 | 44 |
| 46 } // namespace | 45 } // namespace |
| 47 | 46 |
| 48 namespace content_settings { | 47 namespace content_settings { |
| 49 | 48 |
| 50 class PrefDefaultProviderTest : public TestingBrowserProcessTest { | 49 class PrefDefaultProviderTest : public testing::Test { |
| 51 public: | 50 public: |
| 52 PrefDefaultProviderTest() | 51 PrefDefaultProviderTest() |
| 53 : ui_thread_(BrowserThread::UI, &message_loop_), | 52 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 54 provider_(profile_.GetPrefs(), false) { | 53 provider_(profile_.GetPrefs(), false) { |
| 55 } | 54 } |
| 56 ~PrefDefaultProviderTest() { | 55 ~PrefDefaultProviderTest() { |
| 57 provider_.ShutdownOnUIThread(); | 56 provider_.ShutdownOnUIThread(); |
| 58 } | 57 } |
| 59 | 58 |
| 60 protected: | 59 protected: |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 208 |
| 210 bool SettingsEqual(const ContentSettings& settings1, | 209 bool SettingsEqual(const ContentSettings& settings1, |
| 211 const ContentSettings& settings2) { | 210 const ContentSettings& settings2) { |
| 212 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 211 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 213 if (settings1.settings[i] != settings2.settings[i]) | 212 if (settings1.settings[i] != settings2.settings[i]) |
| 214 return false; | 213 return false; |
| 215 } | 214 } |
| 216 return true; | 215 return true; |
| 217 } | 216 } |
| 218 | 217 |
| 219 class PrefProviderTest : public TestingBrowserProcessTest { | 218 class PrefProviderTest : public testing::Test { |
| 220 public: | 219 public: |
| 221 PrefProviderTest() : ui_thread_( | 220 PrefProviderTest() : ui_thread_( |
| 222 BrowserThread::UI, &message_loop_) { | 221 BrowserThread::UI, &message_loop_) { |
| 223 } | 222 } |
| 224 | 223 |
| 225 protected: | 224 protected: |
| 226 MessageLoop message_loop_; | 225 MessageLoop message_loop_; |
| 227 BrowserThread ui_thread_; | 226 BrowserThread ui_thread_; |
| 228 }; | 227 }; |
| 229 | 228 |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 728 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 730 provider.GetContentSetting( | 729 provider.GetContentSetting( |
| 731 primary_url, | 730 primary_url, |
| 732 secondary_url, | 731 secondary_url, |
| 733 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | 732 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 734 std::string())); | 733 std::string())); |
| 735 provider.ShutdownOnUIThread(); | 734 provider.ShutdownOnUIThread(); |
| 736 } | 735 } |
| 737 | 736 |
| 738 } // namespace content_settings | 737 } // namespace content_settings |
| OLD | NEW |