| 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) |
| 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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 return false; // Failed to parse browser action definition. | 1698 return false; // Failed to parse browser action definition. |
| 1665 } | 1699 } |
| 1666 | 1700 |
| 1667 // Load App settings. | 1701 // Load App settings. |
| 1668 if (!LoadIsApp(manifest_value_.get(), error) || | 1702 if (!LoadIsApp(manifest_value_.get(), error) || |
| 1669 !LoadExtent(manifest_value_.get(), keys::kWebURLs, | 1703 !LoadExtent(manifest_value_.get(), keys::kWebURLs, |
| 1670 &extent_, | 1704 &extent_, |
| 1671 errors::kInvalidWebURLs, errors::kInvalidWebURL, error) || | 1705 errors::kInvalidWebURLs, errors::kInvalidWebURL, error) || |
| 1672 !EnsureNotHybridApp(manifest_value_.get(), error) || | 1706 !EnsureNotHybridApp(manifest_value_.get(), error) || |
| 1673 !LoadLaunchURL(manifest_value_.get(), error) || | 1707 !LoadLaunchURL(manifest_value_.get(), error) || |
| 1674 !LoadLaunchContainer(manifest_value_.get(), error)) { | 1708 !LoadLaunchContainer(manifest_value_.get(), error) || |
| 1709 !LoadAppIsolation(manifest_value_.get(), error)) { |
| 1675 return false; | 1710 return false; |
| 1676 } | 1711 } |
| 1677 | 1712 |
| 1678 // Initialize options page url (optional). | 1713 // Initialize options page url (optional). |
| 1679 // Funtion LoadIsApp() set is_app_ above. | 1714 // Funtion LoadIsApp() set is_app_ above. |
| 1680 if (source.HasKey(keys::kOptionsPage)) { | 1715 if (source.HasKey(keys::kOptionsPage)) { |
| 1681 std::string options_str; | 1716 std::string options_str; |
| 1682 if (!source.GetString(keys::kOptionsPage, &options_str)) { | 1717 if (!source.GetString(keys::kOptionsPage, &options_str)) { |
| 1683 *error = errors::kInvalidOptionsPage; | 1718 *error = errors::kInvalidOptionsPage; |
| 1684 return false; | 1719 return false; |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 | 2346 |
| 2312 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2347 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
| 2313 | 2348 |
| 2314 | 2349 |
| 2315 UnloadedExtensionInfo::UnloadedExtensionInfo( | 2350 UnloadedExtensionInfo::UnloadedExtensionInfo( |
| 2316 const Extension* extension, | 2351 const Extension* extension, |
| 2317 Reason reason) | 2352 Reason reason) |
| 2318 : reason(reason), | 2353 : reason(reason), |
| 2319 already_disabled(false), | 2354 already_disabled(false), |
| 2320 extension(extension) {} | 2355 extension(extension) {} |
| OLD | NEW |