| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 // Override launch url to new tab. | 1022 // Override launch url to new tab. |
| 1023 launch_web_url_ = chrome::kChromeUINewTabURL; | 1023 launch_web_url_ = chrome::kChromeUINewTabURL; |
| 1024 extent_.ClearPatterns(); | 1024 extent_.ClearPatterns(); |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 return true; | 1027 return true; |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 bool Extension::LoadSharedFeatures(string16* error) { | 1030 bool Extension::LoadSharedFeatures(string16* error) { |
| 1031 if (!LoadDescription(error) || | 1031 if (!LoadDescription(error) || |
| 1032 !ManifestHandler::ParseExtension(this, error) || | 1032 !ManifestHandler::ParseExtension(this, error)) |
| 1033 !LoadNaClModules(error)) | |
| 1034 return false; | 1033 return false; |
| 1035 | 1034 |
| 1036 return true; | 1035 return true; |
| 1037 } | 1036 } |
| 1038 | 1037 |
| 1039 bool Extension::LoadDescription(string16* error) { | 1038 bool Extension::LoadDescription(string16* error) { |
| 1040 if (manifest_->HasKey(keys::kDescription) && | 1039 if (manifest_->HasKey(keys::kDescription) && |
| 1041 !manifest_->GetString(keys::kDescription, &description_)) { | 1040 !manifest_->GetString(keys::kDescription, &description_)) { |
| 1042 *error = ASCIIToUTF16(errors::kInvalidDescription); | 1041 *error = ASCIIToUTF16(errors::kInvalidDescription); |
| 1043 return false; | 1042 return false; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1064 switches::kAllowLegacyExtensionManifests)) { | 1063 switches::kAllowLegacyExtensionManifests)) { |
| 1065 *error = ErrorUtils::FormatErrorMessageUTF16( | 1064 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 1066 errors::kInvalidManifestVersionOld, | 1065 errors::kInvalidManifestVersionOld, |
| 1067 base::IntToString(kModernManifestVersion)); | 1066 base::IntToString(kModernManifestVersion)); |
| 1068 return false; | 1067 return false; |
| 1069 } | 1068 } |
| 1070 | 1069 |
| 1071 return true; | 1070 return true; |
| 1072 } | 1071 } |
| 1073 | 1072 |
| 1074 bool Extension::LoadNaClModules(string16* error) { | |
| 1075 if (!manifest_->HasKey(keys::kNaClModules)) | |
| 1076 return true; | |
| 1077 const ListValue* list_value = NULL; | |
| 1078 if (!manifest_->GetList(keys::kNaClModules, &list_value)) { | |
| 1079 *error = ASCIIToUTF16(errors::kInvalidNaClModules); | |
| 1080 return false; | |
| 1081 } | |
| 1082 | |
| 1083 for (size_t i = 0; i < list_value->GetSize(); ++i) { | |
| 1084 const DictionaryValue* module_value = NULL; | |
| 1085 if (!list_value->GetDictionary(i, &module_value)) { | |
| 1086 *error = ASCIIToUTF16(errors::kInvalidNaClModules); | |
| 1087 return false; | |
| 1088 } | |
| 1089 | |
| 1090 // Get nacl_modules[i].path. | |
| 1091 std::string path_str; | |
| 1092 if (!module_value->GetString(keys::kNaClModulesPath, &path_str)) { | |
| 1093 *error = ErrorUtils::FormatErrorMessageUTF16( | |
| 1094 errors::kInvalidNaClModulesPath, base::IntToString(i)); | |
| 1095 return false; | |
| 1096 } | |
| 1097 | |
| 1098 // Get nacl_modules[i].mime_type. | |
| 1099 std::string mime_type; | |
| 1100 if (!module_value->GetString(keys::kNaClModulesMIMEType, &mime_type)) { | |
| 1101 *error = ErrorUtils::FormatErrorMessageUTF16( | |
| 1102 errors::kInvalidNaClModulesMIMEType, base::IntToString(i)); | |
| 1103 return false; | |
| 1104 } | |
| 1105 | |
| 1106 nacl_modules_.push_back(NaClModuleInfo()); | |
| 1107 nacl_modules_.back().url = GetResourceURL(path_str); | |
| 1108 nacl_modules_.back().mime_type = mime_type; | |
| 1109 } | |
| 1110 | |
| 1111 return true; | |
| 1112 } | |
| 1113 | |
| 1114 bool Extension::HasMultipleUISurfaces() const { | 1073 bool Extension::HasMultipleUISurfaces() const { |
| 1115 int num_surfaces = 0; | 1074 int num_surfaces = 0; |
| 1116 | 1075 |
| 1117 if (ActionInfo::GetPageActionInfo(this)) | 1076 if (ActionInfo::GetPageActionInfo(this)) |
| 1118 ++num_surfaces; | 1077 ++num_surfaces; |
| 1119 | 1078 |
| 1120 if (ActionInfo::GetBrowserActionInfo(this)) | 1079 if (ActionInfo::GetBrowserActionInfo(this)) |
| 1121 ++num_surfaces; | 1080 ++num_surfaces; |
| 1122 | 1081 |
| 1123 if (is_app()) | 1082 if (is_app()) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 | 1202 |
| 1244 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 1203 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 1245 const Extension* extension, | 1204 const Extension* extension, |
| 1246 const PermissionSet* permissions, | 1205 const PermissionSet* permissions, |
| 1247 Reason reason) | 1206 Reason reason) |
| 1248 : reason(reason), | 1207 : reason(reason), |
| 1249 extension(extension), | 1208 extension(extension), |
| 1250 permissions(permissions) {} | 1209 permissions(permissions) {} |
| 1251 | 1210 |
| 1252 } // namespace extensions | 1211 } // namespace extensions |
| OLD | NEW |