| 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" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 extension_pref_value_map_.get(), | 116 extension_pref_value_map_.get(), |
| 117 ExtensionsBrowserClient::Get()->CreateAppSorting().Pass(), | 117 ExtensionsBrowserClient::Get()->CreateAppSorting().Pass(), |
| 118 extensions_disabled_, | 118 extensions_disabled_, |
| 119 // Guarantee that no two extensions get the same installation time | 119 // Guarantee that no two extensions get the same installation time |
| 120 // stamp and we can reliably assert the installation order in the tests. | 120 // stamp and we can reliably assert the installation order in the tests. |
| 121 scoped_ptr<ExtensionPrefs::TimeProvider>( | 121 scoped_ptr<ExtensionPrefs::TimeProvider>( |
| 122 new IncrementalTimeProvider()))); | 122 new IncrementalTimeProvider()))); |
| 123 } | 123 } |
| 124 | 124 |
| 125 scoped_refptr<Extension> TestExtensionPrefs::AddExtension(std::string name) { | 125 scoped_refptr<Extension> TestExtensionPrefs::AddExtension(std::string name) { |
| 126 DictionaryValue dictionary; | 126 base::DictionaryValue dictionary; |
| 127 dictionary.SetString(manifest_keys::kName, name); | 127 dictionary.SetString(manifest_keys::kName, name); |
| 128 dictionary.SetString(manifest_keys::kVersion, "0.1"); | 128 dictionary.SetString(manifest_keys::kVersion, "0.1"); |
| 129 return AddExtensionWithManifest(dictionary, Manifest::INTERNAL); | 129 return AddExtensionWithManifest(dictionary, Manifest::INTERNAL); |
| 130 } | 130 } |
| 131 | 131 |
| 132 scoped_refptr<Extension> TestExtensionPrefs::AddApp(std::string name) { | 132 scoped_refptr<Extension> TestExtensionPrefs::AddApp(std::string name) { |
| 133 DictionaryValue dictionary; | 133 base::DictionaryValue dictionary; |
| 134 dictionary.SetString(manifest_keys::kName, name); | 134 dictionary.SetString(manifest_keys::kName, name); |
| 135 dictionary.SetString(manifest_keys::kVersion, "0.1"); | 135 dictionary.SetString(manifest_keys::kVersion, "0.1"); |
| 136 dictionary.SetString(manifest_keys::kApp, "true"); | 136 dictionary.SetString(manifest_keys::kApp, "true"); |
| 137 dictionary.SetString(manifest_keys::kLaunchWebURL, "http://example.com"); | 137 dictionary.SetString(manifest_keys::kLaunchWebURL, "http://example.com"); |
| 138 return AddExtensionWithManifest(dictionary, Manifest::INTERNAL); | 138 return AddExtensionWithManifest(dictionary, Manifest::INTERNAL); |
| 139 | 139 |
| 140 } | 140 } |
| 141 | 141 |
| 142 scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifest( | 142 scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifest( |
| 143 const DictionaryValue& manifest, Manifest::Location location) { | 143 const base::DictionaryValue& manifest, Manifest::Location location) { |
| 144 return AddExtensionWithManifestAndFlags(manifest, location, | 144 return AddExtensionWithManifestAndFlags(manifest, location, |
| 145 Extension::NO_FLAGS); | 145 Extension::NO_FLAGS); |
| 146 } | 146 } |
| 147 | 147 |
| 148 scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifestAndFlags( | 148 scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifestAndFlags( |
| 149 const DictionaryValue& manifest, | 149 const base::DictionaryValue& manifest, |
| 150 Manifest::Location location, | 150 Manifest::Location location, |
| 151 int extra_flags) { | 151 int extra_flags) { |
| 152 std::string name; | 152 std::string name; |
| 153 EXPECT_TRUE(manifest.GetString(manifest_keys::kName, &name)); | 153 EXPECT_TRUE(manifest.GetString(manifest_keys::kName, &name)); |
| 154 base::FilePath path = extensions_dir_.AppendASCII(name); | 154 base::FilePath path = extensions_dir_.AppendASCII(name); |
| 155 std::string errors; | 155 std::string errors; |
| 156 scoped_refptr<Extension> extension = Extension::Create( | 156 scoped_refptr<Extension> extension = Extension::Create( |
| 157 path, location, manifest, extra_flags, &errors); | 157 path, location, manifest, extra_flags, &errors); |
| 158 EXPECT_TRUE(extension.get()) << errors; | 158 EXPECT_TRUE(extension.get()) << errors; |
| 159 if (!extension.get()) | 159 if (!extension.get()) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 175 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { | 175 PrefService* TestExtensionPrefs::CreateIncognitoPrefService() const { |
| 176 return pref_service_->CreateIncognitoPrefService( | 176 return pref_service_->CreateIncognitoPrefService( |
| 177 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); | 177 new ExtensionPrefStore(extension_pref_value_map_.get(), true)); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { | 180 void TestExtensionPrefs::set_extensions_disabled(bool extensions_disabled) { |
| 181 extensions_disabled_ = extensions_disabled; | 181 extensions_disabled_ = extensions_disabled; |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace extensions | 184 } // namespace extensions |
| OLD | NEW |