| 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/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 367 |
| 368 // Helper method that loads a UserScript object from a dictionary in the | 368 // Helper method that loads a UserScript object from a dictionary in the |
| 369 // content_script list of the manifest. | 369 // content_script list of the manifest. |
| 370 bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, | 370 bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, |
| 371 int definition_index, | 371 int definition_index, |
| 372 int flags, | 372 int flags, |
| 373 std::string* error, | 373 std::string* error, |
| 374 UserScript* result) { | 374 UserScript* result) { |
| 375 // When strict error checks are enabled, make URL pattern parsing strict. | 375 // When strict error checks are enabled, make URL pattern parsing strict. |
| 376 URLPattern::ParseOption parse_strictness = | 376 URLPattern::ParseOption parse_strictness = |
| 377 (flags & STRICT_ERROR_CHECKS ? URLPattern::PARSE_STRICT | 377 (flags & STRICT_ERROR_CHECKS ? URLPattern::ERROR_ON_PORTS |
| 378 : URLPattern::PARSE_LENIENT); | 378 : URLPattern::IGNORE_PORTS); |
| 379 | 379 |
| 380 // run_at | 380 // run_at |
| 381 if (content_script->HasKey(keys::kRunAt)) { | 381 if (content_script->HasKey(keys::kRunAt)) { |
| 382 std::string run_location; | 382 std::string run_location; |
| 383 if (!content_script->GetString(keys::kRunAt, &run_location)) { | 383 if (!content_script->GetString(keys::kRunAt, &run_location)) { |
| 384 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidRunAt, | 384 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidRunAt, |
| 385 base::IntToString(definition_index)); | 385 base::IntToString(definition_index)); |
| 386 return false; | 386 return false; |
| 387 } | 387 } |
| 388 | 388 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 return NULL; | 778 return NULL; |
| 779 } | 779 } |
| 780 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 780 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 781 std::string filter; | 781 std::string filter; |
| 782 if (!list_value->GetString(i, &filter)) { | 782 if (!list_value->GetString(i, &filter)) { |
| 783 *error = ExtensionErrorUtils::FormatErrorMessage( | 783 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 784 errors::kInvalidFileFilterValue, base::IntToString(i)); | 784 errors::kInvalidFileFilterValue, base::IntToString(i)); |
| 785 return NULL; | 785 return NULL; |
| 786 } | 786 } |
| 787 URLPattern pattern(URLPattern::SCHEME_FILESYSTEM); | 787 URLPattern pattern(URLPattern::SCHEME_FILESYSTEM); |
| 788 if (URLPattern::PARSE_SUCCESS != pattern.Parse(filter, | 788 if (pattern.Parse(filter, URLPattern::ERROR_ON_PORTS) != |
| 789 URLPattern::PARSE_STRICT)) { | 789 URLPattern::PARSE_SUCCESS) { |
| 790 *error = ExtensionErrorUtils::FormatErrorMessage( | 790 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 791 errors::kInvalidURLPatternError, filter); | 791 errors::kInvalidURLPatternError, filter); |
| 792 return NULL; | 792 return NULL; |
| 793 } | 793 } |
| 794 result->AddPattern(pattern); | 794 result->AddPattern(pattern); |
| 795 } | 795 } |
| 796 | 796 |
| 797 std::string default_icon; | 797 std::string default_icon; |
| 798 // Read the file browser action |default_icon| (optional). | 798 // Read the file browser action |default_icon| (optional). |
| 799 if (file_browser_handler->HasKey(keys::kPageActionDefaultIcon)) { | 799 if (file_browser_handler->HasKey(keys::kPageActionDefaultIcon)) { |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 << " should not contain a port. Removing it."; | 1028 << " should not contain a port. Removing it."; |
| 1029 | 1029 |
| 1030 GURL::Replacements remove_port; | 1030 GURL::Replacements remove_port; |
| 1031 remove_port.ClearPort(); | 1031 remove_port.ClearPort(); |
| 1032 gallery_url = gallery_url.ReplaceComponents(remove_port); | 1032 gallery_url = gallery_url.ReplaceComponents(remove_port); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 launch_web_url_ = gallery_url.spec(); | 1035 launch_web_url_ = gallery_url.spec(); |
| 1036 | 1036 |
| 1037 URLPattern pattern(kValidWebExtentSchemes); | 1037 URLPattern pattern(kValidWebExtentSchemes); |
| 1038 pattern.Parse(gallery_url.spec(), URLPattern::PARSE_STRICT); | 1038 pattern.Parse(gallery_url.spec(), URLPattern::ERROR_ON_PORTS); |
| 1039 pattern.SetPath(pattern.path() + '*'); | 1039 pattern.SetPath(pattern.path() + '*'); |
| 1040 extent_.AddPattern(pattern); | 1040 extent_.AddPattern(pattern); |
| 1041 } | 1041 } |
| 1042 } | 1042 } |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 return true; | 1045 return true; |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 bool Extension::LoadLaunchContainer(const DictionaryValue* manifest, | 1048 bool Extension::LoadLaunchContainer(const DictionaryValue* manifest, |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 | 1316 |
| 1317 GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) { | 1317 GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) { |
| 1318 return GURL(std::string(chrome::kExtensionScheme) + | 1318 return GURL(std::string(chrome::kExtensionScheme) + |
| 1319 chrome::kStandardSchemeSeparator + extension_id + "/"); | 1319 chrome::kStandardSchemeSeparator + extension_id + "/"); |
| 1320 } | 1320 } |
| 1321 | 1321 |
| 1322 bool Extension::InitFromValue(const DictionaryValue& source, int flags, | 1322 bool Extension::InitFromValue(const DictionaryValue& source, int flags, |
| 1323 std::string* error) { | 1323 std::string* error) { |
| 1324 // When strict error checks are enabled, make URL pattern parsing strict. | 1324 // When strict error checks are enabled, make URL pattern parsing strict. |
| 1325 URLPattern::ParseOption parse_strictness = | 1325 URLPattern::ParseOption parse_strictness = |
| 1326 (flags & STRICT_ERROR_CHECKS ? URLPattern::PARSE_STRICT | 1326 (flags & STRICT_ERROR_CHECKS ? URLPattern::ERROR_ON_PORTS |
| 1327 : URLPattern::PARSE_LENIENT); | 1327 : URLPattern::IGNORE_PORTS); |
| 1328 | 1328 |
| 1329 // Initialize permissions with an empty, default permission set. | 1329 // Initialize permissions with an empty, default permission set. |
| 1330 permission_set_.reset(new ExtensionPermissionSet()); | 1330 permission_set_.reset(new ExtensionPermissionSet()); |
| 1331 | 1331 |
| 1332 if (source.HasKey(keys::kPublicKey)) { | 1332 if (source.HasKey(keys::kPublicKey)) { |
| 1333 std::string public_key_bytes; | 1333 std::string public_key_bytes; |
| 1334 if (!source.GetString(keys::kPublicKey, | 1334 if (!source.GetString(keys::kPublicKey, |
| 1335 &public_key_) || | 1335 &public_key_) || |
| 1336 !ParsePEMKeyBytes(public_key_, | 1336 !ParsePEMKeyBytes(public_key_, |
| 1337 &public_key_bytes) || | 1337 &public_key_bytes) || |
| (...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2679 | 2679 |
| 2680 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2680 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
| 2681 | 2681 |
| 2682 | 2682 |
| 2683 UnloadedExtensionInfo::UnloadedExtensionInfo( | 2683 UnloadedExtensionInfo::UnloadedExtensionInfo( |
| 2684 const Extension* extension, | 2684 const Extension* extension, |
| 2685 Reason reason) | 2685 Reason reason) |
| 2686 : reason(reason), | 2686 : reason(reason), |
| 2687 already_disabled(false), | 2687 already_disabled(false), |
| 2688 extension(extension) {} | 2688 extension(extension) {} |
| OLD | NEW |