OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/net/safe_search_util.h" | |
13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/profiles/profile_attributes_entry.h" | 13 #include "chrome/browser/profiles/profile_attributes_entry.h" |
15 #include "chrome/browser/profiles/profile_attributes_storage.h" | 14 #include "chrome/browser/profiles/profile_attributes_storage.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 16 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
18 #include "chrome/browser/supervised_user/supervised_user_service.h" | 17 #include "chrome/browser/supervised_user/supervised_user_service.h" |
19 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 18 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
20 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 19 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
21 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" | 20 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" |
22 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 profile, | 80 profile, |
82 GoogleServiceAuthError(GoogleServiceAuthError::NONE), | 81 GoogleServiceAuthError(GoogleServiceAuthError::NONE), |
83 std::string("abcdef")); | 82 std::string("abcdef")); |
84 EXPECT_FALSE(entry->IsOmitted()); | 83 EXPECT_FALSE(entry->IsOmitted()); |
85 } | 84 } |
86 | 85 |
87 IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTest, LocalPolicies) { | 86 IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTest, LocalPolicies) { |
88 Profile* profile = browser()->profile(); | 87 Profile* profile = browser()->profile(); |
89 PrefService* prefs = profile->GetPrefs(); | 88 PrefService* prefs = profile->GetPrefs(); |
90 EXPECT_FALSE(prefs->GetBoolean(prefs::kForceGoogleSafeSearch)); | 89 EXPECT_FALSE(prefs->GetBoolean(prefs::kForceGoogleSafeSearch)); |
91 EXPECT_EQ(prefs->GetInteger(prefs::kForceYouTubeRestrict), | 90 EXPECT_FALSE(prefs->GetBoolean(prefs::kForceYouTubeSafetyMode)); |
92 safe_search_util::YOUTUBE_RESTRICT_OFF); | |
93 EXPECT_TRUE(prefs->IsUserModifiablePreference(prefs::kForceGoogleSafeSearch)); | 91 EXPECT_TRUE(prefs->IsUserModifiablePreference(prefs::kForceGoogleSafeSearch)); |
94 EXPECT_TRUE(prefs->IsUserModifiablePreference(prefs::kForceYouTubeRestrict)); | 92 EXPECT_TRUE( |
| 93 prefs->IsUserModifiablePreference(prefs::kForceYouTubeSafetyMode)); |
95 } | 94 } |
96 | 95 |
97 IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTest, ProfileName) { | 96 IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTest, ProfileName) { |
98 Profile* profile = browser()->profile(); | 97 Profile* profile = browser()->profile(); |
99 PrefService* prefs = profile->GetPrefs(); | 98 PrefService* prefs = profile->GetPrefs(); |
100 EXPECT_TRUE(prefs->IsUserModifiablePreference(prefs::kProfileName)); | 99 EXPECT_TRUE(prefs->IsUserModifiablePreference(prefs::kProfileName)); |
101 | 100 |
102 std::string original_name = prefs->GetString(prefs::kProfileName); | 101 std::string original_name = prefs->GetString(prefs::kProfileName); |
103 ProfileAttributesEntry* entry; | 102 ProfileAttributesEntry* entry; |
104 ASSERT_TRUE(g_browser_process->profile_manager()-> | 103 ASSERT_TRUE(g_browser_process->profile_manager()-> |
105 GetProfileAttributesStorage(). | 104 GetProfileAttributesStorage(). |
106 GetProfileAttributesWithPath(profile->GetPath(), &entry)); | 105 GetProfileAttributesWithPath(profile->GetPath(), &entry)); |
107 EXPECT_EQ(original_name, base::UTF16ToUTF8(entry->GetName())); | 106 EXPECT_EQ(original_name, base::UTF16ToUTF8(entry->GetName())); |
108 } | 107 } |
109 | 108 |
110 IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTestSupervised, LocalPolicies) { | 109 IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTestSupervised, LocalPolicies) { |
111 Profile* profile = browser()->profile(); | 110 Profile* profile = browser()->profile(); |
112 PrefService* prefs = profile->GetPrefs(); | 111 PrefService* prefs = profile->GetPrefs(); |
113 EXPECT_TRUE(prefs->GetBoolean(prefs::kForceGoogleSafeSearch)); | 112 EXPECT_TRUE(prefs->GetBoolean(prefs::kForceGoogleSafeSearch)); |
114 EXPECT_EQ(prefs->GetInteger(prefs::kForceYouTubeRestrict), | 113 EXPECT_TRUE(prefs->GetBoolean(prefs::kForceYouTubeSafetyMode)); |
115 safe_search_util::YOUTUBE_RESTRICT_MODERATE); | |
116 EXPECT_FALSE( | 114 EXPECT_FALSE( |
117 prefs->IsUserModifiablePreference(prefs::kForceGoogleSafeSearch)); | 115 prefs->IsUserModifiablePreference(prefs::kForceGoogleSafeSearch)); |
118 EXPECT_FALSE(prefs->IsUserModifiablePreference(prefs::kForceYouTubeRestrict)); | 116 EXPECT_FALSE( |
| 117 prefs->IsUserModifiablePreference(prefs::kForceYouTubeSafetyMode)); |
119 } | 118 } |
120 | 119 |
121 IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTestSupervised, ProfileName) { | 120 IN_PROC_BROWSER_TEST_F(SupervisedUserServiceTestSupervised, ProfileName) { |
122 Profile* profile = browser()->profile(); | 121 Profile* profile = browser()->profile(); |
123 PrefService* prefs = profile->GetPrefs(); | 122 PrefService* prefs = profile->GetPrefs(); |
124 std::string original_name = prefs->GetString(prefs::kProfileName); | 123 std::string original_name = prefs->GetString(prefs::kProfileName); |
125 | 124 |
126 SupervisedUserSettingsService* settings = | 125 SupervisedUserSettingsService* settings = |
127 SupervisedUserSettingsServiceFactory::GetForProfile(profile); | 126 SupervisedUserSettingsServiceFactory::GetForProfile(profile); |
128 | 127 |
(...skipping 19 matching lines...) Expand all Loading... |
148 std::unique_ptr<base::Value>(new base::StringValue(new_name))); | 147 std::unique_ptr<base::Value>(new base::StringValue(new_name))); |
149 EXPECT_EQ(new_name, prefs->GetString(prefs::kProfileName)); | 148 EXPECT_EQ(new_name, prefs->GetString(prefs::kProfileName)); |
150 EXPECT_EQ(new_name, base::UTF16ToUTF8(entry->GetName())); | 149 EXPECT_EQ(new_name, base::UTF16ToUTF8(entry->GetName())); |
151 | 150 |
152 // Remove the setting. | 151 // Remove the setting. |
153 settings->SetLocalSetting(supervised_users::kUserName, | 152 settings->SetLocalSetting(supervised_users::kUserName, |
154 std::unique_ptr<base::Value>()); | 153 std::unique_ptr<base::Value>()); |
155 EXPECT_EQ(original_name, prefs->GetString(prefs::kProfileName)); | 154 EXPECT_EQ(original_name, prefs->GetString(prefs::kProfileName)); |
156 EXPECT_EQ(original_name, base::UTF16ToUTF8(entry->GetName())); | 155 EXPECT_EQ(original_name, base::UTF16ToUTF8(entry->GetName())); |
157 } | 156 } |
OLD | NEW |