| 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 "chrome/browser/extensions/test_extension_prefs.h" | 5 #include "chrome/browser/extensions/test_extension_prefs.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
| 13 #include "base/prefs/json_pref_store.h" | 13 #include "base/prefs/json_pref_store.h" |
| 14 #include "base/prefs/pref_value_store.h" | 14 #include "base/prefs/pref_value_store.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
| 17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/browser/prefs/pref_service_mock_factory.h" | 19 #include "chrome/browser/prefs/pref_service_mock_factory.h" |
| 20 #include "chrome/browser/prefs/pref_service_syncable.h" | 20 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 21 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 22 #include "components/crx_file/id_util.h" |
| 22 #include "components/pref_registry/pref_registry_syncable.h" | 23 #include "components/pref_registry/pref_registry_syncable.h" |
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 24 #include "extensions/browser/extension_pref_store.h" | 25 #include "extensions/browser/extension_pref_store.h" |
| 25 #include "extensions/browser/extension_pref_value_map.h" | 26 #include "extensions/browser/extension_pref_value_map.h" |
| 26 #include "extensions/browser/extension_prefs.h" | 27 #include "extensions/browser/extension_prefs.h" |
| 27 #include "extensions/browser/extensions_browser_client.h" | 28 #include "extensions/browser/extensions_browser_client.h" |
| 28 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
| 29 #include "extensions/common/manifest_constants.h" | 30 #include "extensions/common/manifest_constants.h" |
| 30 #include "sync/api/string_ordinal.h" | 31 #include "sync/api/string_ordinal.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 std::string name; | 155 std::string name; |
| 155 EXPECT_TRUE(manifest.GetString(manifest_keys::kName, &name)); | 156 EXPECT_TRUE(manifest.GetString(manifest_keys::kName, &name)); |
| 156 base::FilePath path = extensions_dir_.AppendASCII(name); | 157 base::FilePath path = extensions_dir_.AppendASCII(name); |
| 157 std::string errors; | 158 std::string errors; |
| 158 scoped_refptr<Extension> extension = Extension::Create( | 159 scoped_refptr<Extension> extension = Extension::Create( |
| 159 path, location, manifest, extra_flags, &errors); | 160 path, location, manifest, extra_flags, &errors); |
| 160 EXPECT_TRUE(extension.get()) << errors; | 161 EXPECT_TRUE(extension.get()) << errors; |
| 161 if (!extension.get()) | 162 if (!extension.get()) |
| 162 return NULL; | 163 return NULL; |
| 163 | 164 |
| 164 EXPECT_TRUE(Extension::IdIsValid(extension->id())); | 165 EXPECT_TRUE(crx_file::id_util::IdIsValid(extension->id())); |
| 165 prefs_->OnExtensionInstalled(extension.get(), | 166 prefs_->OnExtensionInstalled(extension.get(), |
| 166 Extension::ENABLED, | 167 Extension::ENABLED, |
| 167 syncer::StringOrdinal::CreateInitialOrdinal(), | 168 syncer::StringOrdinal::CreateInitialOrdinal(), |
| 168 std::string()); | 169 std::string()); |
| 169 return extension; | 170 return extension; |
| 170 } | 171 } |
| 171 | 172 |
| 172 std::string TestExtensionPrefs::AddExtensionAndReturnId( | 173 std::string TestExtensionPrefs::AddExtensionAndReturnId( |
| 173 const std::string& name) { | 174 const std::string& name) { |
| 174 scoped_refptr<Extension> extension(AddExtension(name)); | 175 scoped_refptr<Extension> extension(AddExtension(name)); |
| 175 return extension->id(); | 176 return extension->id(); |
| 176 } | 177 } |
| 177 | 178 |
| 178 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { | 179 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { |
| 179 return pref_service_->CreateIncognitoPrefService( | 180 return pref_service_->CreateIncognitoPrefService( |
| 180 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); | 181 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); |
| 181 } | 182 } |
| 182 | 183 |
| 183 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { | 184 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { |
| 184 extensions_disabled_ = extensions_disabled; | 185 extensions_disabled_ = extensions_disabled; |
| 185 } | 186 } |
| 186 | 187 |
| 187 } // namespace extensions | 188 } // namespace extensions |
| OLD | NEW |