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 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1002 if (!temp->GetAsInteger(&launch_height_) || launch_height_ < 0) { | 1002 if (!temp->GetAsInteger(&launch_height_) || launch_height_ < 0) { |
1003 launch_height_ = 0; | 1003 launch_height_ = 0; |
1004 *error = errors::kInvalidLaunchHeight; | 1004 *error = errors::kInvalidLaunchHeight; |
1005 return false; | 1005 return false; |
1006 } | 1006 } |
1007 } | 1007 } |
1008 | 1008 |
1009 return true; | 1009 return true; |
1010 } | 1010 } |
1011 | 1011 |
1012 bool Extension::LoadAppIsolation(const DictionaryValue* manifest, | |
1013 std::string* error) { | |
1014 // Only parse app isolation features if this switch is present. | |
1015 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
1016 switches::kEnableExperimentalAppManifests)) | |
1017 return true; | |
1018 | |
1019 Value* temp = NULL; | |
1020 if (!manifest->Get(keys::kIsolation, &temp)) | |
1021 return true; | |
1022 | |
1023 if (temp->GetType() != Value::TYPE_LIST) { | |
1024 *error = errors::kInvalidIsolation; | |
1025 return false; | |
1026 } | |
1027 | |
1028 ListValue* isolation_list = static_cast<ListValue*>(temp); | |
1029 for (size_t i = 0; i < isolation_list->GetSize(); ++i) { | |
1030 std::string isolation_string; | |
1031 if (!isolation_list->GetString(i, &isolation_string)) { | |
1032 *error = ExtensionErrorUtils::FormatErrorMessage( | |
1033 errors::kInvalidIsolationValue, | |
1034 base::UintToString(i)); | |
1035 return false; | |
1036 } | |
1037 | |
1038 // Check for isolated storage. | |
1039 if (isolation_string == keys::kIsolatedStorage) | |
Matt Perry
2011/01/26 20:09:23
nit: add a LOG(WARNING) if it's a string we don't
Charlie Reis
2011/03/01 21:33:11
Done.
| |
1040 is_storage_isolated_ = true; | |
1041 } | |
1042 return true; | |
1043 } | |
1044 | |
1012 bool Extension::EnsureNotHybridApp(const DictionaryValue* manifest, | 1045 bool Extension::EnsureNotHybridApp(const DictionaryValue* manifest, |
1013 std::string* error) { | 1046 std::string* error) { |
1014 if (web_extent().is_empty()) | 1047 if (web_extent().is_empty()) |
1015 return true; | 1048 return true; |
1016 | 1049 |
1017 for (DictionaryValue::key_iterator key = manifest->begin_keys(); | 1050 for (DictionaryValue::key_iterator key = manifest->begin_keys(); |
1018 key != manifest->end_keys(); ++key) { | 1051 key != manifest->end_keys(); ++key) { |
1019 if (!IsBaseCrxKey(*key) && | 1052 if (!IsBaseCrxKey(*key) && |
1020 *key != keys::kApp && | 1053 *key != keys::kApp && |
1021 *key != keys::kPermissions && | 1054 *key != keys::kPermissions && |
1022 *key != keys::kOptionsPage) { | 1055 *key != keys::kOptionsPage) { |
1023 *error = errors::kHostedAppsCannotIncludeExtensionFeatures; | 1056 *error = errors::kHostedAppsCannotIncludeExtensionFeatures; |
1024 return false; | 1057 return false; |
1025 } | 1058 } |
1026 } | 1059 } |
1027 | 1060 |
1028 return true; | 1061 return true; |
1029 } | 1062 } |
1030 | 1063 |
1031 Extension::Extension(const FilePath& path, Location location) | 1064 Extension::Extension(const FilePath& path, Location location) |
1032 : incognito_split_mode_(false), | 1065 : incognito_split_mode_(false), |
1033 location_(location), | 1066 location_(location), |
1034 converted_from_user_script_(false), | 1067 converted_from_user_script_(false), |
1035 is_theme_(false), | 1068 is_theme_(false), |
1036 is_app_(false), | 1069 is_app_(false), |
1070 is_storage_isolated_(false), | |
1037 launch_container_(extension_misc::LAUNCH_TAB), | 1071 launch_container_(extension_misc::LAUNCH_TAB), |
1038 launch_width_(0), | 1072 launch_width_(0), |
1039 launch_height_(0) { | 1073 launch_height_(0) { |
1040 DCHECK(path.IsAbsolute()); | 1074 DCHECK(path.IsAbsolute()); |
1041 path_ = MaybeNormalizePath(path); | 1075 path_ = MaybeNormalizePath(path); |
1042 } | 1076 } |
1043 Extension::~Extension() { | 1077 Extension::~Extension() { |
1044 } | 1078 } |
1045 ExtensionResource Extension::GetResource( | 1079 ExtensionResource Extension::GetResource( |
1046 const std::string& relative_path) const { | 1080 const std::string& relative_path) const { |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1660 return false; // Failed to parse browser action definition. | 1694 return false; // Failed to parse browser action definition. |
1661 } | 1695 } |
1662 | 1696 |
1663 // Load App settings. | 1697 // Load App settings. |
1664 if (!LoadIsApp(manifest_value_.get(), error) || | 1698 if (!LoadIsApp(manifest_value_.get(), error) || |
1665 !LoadExtent(manifest_value_.get(), keys::kWebURLs, | 1699 !LoadExtent(manifest_value_.get(), keys::kWebURLs, |
1666 &extent_, | 1700 &extent_, |
1667 errors::kInvalidWebURLs, errors::kInvalidWebURL, error) || | 1701 errors::kInvalidWebURLs, errors::kInvalidWebURL, error) || |
1668 !EnsureNotHybridApp(manifest_value_.get(), error) || | 1702 !EnsureNotHybridApp(manifest_value_.get(), error) || |
1669 !LoadLaunchURL(manifest_value_.get(), error) || | 1703 !LoadLaunchURL(manifest_value_.get(), error) || |
1670 !LoadLaunchContainer(manifest_value_.get(), error)) { | 1704 !LoadLaunchContainer(manifest_value_.get(), error) || |
1705 !LoadAppIsolation(manifest_value_.get(), error)) { | |
1671 return false; | 1706 return false; |
1672 } | 1707 } |
1673 | 1708 |
1674 // Initialize options page url (optional). | 1709 // Initialize options page url (optional). |
1675 // Funtion LoadIsApp() set is_app_ above. | 1710 // Funtion LoadIsApp() set is_app_ above. |
1676 if (source.HasKey(keys::kOptionsPage)) { | 1711 if (source.HasKey(keys::kOptionsPage)) { |
1677 std::string options_str; | 1712 std::string options_str; |
1678 if (!source.GetString(keys::kOptionsPage, &options_str)) { | 1713 if (!source.GetString(keys::kOptionsPage, &options_str)) { |
1679 *error = errors::kInvalidOptionsPage; | 1714 *error = errors::kInvalidOptionsPage; |
1680 return false; | 1715 return false; |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2306 | 2341 |
2307 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2342 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
2308 | 2343 |
2309 | 2344 |
2310 UnloadedExtensionInfo::UnloadedExtensionInfo( | 2345 UnloadedExtensionInfo::UnloadedExtensionInfo( |
2311 const Extension* extension, | 2346 const Extension* extension, |
2312 Reason reason) | 2347 Reason reason) |
2313 : reason(reason), | 2348 : reason(reason), |
2314 already_disabled(false), | 2349 already_disabled(false), |
2315 extension(extension) {} | 2350 extension(extension) {} |
OLD | NEW |