| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 // Initialize options page url (optional). | 1237 // Initialize options page url (optional). |
| 1238 if (source.HasKey(keys::kOptionsPage)) { | 1238 if (source.HasKey(keys::kOptionsPage)) { |
| 1239 std::string options_str; | 1239 std::string options_str; |
| 1240 if (!source.GetString(keys::kOptionsPage, &options_str)) { | 1240 if (!source.GetString(keys::kOptionsPage, &options_str)) { |
| 1241 *error = errors::kInvalidOptionsPage; | 1241 *error = errors::kInvalidOptionsPage; |
| 1242 return false; | 1242 return false; |
| 1243 } | 1243 } |
| 1244 options_url_ = GetResourceURL(options_str); | 1244 options_url_ = GetResourceURL(options_str); |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 // Initialize toolstrips (deprecated and optional). | 1247 // Initialize toolstrips. This is deprecated for public use. |
| 1248 // TODO(erikkay) remove this altogether. | 1248 // NOTE(erikkay) Although deprecated, we intend to preserve this parsing |
| 1249 // code indefinitely. Please contact me or Joi for details as to why. |
| 1249 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1250 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1250 switches::kEnableExtensionToolstrips) && | 1251 switches::kEnableExperimentalExtensionApis) && |
| 1251 source.HasKey(keys::kToolstrips)) { | 1252 source.HasKey(keys::kToolstrips)) { |
| 1252 ListValue* list_value; | 1253 ListValue* list_value; |
| 1253 if (!source.GetList(keys::kToolstrips, &list_value)) { | 1254 if (!source.GetList(keys::kToolstrips, &list_value)) { |
| 1254 *error = errors::kInvalidToolstrips; | 1255 *error = errors::kInvalidToolstrips; |
| 1255 return false; | 1256 return false; |
| 1256 } | 1257 } |
| 1257 | 1258 |
| 1258 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 1259 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 1259 ToolstripInfo toolstrip; | 1260 GURL toolstrip; |
| 1260 DictionaryValue* toolstrip_value; | 1261 DictionaryValue* toolstrip_value; |
| 1261 std::string toolstrip_path; | 1262 std::string toolstrip_path; |
| 1262 if (list_value->GetString(i, &toolstrip_path)) { | 1263 if (list_value->GetString(i, &toolstrip_path)) { |
| 1263 // Support a simple URL value for backwards compatibility. | 1264 // Support a simple URL value for backwards compatibility. |
| 1264 toolstrip.toolstrip = GetResourceURL(toolstrip_path); | 1265 toolstrip = GetResourceURL(toolstrip_path); |
| 1265 } else if (list_value->GetDictionary(i, &toolstrip_value)) { | 1266 } else if (list_value->GetDictionary(i, &toolstrip_value)) { |
| 1266 if (!toolstrip_value->GetString(keys::kToolstripPath, | 1267 if (!toolstrip_value->GetString(keys::kToolstripPath, |
| 1267 &toolstrip_path)) { | 1268 &toolstrip_path)) { |
| 1268 *error = ExtensionErrorUtils::FormatErrorMessage( | 1269 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 1269 errors::kInvalidToolstrip, base::IntToString(i)); | 1270 errors::kInvalidToolstrip, base::IntToString(i)); |
| 1270 return false; | 1271 return false; |
| 1271 } | 1272 } |
| 1272 toolstrip.toolstrip = GetResourceURL(toolstrip_path); | 1273 toolstrip = GetResourceURL(toolstrip_path); |
| 1273 if (toolstrip_value->HasKey(keys::kToolstripMolePath)) { | |
| 1274 std::string mole_path; | |
| 1275 if (!toolstrip_value->GetString(keys::kToolstripMolePath, | |
| 1276 &mole_path)) { | |
| 1277 *error = ExtensionErrorUtils::FormatErrorMessage( | |
| 1278 errors::kInvalidToolstrip, base::IntToString(i)); | |
| 1279 return false; | |
| 1280 } | |
| 1281 int height; | |
| 1282 if (!toolstrip_value->GetInteger(keys::kToolstripMoleHeight, | |
| 1283 &height) || (height < 0)) { | |
| 1284 *error = ExtensionErrorUtils::FormatErrorMessage( | |
| 1285 errors::kInvalidToolstrip, base::IntToString(i)); | |
| 1286 return false; | |
| 1287 } | |
| 1288 toolstrip.mole = GetResourceURL(mole_path); | |
| 1289 toolstrip.mole_height = height; | |
| 1290 } | |
| 1291 } else { | 1274 } else { |
| 1292 *error = ExtensionErrorUtils::FormatErrorMessage( | 1275 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 1293 errors::kInvalidToolstrip, base::IntToString(i)); | 1276 errors::kInvalidToolstrip, base::IntToString(i)); |
| 1294 return false; | 1277 return false; |
| 1295 } | 1278 } |
| 1296 toolstrips_.push_back(toolstrip); | 1279 toolstrips_.push_back(toolstrip); |
| 1297 } | 1280 } |
| 1298 } | 1281 } |
| 1299 | 1282 |
| 1300 // Initialize content scripts (optional). | 1283 // Initialize content scripts (optional). |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 } else { | 1739 } else { |
| 1757 return false; | 1740 return false; |
| 1758 } | 1741 } |
| 1759 } else { | 1742 } else { |
| 1760 return true; | 1743 return true; |
| 1761 } | 1744 } |
| 1762 } | 1745 } |
| 1763 } | 1746 } |
| 1764 return false; | 1747 return false; |
| 1765 } | 1748 } |
| OLD | NEW |