OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/common/manifest_handlers/shared_module_info.h" | 5 #include "extensions/common/manifest_handlers/shared_module_info.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 bool SharedModuleInfo::ImportsModules(const Extension* extension) { | 98 bool SharedModuleInfo::ImportsModules(const Extension* extension) { |
99 return GetSharedModuleInfo(extension).imports_.size() > 0; | 99 return GetSharedModuleInfo(extension).imports_.size() > 0; |
100 } | 100 } |
101 | 101 |
102 // static | 102 // static |
103 const std::vector<SharedModuleInfo::ImportInfo>& SharedModuleInfo::GetImports( | 103 const std::vector<SharedModuleInfo::ImportInfo>& SharedModuleInfo::GetImports( |
104 const Extension* extension) { | 104 const Extension* extension) { |
105 return GetSharedModuleInfo(extension).imports_; | 105 return GetSharedModuleInfo(extension).imports_; |
106 } | 106 } |
107 | 107 |
108 bool SharedModuleInfo::Parse(const Extension* extension, string16* error) { | 108 bool SharedModuleInfo::Parse(const Extension* extension, |
| 109 base::string16* error) { |
109 bool has_import = extension->manifest()->HasKey(keys::kImport); | 110 bool has_import = extension->manifest()->HasKey(keys::kImport); |
110 bool has_export = extension->manifest()->HasKey(keys::kExport); | 111 bool has_export = extension->manifest()->HasKey(keys::kExport); |
111 if (!has_import && !has_export) | 112 if (!has_import && !has_export) |
112 return true; | 113 return true; |
113 | 114 |
114 if (has_import && has_export) { | 115 if (has_import && has_export) { |
115 *error = ASCIIToUTF16(errors::kInvalidImportAndExport); | 116 *error = ASCIIToUTF16(errors::kInvalidImportAndExport); |
116 return false; | 117 return false; |
117 } | 118 } |
118 | 119 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 return true; | 187 return true; |
187 } | 188 } |
188 | 189 |
189 | 190 |
190 SharedModuleHandler::SharedModuleHandler() { | 191 SharedModuleHandler::SharedModuleHandler() { |
191 } | 192 } |
192 | 193 |
193 SharedModuleHandler::~SharedModuleHandler() { | 194 SharedModuleHandler::~SharedModuleHandler() { |
194 } | 195 } |
195 | 196 |
196 bool SharedModuleHandler::Parse(Extension* extension, string16* error) { | 197 bool SharedModuleHandler::Parse(Extension* extension, base::string16* error) { |
197 scoped_ptr<SharedModuleInfo> info(new SharedModuleInfo); | 198 scoped_ptr<SharedModuleInfo> info(new SharedModuleInfo); |
198 if (!info->Parse(extension, error)) | 199 if (!info->Parse(extension, error)) |
199 return false; | 200 return false; |
200 extension->SetManifestData(kSharedModule, info.release()); | 201 extension->SetManifestData(kSharedModule, info.release()); |
201 return true; | 202 return true; |
202 } | 203 } |
203 | 204 |
204 bool SharedModuleHandler::Validate( | 205 bool SharedModuleHandler::Validate( |
205 const Extension* extension, | 206 const Extension* extension, |
206 std::string* error, | 207 std::string* error, |
(...skipping 11 matching lines...) Expand all Loading... |
218 | 219 |
219 const std::vector<std::string> SharedModuleHandler::Keys() const { | 220 const std::vector<std::string> SharedModuleHandler::Keys() const { |
220 static const char* keys[] = { | 221 static const char* keys[] = { |
221 keys::kExport, | 222 keys::kExport, |
222 keys::kImport | 223 keys::kImport |
223 }; | 224 }; |
224 return std::vector<std::string>(keys, keys + arraysize(keys)); | 225 return std::vector<std::string>(keys, keys + arraysize(keys)); |
225 } | 226 } |
226 | 227 |
227 } // namespace extensions | 228 } // namespace extensions |
OLD | NEW |