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 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 if (web_extent().is_empty()) | 1183 if (web_extent().is_empty()) |
1184 return true; | 1184 return true; |
1185 | 1185 |
1186 for (DictionaryValue::key_iterator key = manifest->begin_keys(); | 1186 for (DictionaryValue::key_iterator key = manifest->begin_keys(); |
1187 key != manifest->end_keys(); ++key) { | 1187 key != manifest->end_keys(); ++key) { |
1188 if (!IsBaseCrxKey(*key) && | 1188 if (!IsBaseCrxKey(*key) && |
1189 *key != keys::kApp && | 1189 *key != keys::kApp && |
1190 *key != keys::kPermissions && | 1190 *key != keys::kPermissions && |
1191 *key != keys::kOptionalPermissions && | 1191 *key != keys::kOptionalPermissions && |
1192 *key != keys::kOptionsPage && | 1192 *key != keys::kOptionsPage && |
1193 *key != keys::kBackground) { | 1193 *key != keys::kBackground && |
| 1194 *key != keys::kOfflineEnabled) { |
1194 *error = ExtensionErrorUtils::FormatErrorMessage( | 1195 *error = ExtensionErrorUtils::FormatErrorMessage( |
1195 errors::kHostedAppsCannotIncludeExtensionFeatures, *key); | 1196 errors::kHostedAppsCannotIncludeExtensionFeatures, *key); |
1196 return false; | 1197 return false; |
1197 } | 1198 } |
1198 } | 1199 } |
1199 | 1200 |
1200 return true; | 1201 return true; |
1201 } | 1202 } |
1202 | 1203 |
1203 // static | 1204 // static |
1204 bool Extension::IsTrustedId(const std::string& id) { | 1205 bool Extension::IsTrustedId(const std::string& id) { |
1205 // See http://b/4946060 for more details. | 1206 // See http://b/4946060 for more details. |
1206 return id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); | 1207 return id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); |
1207 } | 1208 } |
1208 | 1209 |
1209 Extension::Extension(const FilePath& path, Location location) | 1210 Extension::Extension(const FilePath& path, Location location) |
1210 : incognito_split_mode_(false), | 1211 : incognito_split_mode_(false), |
| 1212 offline_enabled_(false), |
1211 location_(location), | 1213 location_(location), |
1212 converted_from_user_script_(false), | 1214 converted_from_user_script_(false), |
1213 is_theme_(false), | 1215 is_theme_(false), |
1214 is_app_(false), | 1216 is_app_(false), |
1215 is_storage_isolated_(false), | 1217 is_storage_isolated_(false), |
1216 launch_container_(extension_misc::LAUNCH_TAB), | 1218 launch_container_(extension_misc::LAUNCH_TAB), |
1217 launch_width_(0), | 1219 launch_width_(0), |
1218 launch_height_(0), | 1220 launch_height_(0), |
1219 wants_file_access_(false), | 1221 wants_file_access_(false), |
1220 creation_flags_(0) { | 1222 creation_flags_(0) { |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1863 errors::kInvalidWebURLs, errors::kInvalidWebURL, | 1865 errors::kInvalidWebURLs, errors::kInvalidWebURL, |
1864 parse_strictness, error) || | 1866 parse_strictness, error) || |
1865 !EnsureNotHybridApp(manifest_value_.get(), error) || | 1867 !EnsureNotHybridApp(manifest_value_.get(), error) || |
1866 !LoadLaunchURL(manifest_value_.get(), error) || | 1868 !LoadLaunchURL(manifest_value_.get(), error) || |
1867 !LoadLaunchContainer(manifest_value_.get(), error) || | 1869 !LoadLaunchContainer(manifest_value_.get(), error) || |
1868 !LoadAppIsolation(manifest_value_.get(), error)) { | 1870 !LoadAppIsolation(manifest_value_.get(), error)) { |
1869 return false; | 1871 return false; |
1870 } | 1872 } |
1871 | 1873 |
1872 // Initialize options page url (optional). | 1874 // Initialize options page url (optional). |
1873 // Funtion LoadIsApp() set is_app_ above. | 1875 // Function LoadIsApp() set is_app_ above. |
1874 if (source.HasKey(keys::kOptionsPage)) { | 1876 if (source.HasKey(keys::kOptionsPage)) { |
1875 std::string options_str; | 1877 std::string options_str; |
1876 if (!source.GetString(keys::kOptionsPage, &options_str)) { | 1878 if (!source.GetString(keys::kOptionsPage, &options_str)) { |
1877 *error = errors::kInvalidOptionsPage; | 1879 *error = errors::kInvalidOptionsPage; |
1878 return false; | 1880 return false; |
1879 } | 1881 } |
1880 | 1882 |
1881 if (is_hosted_app()) { | 1883 if (is_hosted_app()) { |
1882 // hosted apps require an absolute URL. | 1884 // hosted apps require an absolute URL. |
1883 GURL options_url(options_str); | 1885 GURL options_url(options_str); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2298 if (value == values::kIncognitoSpanning) { | 2300 if (value == values::kIncognitoSpanning) { |
2299 incognito_split_mode_ = false; | 2301 incognito_split_mode_ = false; |
2300 } else if (value == values::kIncognitoSplit) { | 2302 } else if (value == values::kIncognitoSplit) { |
2301 incognito_split_mode_ = true; | 2303 incognito_split_mode_ = true; |
2302 } else { | 2304 } else { |
2303 *error = errors::kInvalidIncognitoBehavior; | 2305 *error = errors::kInvalidIncognitoBehavior; |
2304 return false; | 2306 return false; |
2305 } | 2307 } |
2306 } | 2308 } |
2307 | 2309 |
| 2310 // Initialize offline-enabled status. Defaults to false. |
| 2311 if (source.HasKey(keys::kOfflineEnabled)) { |
| 2312 if (!source.GetBoolean(keys::kOfflineEnabled, &offline_enabled_)) { |
| 2313 *error = errors::kInvalidOfflineEnabled; |
| 2314 return false; |
| 2315 } |
| 2316 } |
| 2317 |
2308 if (HasMultipleUISurfaces()) { | 2318 if (HasMultipleUISurfaces()) { |
2309 *error = errors::kOneUISurfaceOnly; | 2319 *error = errors::kOneUISurfaceOnly; |
2310 return false; | 2320 return false; |
2311 } | 2321 } |
2312 | 2322 |
2313 runtime_data_.SetActivePermissions(new ExtensionPermissionSet( | 2323 runtime_data_.SetActivePermissions(new ExtensionPermissionSet( |
2314 this, api_permissions, host_permissions)); | 2324 this, api_permissions, host_permissions)); |
2315 required_permission_set_ = new ExtensionPermissionSet( | 2325 required_permission_set_ = new ExtensionPermissionSet( |
2316 this, api_permissions, host_permissions); | 2326 this, api_permissions, host_permissions); |
2317 optional_permission_set_ = new ExtensionPermissionSet( | 2327 optional_permission_set_ = new ExtensionPermissionSet( |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2870 already_disabled(false), | 2880 already_disabled(false), |
2871 extension(extension) {} | 2881 extension(extension) {} |
2872 | 2882 |
2873 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 2883 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
2874 const Extension* extension, | 2884 const Extension* extension, |
2875 const ExtensionPermissionSet* permissions, | 2885 const ExtensionPermissionSet* permissions, |
2876 Reason reason) | 2886 Reason reason) |
2877 : reason(reason), | 2887 : reason(reason), |
2878 extension(extension), | 2888 extension(extension), |
2879 permissions(permissions) {} | 2889 permissions(permissions) {} |
OLD | NEW |