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