| OLD | NEW | 
|     1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |     1 // Copyright (c) 2010 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/host_content_settings_map.h" |     5 #include "chrome/browser/host_content_settings_map.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 "base/json/json_reader.h" |     9 #include "base/json/json_reader.h" | 
|    10 #include "base/json/json_writer.h" |    10 #include "base/json/json_writer.h" | 
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   977   EXPECT_EQ(CONTENT_SETTING_ALLOW, |   977   EXPECT_EQ(CONTENT_SETTING_ALLOW, | 
|   978             host_content_settings_map->GetDefaultContentSetting( |   978             host_content_settings_map->GetDefaultContentSetting( | 
|   979                 CONTENT_SETTINGS_TYPE_PLUGINS)); |   979                 CONTENT_SETTINGS_TYPE_PLUGINS)); | 
|   980  |   980  | 
|   981   prefs->RemoveManagedPref(prefs::kManagedDefaultPluginsSetting); |   981   prefs->RemoveManagedPref(prefs::kManagedDefaultPluginsSetting); | 
|   982   EXPECT_EQ(CONTENT_SETTING_BLOCK, |   982   EXPECT_EQ(CONTENT_SETTING_BLOCK, | 
|   983             host_content_settings_map->GetDefaultContentSetting( |   983             host_content_settings_map->GetDefaultContentSetting( | 
|   984                 CONTENT_SETTINGS_TYPE_PLUGINS)); |   984                 CONTENT_SETTINGS_TYPE_PLUGINS)); | 
|   985 } |   985 } | 
|   986  |   986  | 
 |   987 TEST_F(HostContentSettingsMapTest, ResetToDefaultsWhenManaged) { | 
 |   988   TestingProfile profile; | 
 |   989   HostContentSettingsMap* host_content_settings_map = | 
 |   990       profile.GetHostContentSettingsMap(); | 
 |   991   TestingPrefService* prefs = profile.GetTestingPrefService(); | 
 |   992  | 
 |   993   prefs->SetManagedPref(prefs::kBlockThirdPartyCookies, | 
 |   994                         Value::CreateBooleanValue(true)); | 
 |   995   prefs->SetUserPref(prefs::kBlockThirdPartyCookies, | 
 |   996                      Value::CreateBooleanValue(true)); | 
 |   997  | 
 |   998   EXPECT_EQ(true, | 
 |   999             host_content_settings_map->IsBlockThirdPartyCookiesManaged()); | 
 |  1000   EXPECT_EQ(true, host_content_settings_map->BlockThirdPartyCookies()); | 
 |  1001  | 
 |  1002   // Reset to the default value (false). | 
 |  1003   host_content_settings_map->ResetToDefaults(); | 
 |  1004   // Since the preference BlockThirdPartyCookies is managed the | 
 |  1005   // HostContentSettingsMap should still return the managed value which is true. | 
 |  1006   EXPECT_EQ(true, | 
 |  1007             host_content_settings_map->IsBlockThirdPartyCookiesManaged()); | 
 |  1008   EXPECT_EQ(true, host_content_settings_map->BlockThirdPartyCookies()); | 
 |  1009  | 
 |  1010   // After unsetting the managed value for the preference BlockThirdPartyCookies | 
 |  1011   // the default value should be returned now. | 
 |  1012   prefs->RemoveManagedPref(prefs::kBlockThirdPartyCookies); | 
 |  1013   EXPECT_EQ(false, | 
 |  1014             host_content_settings_map->IsBlockThirdPartyCookiesManaged()); | 
 |  1015   EXPECT_EQ(false, host_content_settings_map->BlockThirdPartyCookies()); | 
 |  1016 } | 
 |  1017  | 
|   987 }  // namespace |  1018 }  // namespace | 
| OLD | NEW |