| 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/extensions/test_extension_prefs.h" | 5 #include "chrome/browser/extensions/test_extension_prefs.h" |
| 6 | 6 |
| 7 | 7 |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // The PrefService writes its persistent file on the file thread, so we | 35 // The PrefService writes its persistent file on the file thread, so we |
| 36 // need to wait for any pending I/O to complete before creating a new | 36 // need to wait for any pending I/O to complete before creating a new |
| 37 // PrefService. | 37 // PrefService. |
| 38 MessageLoop file_loop; | 38 MessageLoop file_loop; |
| 39 ChromeThread file_thread(ChromeThread::FILE, &file_loop); | 39 ChromeThread file_thread(ChromeThread::FILE, &file_loop); |
| 40 pref_service_->SavePersistentPrefs(); | 40 pref_service_->SavePersistentPrefs(); |
| 41 file_loop.RunAllPending(); | 41 file_loop.RunAllPending(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Create a |PrefService| instance that contains only user defined values. | 44 // Create a |PrefService| instance that contains only user defined values. |
| 45 pref_service_.reset(new PrefService(new PrefValueStore( | 45 pref_service_.reset(PrefService::CreateUserPrefService(preferences_file_)); |
| 46 NULL, /* no managed preference values */ | |
| 47 new JsonPrefStore( /* user defined preferemnce values*/ | |
| 48 preferences_file_, | |
| 49 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)), | |
| 50 NULL /* no suggested preference values*/))); | |
| 51 ExtensionPrefs::RegisterUserPrefs(pref_service_.get()); | 46 ExtensionPrefs::RegisterUserPrefs(pref_service_.get()); |
| 52 prefs_.reset(new ExtensionPrefs(pref_service_.get(), temp_dir_.path())); | 47 prefs_.reset(new ExtensionPrefs(pref_service_.get(), temp_dir_.path())); |
| 53 } | 48 } |
| 54 | 49 |
| 55 Extension* TestExtensionPrefs::AddExtension(std::string name) { | 50 Extension* TestExtensionPrefs::AddExtension(std::string name) { |
| 56 DictionaryValue dictionary; | 51 DictionaryValue dictionary; |
| 57 dictionary.SetString(extension_manifest_keys::kName, name); | 52 dictionary.SetString(extension_manifest_keys::kName, name); |
| 58 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); | 53 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); |
| 59 return AddExtensionWithManifest(dictionary); | 54 return AddExtensionWithManifest(dictionary); |
| 60 } | 55 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 72 const bool kInitialIncognitoEnabled = false; | 67 const bool kInitialIncognitoEnabled = false; |
| 73 prefs_->OnExtensionInstalled(extension, Extension::ENABLED, | 68 prefs_->OnExtensionInstalled(extension, Extension::ENABLED, |
| 74 kInitialIncognitoEnabled); | 69 kInitialIncognitoEnabled); |
| 75 return extension; | 70 return extension; |
| 76 } | 71 } |
| 77 | 72 |
| 78 std::string TestExtensionPrefs::AddExtensionAndReturnId(std::string name) { | 73 std::string TestExtensionPrefs::AddExtensionAndReturnId(std::string name) { |
| 79 scoped_ptr<Extension> extension(AddExtension(name)); | 74 scoped_ptr<Extension> extension(AddExtension(name)); |
| 80 return extension->id(); | 75 return extension->id(); |
| 81 } | 76 } |
| OLD | NEW |