| 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/preferences_mock_mac.h" | 5 #include "chrome/browser/preferences_mock_mac.h" |
| 6 | 6 |
| 7 MockPreferences::MockPreferences() { | 7 MockPreferences::MockPreferences() { |
| 8 values_.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, | 8 values_.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, |
| 9 0, | 9 0, |
| 10 &kCFTypeDictionaryKeyCallBacks, | 10 &kCFTypeDictionaryKeyCallBacks, |
| 11 &kCFTypeDictionaryValueCallBacks)); | 11 &kCFTypeDictionaryValueCallBacks)); |
| 12 forced_.reset(CFSetCreateMutable(kCFAllocatorDefault, | 12 forced_.reset(CFSetCreateMutable(kCFAllocatorDefault, |
| 13 0, | 13 0, |
| 14 &kCFTypeSetCallBacks)); | 14 &kCFTypeSetCallBacks)); |
| 15 } | 15 } |
| 16 | 16 |
| 17 MockPreferences::~MockPreferences() { | 17 MockPreferences::~MockPreferences() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 Boolean MockPreferences::AppSynchronize(CFStringRef applicationID) { |
| 21 return true; |
| 22 } |
| 20 | 23 |
| 21 CFPropertyListRef MockPreferences::CopyAppValue(CFStringRef key, | 24 CFPropertyListRef MockPreferences::CopyAppValue(CFStringRef key, |
| 22 CFStringRef applicationID) { | 25 CFStringRef applicationID) { |
| 23 CFPropertyListRef value; | 26 CFPropertyListRef value; |
| 24 Boolean found = CFDictionaryGetValueIfPresent(values_, | 27 Boolean found = CFDictionaryGetValueIfPresent(values_, |
| 25 key, | 28 key, |
| 26 &value); | 29 &value); |
| 27 if (!found || !value) | 30 if (!found || !value) |
| 28 return NULL; | 31 return NULL; |
| 29 CFRetain(value); | 32 CFRetain(value); |
| 30 return value; | 33 return value; |
| 31 } | 34 } |
| 32 | 35 |
| 33 Boolean MockPreferences::AppValueIsForced(CFStringRef key, | 36 Boolean MockPreferences::AppValueIsForced(CFStringRef key, |
| 34 CFStringRef applicationID) { | 37 CFStringRef applicationID) { |
| 35 return CFSetContainsValue(forced_, key); | 38 return CFSetContainsValue(forced_, key); |
| 36 } | 39 } |
| 37 | 40 |
| 38 void MockPreferences::AddTestItem(CFStringRef key, | 41 void MockPreferences::AddTestItem(CFStringRef key, |
| 39 CFPropertyListRef value, | 42 CFPropertyListRef value, |
| 40 bool is_forced) { | 43 bool is_forced) { |
| 41 CFDictionarySetValue(values_, key, value); | 44 CFDictionarySetValue(values_, key, value); |
| 42 if (is_forced) | 45 if (is_forced) |
| 43 CFSetAddValue(forced_, key); | 46 CFSetAddValue(forced_, key); |
| 44 } | 47 } |
| OLD | NEW |