OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1070 it != component_extension_manifests_.end(); ++it) { | 1070 it != component_extension_manifests_.end(); ++it) { |
1071 LoadComponentExtension(*it); | 1071 LoadComponentExtension(*it); |
1072 } | 1072 } |
1073 } | 1073 } |
1074 | 1074 |
1075 const Extension* ExtensionService::LoadComponentExtension( | 1075 const Extension* ExtensionService::LoadComponentExtension( |
1076 const ComponentExtensionInfo &info) { | 1076 const ComponentExtensionInfo &info) { |
1077 JSONStringValueSerializer serializer(info.manifest); | 1077 JSONStringValueSerializer serializer(info.manifest); |
1078 scoped_ptr<Value> manifest(serializer.Deserialize(NULL, NULL)); | 1078 scoped_ptr<Value> manifest(serializer.Deserialize(NULL, NULL)); |
1079 if (!manifest.get()) { | 1079 if (!manifest.get()) { |
1080 DLOG(ERROR) << "Failed to parse manifest for extension"; | 1080 LOG(ERROR) << "Failed to parse manifest for extension"; |
1081 return NULL; | 1081 return NULL; |
1082 } | 1082 } |
1083 | 1083 |
1084 int flags = Extension::REQUIRE_KEY; | 1084 int flags = Extension::REQUIRE_KEY; |
1085 if (Extension::ShouldDoStrictErrorChecking(Extension::COMPONENT)) | 1085 if (Extension::ShouldDoStrictErrorChecking(Extension::COMPONENT)) |
1086 flags |= Extension::STRICT_ERROR_CHECKS; | 1086 flags |= Extension::STRICT_ERROR_CHECKS; |
1087 std::string error; | 1087 std::string error; |
1088 scoped_refptr<const Extension> extension(Extension::Create( | 1088 scoped_refptr<const Extension> extension(Extension::Create( |
1089 info.root_directory, | 1089 info.root_directory, |
1090 Extension::COMPONENT, | 1090 Extension::COMPONENT, |
1091 *static_cast<DictionaryValue*>(manifest.get()), | 1091 *static_cast<DictionaryValue*>(manifest.get()), |
1092 flags, | 1092 flags, |
1093 &error)); | 1093 &error)); |
1094 if (!extension.get()) { | 1094 if (!extension.get()) { |
1095 NOTREACHED() << error; | 1095 LOG(ERROR) << error; |
1096 return NULL; | 1096 return NULL; |
1097 } | 1097 } |
1098 if (!extension_file_util::ValidateExtension(extension, &error)) { | |
Aaron Boodman
2011/08/08 21:31:42
Please remove this.
Component extensions must be
hashimoto
2011/08/09 06:19:52
Thank you for your detailed explanation.
I abando
| |
1099 LOG(ERROR) << error; | |
1100 } | |
1098 AddExtension(extension); | 1101 AddExtension(extension); |
1099 return extension; | 1102 return extension; |
1100 } | 1103 } |
1101 | 1104 |
1102 void ExtensionService::UnloadComponentExtension( | 1105 void ExtensionService::UnloadComponentExtension( |
1103 const ComponentExtensionInfo& info) { | 1106 const ComponentExtensionInfo& info) { |
1104 JSONStringValueSerializer serializer(info.manifest); | 1107 JSONStringValueSerializer serializer(info.manifest); |
1105 scoped_ptr<Value> manifest(serializer.Deserialize(NULL, NULL)); | 1108 scoped_ptr<Value> manifest(serializer.Deserialize(NULL, NULL)); |
1106 if (!manifest.get()) { | 1109 if (!manifest.get()) { |
1107 DLOG(ERROR) << "Failed to parse manifest for extension"; | 1110 LOG(ERROR) << "Failed to parse manifest for extension"; |
1108 return; | 1111 return; |
1109 } | 1112 } |
1110 std::string public_key; | 1113 std::string public_key; |
1111 std::string public_key_bytes; | 1114 std::string public_key_bytes; |
1112 std::string id; | 1115 std::string id; |
1113 if (!static_cast<DictionaryValue*>(manifest.get())-> | 1116 if (!static_cast<DictionaryValue*>(manifest.get())-> |
1114 GetString(extension_manifest_keys::kPublicKey, &public_key) || | 1117 GetString(extension_manifest_keys::kPublicKey, &public_key) || |
1115 !Extension::ParsePEMKeyBytes(public_key, &public_key_bytes) || | 1118 !Extension::ParsePEMKeyBytes(public_key, &public_key_bytes) || |
1116 !Extension::GenerateId(public_key_bytes, &id)) { | 1119 !Extension::GenerateId(public_key_bytes, &id)) { |
1117 DLOG(ERROR) << "Failed to get extension id"; | 1120 LOG(ERROR) << "Failed to get extension id"; |
1118 return; | 1121 return; |
1119 } | 1122 } |
1120 UnloadExtension(id, UnloadedExtensionInfo::DISABLE); | 1123 UnloadExtension(id, UnloadedExtensionInfo::DISABLE); |
1121 } | 1124 } |
1122 | 1125 |
1123 void ExtensionService::LoadAllExtensions() { | 1126 void ExtensionService::LoadAllExtensions() { |
1124 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1127 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1125 | 1128 |
1126 base::TimeTicks start_time = base::TimeTicks::Now(); | 1129 base::TimeTicks start_time = base::TimeTicks::Now(); |
1127 | 1130 |
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2581 | 2584 |
2582 ExtensionService::NaClModuleInfoList::iterator | 2585 ExtensionService::NaClModuleInfoList::iterator |
2583 ExtensionService::FindNaClModule(const GURL& url) { | 2586 ExtensionService::FindNaClModule(const GURL& url) { |
2584 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2587 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
2585 iter != nacl_module_list_.end(); ++iter) { | 2588 iter != nacl_module_list_.end(); ++iter) { |
2586 if (iter->url == url) | 2589 if (iter->url == url) |
2587 return iter; | 2590 return iter; |
2588 } | 2591 } |
2589 return nacl_module_list_.end(); | 2592 return nacl_module_list_.end(); |
2590 } | 2593 } |
OLD | NEW |