OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <map> | 6 #include <map> |
7 #include <sstream> | 7 #include <sstream> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 423 |
424 for (ScopedVector<PrefMapping>::const_iterator | 424 for (ScopedVector<PrefMapping>::const_iterator |
425 pref_mapping = pref_mappings.begin(); | 425 pref_mapping = pref_mappings.begin(); |
426 pref_mapping != pref_mappings.end(); | 426 pref_mapping != pref_mappings.end(); |
427 ++pref_mapping) { | 427 ++pref_mapping) { |
428 // Skip Chrome OS preferences that use a different backend and cannot be | 428 // Skip Chrome OS preferences that use a different backend and cannot be |
429 // retrieved through the prefs mechanism. | 429 // retrieved through the prefs mechanism. |
430 if (StartsWithASCII((*pref_mapping)->pref(), kCrosSettingsPrefix, true)) | 430 if (StartsWithASCII((*pref_mapping)->pref(), kCrosSettingsPrefix, true)) |
431 continue; | 431 continue; |
432 | 432 |
| 433 PrefService* local_state = g_browser_process->local_state(); |
| 434 PrefService* user_prefs = browser()->profile()->GetPrefs(); |
433 PrefService* prefs = (*pref_mapping)->is_local_state() ? | 435 PrefService* prefs = (*pref_mapping)->is_local_state() ? |
434 g_browser_process->local_state() : browser()->profile()->GetPrefs(); | 436 local_state : user_prefs; |
435 // The preference must have been registered. | 437 // The preference must have been registered. |
436 const PrefService::Preference* pref = | 438 const PrefService::Preference* pref = |
437 prefs->FindPreference((*pref_mapping)->pref().c_str()); | 439 prefs->FindPreference((*pref_mapping)->pref().c_str()); |
438 ASSERT_TRUE(pref); | 440 ASSERT_TRUE(pref); |
439 prefs->ClearPref((*pref_mapping)->pref().c_str()); | 441 prefs->ClearPref((*pref_mapping)->pref().c_str()); |
440 | 442 |
441 // Verify that setting the policy overrides the pref. | 443 // Verify that setting the policy overrides the pref. |
442 const PolicyMap kNoPolicies; | 444 const PolicyMap kNoPolicies; |
443 provider_.UpdateChromePolicy(kNoPolicies); | 445 provider_.UpdateChromePolicy(kNoPolicies); |
444 EXPECT_TRUE(pref->IsDefaultValue()); | 446 EXPECT_TRUE(pref->IsDefaultValue()); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); | 515 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER); |
514 provider_.UpdateChromePolicy(policies); | 516 provider_.UpdateChromePolicy(policies); |
515 VerifyControlledSettingIndicators(browser(), indicator_selector, | 517 VerifyControlledSettingIndicators(browser(), indicator_selector, |
516 (*indicator_test_case)->value(), | 518 (*indicator_test_case)->value(), |
517 "policy", | 519 "policy", |
518 (*indicator_test_case)->readonly()); | 520 (*indicator_test_case)->readonly()); |
519 | 521 |
520 if (!policy_test_case->can_be_recommended()) | 522 if (!policy_test_case->can_be_recommended()) |
521 continue; | 523 continue; |
522 | 524 |
| 525 PrefService* local_state = g_browser_process->local_state(); |
| 526 PrefService* user_prefs = browser()->profile()->GetPrefs(); |
523 PrefService* prefs = (*pref_mapping)->is_local_state() ? | 527 PrefService* prefs = (*pref_mapping)->is_local_state() ? |
524 g_browser_process->local_state() : browser()->profile()->GetPrefs(); | 528 local_state : user_prefs; |
525 // The preference must have been registered. | 529 // The preference must have been registered. |
526 const PrefService::Preference* pref = | 530 const PrefService::Preference* pref = |
527 prefs->FindPreference((*pref_mapping)->pref().c_str()); | 531 prefs->FindPreference((*pref_mapping)->pref().c_str()); |
528 ASSERT_TRUE(pref); | 532 ASSERT_TRUE(pref); |
529 | 533 |
530 // Check that the appropriate controlled setting indicator is shown when a | 534 // Check that the appropriate controlled setting indicator is shown when a |
531 // value is recommended by policy and the user has not overridden the | 535 // value is recommended by policy and the user has not overridden the |
532 // recommendation. | 536 // recommendation. |
533 policies.LoadFrom(&(*indicator_test_case)->policy(), | 537 policies.LoadFrom(&(*indicator_test_case)->policy(), |
534 POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER); | 538 POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER); |
(...skipping 15 matching lines...) Expand all Loading... |
550 } | 554 } |
551 } | 555 } |
552 | 556 |
553 INSTANTIATE_TEST_CASE_P( | 557 INSTANTIATE_TEST_CASE_P( |
554 PolicyPrefsTestInstance, | 558 PolicyPrefsTestInstance, |
555 PolicyPrefsTest, | 559 PolicyPrefsTest, |
556 testing::ValuesIn(GetChromePolicyDefinitionList()->begin, | 560 testing::ValuesIn(GetChromePolicyDefinitionList()->begin, |
557 GetChromePolicyDefinitionList()->end)); | 561 GetChromePolicyDefinitionList()->end)); |
558 | 562 |
559 } // namespace policy | 563 } // namespace policy |
OLD | NEW |