| 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/component_loader.h" | 5 #include "chrome/browser/extensions/component_loader.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (extension_service_->is_ready()) | 147 if (extension_service_->is_ready()) |
| 148 Load(info); | 148 Load(info); |
| 149 return info.extension_id; | 149 return info.extension_id; |
| 150 } | 150 } |
| 151 | 151 |
| 152 std::string ComponentLoader::AddOrReplace(const base::FilePath& path) { | 152 std::string ComponentLoader::AddOrReplace(const base::FilePath& path) { |
| 153 base::FilePath absolute_path = base::MakeAbsoluteFilePath(path); | 153 base::FilePath absolute_path = base::MakeAbsoluteFilePath(path); |
| 154 std::string error; | 154 std::string error; |
| 155 scoped_ptr<DictionaryValue> manifest( | 155 scoped_ptr<DictionaryValue> manifest( |
| 156 extension_file_util::LoadManifest(absolute_path, &error)); | 156 extension_file_util::LoadManifest(absolute_path, &error)); |
| 157 if (!manifest.get()) { | 157 if (!manifest) { |
| 158 LOG(ERROR) << "Could not load extension from '" << | 158 LOG(ERROR) << "Could not load extension from '" << |
| 159 absolute_path.value() << "'. " << error; | 159 absolute_path.value() << "'. " << error; |
| 160 return NULL; | 160 return NULL; |
| 161 } | 161 } |
| 162 Remove(GenerateId(manifest.get(), absolute_path)); | 162 Remove(GenerateId(manifest.get(), absolute_path)); |
| 163 | 163 |
| 164 return Add(manifest.release(), absolute_path); | 164 return Add(manifest.release(), absolute_path); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void ComponentLoader::Reload(const std::string& extension_id) { | 167 void ComponentLoader::Reload(const std::string& extension_id) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 181 int flags = Extension::REQUIRE_KEY; | 181 int flags = Extension::REQUIRE_KEY; |
| 182 | 182 |
| 183 std::string error; | 183 std::string error; |
| 184 | 184 |
| 185 scoped_refptr<const Extension> extension(Extension::Create( | 185 scoped_refptr<const Extension> extension(Extension::Create( |
| 186 info.root_directory, | 186 info.root_directory, |
| 187 Manifest::COMPONENT, | 187 Manifest::COMPONENT, |
| 188 *info.manifest, | 188 *info.manifest, |
| 189 flags, | 189 flags, |
| 190 &error)); | 190 &error)); |
| 191 if (!extension.get()) { | 191 if (!extension) { |
| 192 LOG(ERROR) << error; | 192 LOG(ERROR) << error; |
| 193 return; | 193 return; |
| 194 } | 194 } |
| 195 | 195 |
| 196 CHECK_EQ(info.extension_id, extension->id()) << extension->name(); | 196 CHECK_EQ(info.extension_id, extension->id()) << extension->name(); |
| 197 extension_service_->AddComponentExtension(extension); | 197 extension_service_->AddComponentExtension(extension); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void ComponentLoader::RemoveAll() { | 200 void ComponentLoader::RemoveAll() { |
| 201 RegisteredComponentExtensions::iterator it = component_extensions_.begin(); | 201 RegisteredComponentExtensions::iterator it = component_extensions_.begin(); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 void ComponentLoader::RegisterUserPrefs(PrefRegistrySyncable* registry) { | 475 void ComponentLoader::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
| 476 registry->RegisterStringPref(prefs::kEnterpriseWebStoreURL, | 476 registry->RegisterStringPref(prefs::kEnterpriseWebStoreURL, |
| 477 std::string() /* default_value */, | 477 std::string() /* default_value */, |
| 478 PrefRegistrySyncable::UNSYNCABLE_PREF); | 478 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 479 registry->RegisterStringPref(prefs::kEnterpriseWebStoreName, | 479 registry->RegisterStringPref(prefs::kEnterpriseWebStoreName, |
| 480 std::string() /* default_value */, | 480 std::string() /* default_value */, |
| 481 PrefRegistrySyncable::UNSYNCABLE_PREF); | 481 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 482 } | 482 } |
| 483 | 483 |
| 484 } // namespace extensions | 484 } // namespace extensions |
| OLD | NEW |