| 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 <set> | 5 #include <set> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // SettingsEnforcement can't be forced via --force-fieldtrials in | 141 // SettingsEnforcement can't be forced via --force-fieldtrials in |
| 142 // official builds. | 142 // official builds. |
| 143 true; | 143 true; |
| 144 #else | 144 #else |
| 145 false; | 145 false; |
| 146 #endif | 146 #endif |
| 147 return allowed_from_param || allowed_from_configuration; | 147 return allowed_from_param || allowed_from_configuration; |
| 148 } | 148 } |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 #if defined(OS_CHROMEOS) |
| 152 // PrefHash service has been disabled on ChromeOS: crbug.com/343261 |
| 153 #define MAYBE_PRE_PRE_InitializeUnloadedProfiles DISABLED_PRE_PRE_InitializeUnlo
adedProfiles |
| 154 #define MAYBE_PRE_InitializeUnloadedProfiles DISABLED_PRE_InitializeUnloadedProf
iles |
| 155 #define MAYBE_InitializeUnloadedProfiles DISABLED_InitializeUnloadedProfiles |
| 156 #else |
| 157 #define MAYBE_PRE_PRE_InitializeUnloadedProfiles PRE_PRE_InitializeUnloadedProfi
les |
| 158 #define MAYBE_PRE_InitializeUnloadedProfiles PRE_InitializeUnloadedProfiles |
| 159 #define MAYBE_InitializeUnloadedProfiles InitializeUnloadedProfiles |
| 160 #endif |
| 161 |
| 151 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, | 162 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, |
| 152 PRE_PRE_InitializeUnloadedProfiles) { | 163 MAYBE_PRE_PRE_InitializeUnloadedProfiles) { |
| 153 if (!profiles::IsMultipleProfilesEnabled()) | 164 if (!profiles::IsMultipleProfilesEnabled()) |
| 154 return; | 165 return; |
| 155 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 166 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 156 | 167 |
| 157 // Create an additional profile. | 168 // Create an additional profile. |
| 158 const base::FilePath new_path = | 169 const base::FilePath new_path = |
| 159 profile_manager->GenerateNextProfileDirectoryPath(); | 170 profile_manager->GenerateNextProfileDirectoryPath(); |
| 160 const scoped_refptr<content::MessageLoopRunner> runner( | 171 const scoped_refptr<content::MessageLoopRunner> runner( |
| 161 new content::MessageLoopRunner); | 172 new content::MessageLoopRunner); |
| 162 profile_manager->CreateProfileAsync( | 173 profile_manager->CreateProfileAsync( |
| 163 new_path, | 174 new_path, |
| 164 base::Bind(&OnUnblockOnProfileCreation, runner->QuitClosure()), | 175 base::Bind(&OnUnblockOnProfileCreation, runner->QuitClosure()), |
| 165 base::string16(), | 176 base::string16(), |
| 166 base::string16(), | 177 base::string16(), |
| 167 std::string()); | 178 std::string()); |
| 168 | 179 |
| 169 // Spin to allow profile creation to take place, loop is terminated | 180 // Spin to allow profile creation to take place, loop is terminated |
| 170 // by OnUnblockOnProfileCreation when the profile is created. | 181 // by OnUnblockOnProfileCreation when the profile is created. |
| 171 runner->Run(); | 182 runner->Run(); |
| 172 | 183 |
| 173 // No profile should have gone through the unloaded profile initialization in | 184 // No profile should have gone through the unloaded profile initialization in |
| 174 // this phase as both profiles should have been loaded normally. | 185 // this phase as both profiles should have been loaded normally. |
| 175 EXPECT_EQ( | 186 EXPECT_EQ( |
| 176 0, GetTrackedPrefHistogramCount( | 187 0, GetTrackedPrefHistogramCount( |
| 177 "Settings.TrackedPreferencesAlternateStoreVersionUpdatedFrom", | 188 "Settings.TrackedPreferencesAlternateStoreVersionUpdatedFrom", |
| 178 true)); | 189 true)); |
| 179 } | 190 } |
| 180 | 191 |
| 181 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, | 192 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, |
| 182 PRE_InitializeUnloadedProfiles) { | 193 MAYBE_PRE_InitializeUnloadedProfiles) { |
| 183 if (!profiles::IsMultipleProfilesEnabled()) | 194 if (!profiles::IsMultipleProfilesEnabled()) |
| 184 return; | 195 return; |
| 185 | 196 |
| 186 // Creating the profile would have initialized its hash store. Also, we don't | 197 // Creating the profile would have initialized its hash store. Also, we don't |
| 187 // know whether the newly created or original profile will be launched (does | 198 // know whether the newly created or original profile will be launched (does |
| 188 // creating a profile cause it to be the most recently used?). | 199 // creating a profile cause it to be the most recently used?). |
| 189 | 200 |
| 190 // So we will find the profile that isn't loaded, reset its hash store, and | 201 // So we will find the profile that isn't loaded, reset its hash store, and |
| 191 // then verify in the _next_ launch that it is, indeed, restored despite not | 202 // then verify in the _next_ launch that it is, indeed, restored despite not |
| 192 // having been loaded. | 203 // having been loaded. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 209 // this phase as both profiles were already initialized at the beginning of | 220 // this phase as both profiles were already initialized at the beginning of |
| 210 // this phase (resetting the unloaded profile's PrefHashStore should only | 221 // this phase (resetting the unloaded profile's PrefHashStore should only |
| 211 // force initialization in the next phase's startup). | 222 // force initialization in the next phase's startup). |
| 212 EXPECT_EQ( | 223 EXPECT_EQ( |
| 213 0, GetTrackedPrefHistogramCount( | 224 0, GetTrackedPrefHistogramCount( |
| 214 "Settings.TrackedPreferencesAlternateStoreVersionUpdatedFrom", | 225 "Settings.TrackedPreferencesAlternateStoreVersionUpdatedFrom", |
| 215 true)); | 226 true)); |
| 216 } | 227 } |
| 217 | 228 |
| 218 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, | 229 IN_PROC_BROWSER_TEST_P(PrefHashBrowserTest, |
| 219 InitializeUnloadedProfiles) { | 230 MAYBE_InitializeUnloadedProfiles) { |
| 220 if (!profiles::IsMultipleProfilesEnabled()) | 231 if (!profiles::IsMultipleProfilesEnabled()) |
| 221 return; | 232 return; |
| 222 | 233 |
| 223 const base::DictionaryValue* hashes = | 234 const base::DictionaryValue* hashes = |
| 224 g_browser_process->local_state()->GetDictionary( | 235 g_browser_process->local_state()->GetDictionary( |
| 225 prefs::kProfilePreferenceHashes); | 236 prefs::kProfilePreferenceHashes); |
| 226 | 237 |
| 227 // The deleted hash collection should be restored only if the current | 238 // The deleted hash collection should be restored only if the current |
| 228 // SettingsEnforcement group allows it. | 239 // SettingsEnforcement group allows it. |
| 229 if (is_unloaded_profile_seeding_allowed_) { | 240 if (is_unloaded_profile_seeding_allowed_) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 313 } |
| 303 } | 314 } |
| 304 | 315 |
| 305 INSTANTIATE_TEST_CASE_P( | 316 INSTANTIATE_TEST_CASE_P( |
| 306 PrefHashBrowserTestInstance, | 317 PrefHashBrowserTestInstance, |
| 307 PrefHashBrowserTest, | 318 PrefHashBrowserTest, |
| 308 testing::Values( | 319 testing::Values( |
| 309 chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement, | 320 chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement, |
| 310 chrome_prefs::internals::kSettingsEnforcementGroupEnforceOnload, | 321 chrome_prefs::internals::kSettingsEnforcementGroupEnforceOnload, |
| 311 chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways)); | 322 chrome_prefs::internals::kSettingsEnforcementGroupEnforceAlways)); |
| OLD | NEW |