Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 6201005: Initial support for partitioning cookies for isolated apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactor and address comments. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 if (!temp->GetAsInteger(&launch_height_) || launch_height_ < 0) { 1054 if (!temp->GetAsInteger(&launch_height_) || launch_height_ < 0) {
1055 launch_height_ = 0; 1055 launch_height_ = 0;
1056 *error = errors::kInvalidLaunchHeight; 1056 *error = errors::kInvalidLaunchHeight;
1057 return false; 1057 return false;
1058 } 1058 }
1059 } 1059 }
1060 1060
1061 return true; 1061 return true;
1062 } 1062 }
1063 1063
1064 bool Extension::LoadAppIsolation(const DictionaryValue* manifest,
1065 std::string* error) {
1066 // Only parse app isolation features if this switch is present.
1067 if (!CommandLine::ForCurrentProcess()->HasSwitch(
1068 switches::kEnableExperimentalAppManifests))
1069 return true;
1070
1071 Value* temp = NULL;
1072 if (!manifest->Get(keys::kIsolation, &temp))
1073 return true;
1074
1075 if (temp->GetType() != Value::TYPE_LIST) {
1076 *error = errors::kInvalidIsolation;
1077 return false;
1078 }
1079
1080 ListValue* isolation_list = static_cast<ListValue*>(temp);
1081 for (size_t i = 0; i < isolation_list->GetSize(); ++i) {
1082 std::string isolation_string;
1083 if (!isolation_list->GetString(i, &isolation_string)) {
1084 *error = ExtensionErrorUtils::FormatErrorMessage(
1085 errors::kInvalidIsolationValue,
1086 base::UintToString(i));
1087 return false;
1088 }
1089
1090 // Check for isolated storage.
1091 if (isolation_string == values::kIsolatedStorage) {
1092 is_storage_isolated_ = true;
1093 } else {
1094 LOG(WARNING) << "Did not recognize isolation type: "
1095 << isolation_string;
1096 }
1097 }
1098 return true;
1099 }
1100
1064 bool Extension::EnsureNotHybridApp(const DictionaryValue* manifest, 1101 bool Extension::EnsureNotHybridApp(const DictionaryValue* manifest,
1065 std::string* error) { 1102 std::string* error) {
1066 if (web_extent().is_empty()) 1103 if (web_extent().is_empty())
1067 return true; 1104 return true;
1068 1105
1069 for (DictionaryValue::key_iterator key = manifest->begin_keys(); 1106 for (DictionaryValue::key_iterator key = manifest->begin_keys();
1070 key != manifest->end_keys(); ++key) { 1107 key != manifest->end_keys(); ++key) {
1071 if (!IsBaseCrxKey(*key) && 1108 if (!IsBaseCrxKey(*key) &&
1072 *key != keys::kApp && 1109 *key != keys::kApp &&
1073 *key != keys::kPermissions && 1110 *key != keys::kPermissions &&
1074 *key != keys::kOptionsPage) { 1111 *key != keys::kOptionsPage) {
1075 *error = errors::kHostedAppsCannotIncludeExtensionFeatures; 1112 *error = errors::kHostedAppsCannotIncludeExtensionFeatures;
1076 return false; 1113 return false;
1077 } 1114 }
1078 } 1115 }
1079 1116
1080 return true; 1117 return true;
1081 } 1118 }
1082 1119
1083 Extension::Extension(const FilePath& path, Location location) 1120 Extension::Extension(const FilePath& path, Location location)
1084 : incognito_split_mode_(false), 1121 : incognito_split_mode_(false),
1085 location_(location), 1122 location_(location),
1086 converted_from_user_script_(false), 1123 converted_from_user_script_(false),
1087 is_theme_(false), 1124 is_theme_(false),
1088 is_app_(false), 1125 is_app_(false),
1126 is_storage_isolated_(false),
1089 launch_container_(extension_misc::LAUNCH_TAB), 1127 launch_container_(extension_misc::LAUNCH_TAB),
1090 launch_width_(0), 1128 launch_width_(0),
1091 launch_height_(0) { 1129 launch_height_(0) {
1092 DCHECK(path.IsAbsolute()); 1130 DCHECK(path.IsAbsolute());
1093 path_ = MaybeNormalizePath(path); 1131 path_ = MaybeNormalizePath(path);
1094 } 1132 }
1095 Extension::~Extension() { 1133 Extension::~Extension() {
1096 } 1134 }
1097 ExtensionResource Extension::GetResource( 1135 ExtensionResource Extension::GetResource(
1098 const std::string& relative_path) const { 1136 const std::string& relative_path) const {
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 return false; // Failed to parse browser action definition. 1748 return false; // Failed to parse browser action definition.
1711 } 1749 }
1712 1750
1713 // Load App settings. 1751 // Load App settings.
1714 if (!LoadIsApp(manifest_value_.get(), error) || 1752 if (!LoadIsApp(manifest_value_.get(), error) ||
1715 !LoadExtent(manifest_value_.get(), keys::kWebURLs, 1753 !LoadExtent(manifest_value_.get(), keys::kWebURLs,
1716 &extent_, 1754 &extent_,
1717 errors::kInvalidWebURLs, errors::kInvalidWebURL, error) || 1755 errors::kInvalidWebURLs, errors::kInvalidWebURL, error) ||
1718 !EnsureNotHybridApp(manifest_value_.get(), error) || 1756 !EnsureNotHybridApp(manifest_value_.get(), error) ||
1719 !LoadLaunchURL(manifest_value_.get(), error) || 1757 !LoadLaunchURL(manifest_value_.get(), error) ||
1720 !LoadLaunchContainer(manifest_value_.get(), error)) { 1758 !LoadLaunchContainer(manifest_value_.get(), error) ||
1759 !LoadAppIsolation(manifest_value_.get(), error)) {
1721 return false; 1760 return false;
1722 } 1761 }
1723 1762
1724 // Initialize options page url (optional). 1763 // Initialize options page url (optional).
1725 // Funtion LoadIsApp() set is_app_ above. 1764 // Funtion LoadIsApp() set is_app_ above.
1726 if (source.HasKey(keys::kOptionsPage)) { 1765 if (source.HasKey(keys::kOptionsPage)) {
1727 std::string options_str; 1766 std::string options_str;
1728 if (!source.GetString(keys::kOptionsPage, &options_str)) { 1767 if (!source.GetString(keys::kOptionsPage, &options_str)) {
1729 *error = errors::kInvalidOptionsPage; 1768 *error = errors::kInvalidOptionsPage;
1730 return false; 1769 return false;
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 2453
2415 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} 2454 UninstalledExtensionInfo::~UninstalledExtensionInfo() {}
2416 2455
2417 2456
2418 UnloadedExtensionInfo::UnloadedExtensionInfo( 2457 UnloadedExtensionInfo::UnloadedExtensionInfo(
2419 const Extension* extension, 2458 const Extension* extension,
2420 Reason reason) 2459 Reason reason)
2421 : reason(reason), 2460 : reason(reason),
2422 already_disabled(false), 2461 already_disabled(false),
2423 extension(extension) {} 2462 extension(extension) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698