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.h" | 11 #include "base/message_loop.h" |
12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/extensions/extension_pref_store.h" | 15 #include "chrome/browser/extensions/extension_pref_store.h" |
16 #include "chrome/browser/extensions/extension_pref_value_map.h" | 16 #include "chrome/browser/extensions/extension_pref_value_map.h" |
17 #include "chrome/browser/extensions/extension_prefs.h" | 17 #include "chrome/browser/extensions/extension_prefs.h" |
18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
19 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 19 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
20 #include "chrome/browser/prefs/pref_value_store.h" | 20 #include "chrome/browser/prefs/pref_value_store.h" |
21 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
22 #include "chrome/common/extensions/extension_manifest_constants.h" | 22 #include "chrome/common/extensions/extension_manifest_constants.h" |
23 #include "chrome/common/json_pref_store.h" | 23 #include "chrome/common/json_pref_store.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "sync/api/string_ordinal.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
26 | 27 |
27 using content::BrowserThread; | 28 using content::BrowserThread; |
28 | 29 |
29 namespace extensions { | 30 namespace extensions { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 // Mock ExtensionPrefs class with artificial clock to guarantee that no two | 34 // Mock ExtensionPrefs class with artificial clock to guarantee that no two |
34 // extensions get the same installation time stamp and we can reliably | 35 // extensions get the same installation time stamp and we can reliably |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 std::string errors; | 140 std::string errors; |
140 scoped_refptr<Extension> extension = Extension::Create( | 141 scoped_refptr<Extension> extension = Extension::Create( |
141 path, location, manifest, extra_flags, &errors); | 142 path, location, manifest, extra_flags, &errors); |
142 EXPECT_TRUE(extension) << errors; | 143 EXPECT_TRUE(extension) << errors; |
143 if (!extension) | 144 if (!extension) |
144 return NULL; | 145 return NULL; |
145 | 146 |
146 EXPECT_TRUE(Extension::IdIsValid(extension->id())); | 147 EXPECT_TRUE(Extension::IdIsValid(extension->id())); |
147 prefs_->OnExtensionInstalled(extension, Extension::ENABLED, | 148 prefs_->OnExtensionInstalled(extension, Extension::ENABLED, |
148 extra_flags & Extension::FROM_WEBSTORE, | 149 extra_flags & Extension::FROM_WEBSTORE, |
149 StringOrdinal::CreateInitialOrdinal()); | 150 syncer::StringOrdinal::CreateInitialOrdinal()); |
150 return extension; | 151 return extension; |
151 } | 152 } |
152 | 153 |
153 std::string TestExtensionPrefs::AddExtensionAndReturnId(std::string name) { | 154 std::string TestExtensionPrefs::AddExtensionAndReturnId(std::string name) { |
154 scoped_refptr<Extension> extension(AddExtension(name)); | 155 scoped_refptr<Extension> extension(AddExtension(name)); |
155 return extension->id(); | 156 return extension->id(); |
156 } | 157 } |
157 | 158 |
158 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { | 159 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { |
159 return pref_service_->CreateIncognitoPrefService( | 160 return pref_service_->CreateIncognitoPrefService( |
160 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); | 161 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); |
161 } | 162 } |
162 | 163 |
163 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { | 164 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { |
164 extensions_disabled_ = extensions_disabled; | 165 extensions_disabled_ = extensions_disabled; |
165 } | 166 } |
166 | 167 |
167 } // namespace extensions | 168 } // namespace extensions |
OLD | NEW |