OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/common/extensions/csp_validator.h" | 32 #include "chrome/common/extensions/csp_validator.h" |
33 #include "chrome/common/extensions/extension_manifest_constants.h" | 33 #include "chrome/common/extensions/extension_manifest_constants.h" |
34 #include "chrome/common/extensions/extension_resource.h" | 34 #include "chrome/common/extensions/extension_resource.h" |
35 #include "chrome/common/extensions/feature_switch.h" | 35 #include "chrome/common/extensions/feature_switch.h" |
36 #include "chrome/common/extensions/features/base_feature_provider.h" | 36 #include "chrome/common/extensions/features/base_feature_provider.h" |
37 #include "chrome/common/extensions/features/feature.h" | 37 #include "chrome/common/extensions/features/feature.h" |
38 #include "chrome/common/extensions/manifest.h" | 38 #include "chrome/common/extensions/manifest.h" |
39 #include "chrome/common/extensions/manifest_handler.h" | 39 #include "chrome/common/extensions/manifest_handler.h" |
40 #include "chrome/common/extensions/manifest_handler_helpers.h" | 40 #include "chrome/common/extensions/manifest_handler_helpers.h" |
41 #include "chrome/common/extensions/manifest_url_handler.h" | 41 #include "chrome/common/extensions/manifest_url_handler.h" |
| 42 #include "chrome/common/extensions/permissions/api_permission_set.h" |
42 #include "chrome/common/extensions/permissions/permission_set.h" | 43 #include "chrome/common/extensions/permissions/permission_set.h" |
43 #include "chrome/common/extensions/permissions/permissions_info.h" | 44 #include "chrome/common/extensions/permissions/permissions_info.h" |
44 #include "chrome/common/extensions/user_script.h" | 45 #include "chrome/common/extensions/user_script.h" |
45 #include "chrome/common/url_constants.h" | 46 #include "chrome/common/url_constants.h" |
46 #include "crypto/sha2.h" | 47 #include "crypto/sha2.h" |
47 #include "extensions/common/constants.h" | 48 #include "extensions/common/constants.h" |
48 #include "extensions/common/error_utils.h" | 49 #include "extensions/common/error_utils.h" |
49 #include "extensions/common/url_pattern_set.h" | 50 #include "extensions/common/url_pattern_set.h" |
50 #include "googleurl/src/url_util.h" | 51 #include "googleurl/src/url_util.h" |
51 #include "grit/chromium_strings.h" | 52 #include "grit/chromium_strings.h" |
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 manifest_->GetString(keys::kPublicKey, &public_key_); | 1400 manifest_->GetString(keys::kPublicKey, &public_key_); |
1400 | 1401 |
1401 extension_url_ = Extension::GetBaseURLFromExtensionId(id()); | 1402 extension_url_ = Extension::GetBaseURLFromExtensionId(id()); |
1402 | 1403 |
1403 // Load App settings. LoadExtent at least has to be done before | 1404 // Load App settings. LoadExtent at least has to be done before |
1404 // ParsePermissions(), because the valid permissions depend on what type of | 1405 // ParsePermissions(), because the valid permissions depend on what type of |
1405 // package this is. | 1406 // package this is. |
1406 if (is_app() && !LoadAppFeatures(error)) | 1407 if (is_app() && !LoadAppFeatures(error)) |
1407 return false; | 1408 return false; |
1408 | 1409 |
1409 APIPermissionSet api_permissions; | 1410 initial_api_permissions_.reset(new APIPermissionSet); |
1410 URLPatternSet host_permissions; | 1411 URLPatternSet host_permissions; |
1411 if (!ParsePermissions(keys::kPermissions, | 1412 if (!ParsePermissions(keys::kPermissions, |
1412 error, | 1413 error, |
1413 &api_permissions, | 1414 initial_api_permissions_.get(), |
1414 &host_permissions)) { | 1415 &host_permissions)) { |
1415 return false; | 1416 return false; |
1416 } | 1417 } |
1417 | 1418 |
1418 // Check for any permissions that are optional only. | 1419 // Check for any permissions that are optional only. |
1419 for (APIPermissionSet::const_iterator i = api_permissions.begin(); | 1420 for (APIPermissionSet::const_iterator i = initial_api_permissions_->begin(); |
1420 i != api_permissions.end(); ++i) { | 1421 i != initial_api_permissions_->end(); ++i) { |
1421 if ((*i)->info()->must_be_optional()) { | 1422 if ((*i)->info()->must_be_optional()) { |
1422 *error = ErrorUtils::FormatErrorMessageUTF16( | 1423 *error = ErrorUtils::FormatErrorMessageUTF16( |
1423 errors::kPermissionMustBeOptional, (*i)->info()->name()); | 1424 errors::kPermissionMustBeOptional, (*i)->info()->name()); |
1424 return false; | 1425 return false; |
1425 } | 1426 } |
1426 } | 1427 } |
1427 | 1428 |
1428 // TODO(jeremya/kalman) do this via the features system by exposing the | 1429 // TODO(jeremya/kalman) do this via the features system by exposing the |
1429 // app.window API to platform apps, with no dependency on any permissions. | 1430 // app.window API to platform apps, with no dependency on any permissions. |
1430 // See http://crbug.com/120069. | 1431 // See http://crbug.com/120069. |
1431 if (is_platform_app()) { | 1432 if (is_platform_app()) { |
1432 api_permissions.insert(APIPermission::kAppCurrentWindowInternal); | 1433 initial_api_permissions_->insert(APIPermission::kAppCurrentWindowInternal); |
1433 api_permissions.insert(APIPermission::kAppRuntime); | 1434 initial_api_permissions_->insert(APIPermission::kAppRuntime); |
1434 api_permissions.insert(APIPermission::kAppWindow); | 1435 initial_api_permissions_->insert(APIPermission::kAppWindow); |
1435 } | 1436 } |
1436 | 1437 |
1437 APIPermissionSet optional_api_permissions; | 1438 APIPermissionSet optional_api_permissions; |
1438 URLPatternSet optional_host_permissions; | 1439 URLPatternSet optional_host_permissions; |
1439 if (!ParsePermissions(keys::kOptionalPermissions, | 1440 if (!ParsePermissions(keys::kOptionalPermissions, |
1440 error, | 1441 error, |
1441 &optional_api_permissions, | 1442 &optional_api_permissions, |
1442 &optional_host_permissions)) { | 1443 &optional_host_permissions)) { |
1443 return false; | 1444 return false; |
1444 } | 1445 } |
1445 | 1446 |
1446 if (ContainsManifestForbiddenPermission(api_permissions, error) || | 1447 if (ContainsManifestForbiddenPermission(*initial_api_permissions_, error) || |
1447 ContainsManifestForbiddenPermission(optional_api_permissions, error)) { | 1448 ContainsManifestForbiddenPermission(optional_api_permissions, error)) { |
1448 return false; | 1449 return false; |
1449 } | 1450 } |
1450 | 1451 |
1451 if (!LoadAppIsolation(api_permissions, error)) | 1452 if (!LoadAppIsolation(error)) |
1452 return false; | 1453 return false; |
1453 | 1454 |
1454 if (!LoadSharedFeatures(api_permissions, error)) | 1455 if (!LoadSharedFeatures(error)) |
1455 return false; | 1456 return false; |
1456 | 1457 |
1457 if (!LoadExtensionFeatures(&api_permissions, error)) | 1458 if (!LoadExtensionFeatures(error)) |
1458 return false; | 1459 return false; |
1459 | 1460 |
1460 if (!LoadManagedModeFeatures(error)) | 1461 if (!LoadManagedModeFeatures(error)) |
1461 return false; | 1462 return false; |
1462 | 1463 |
1463 if (HasMultipleUISurfaces()) { | 1464 if (HasMultipleUISurfaces()) { |
1464 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); | 1465 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); |
1465 return false; | 1466 return false; |
1466 } | 1467 } |
1467 | 1468 |
1468 finished_parsing_manifest_ = true; | 1469 finished_parsing_manifest_ = true; |
1469 | 1470 |
1470 runtime_data_.SetActivePermissions(new PermissionSet( | 1471 runtime_data_.SetActivePermissions(new PermissionSet( |
1471 this, api_permissions, host_permissions)); | 1472 this, *initial_api_permissions_, host_permissions)); |
1472 required_permission_set_ = new PermissionSet( | 1473 required_permission_set_ = new PermissionSet( |
1473 this, api_permissions, host_permissions); | 1474 this, *initial_api_permissions_, host_permissions); |
1474 optional_permission_set_ = new PermissionSet( | 1475 optional_permission_set_ = new PermissionSet( |
1475 optional_api_permissions, optional_host_permissions, URLPatternSet()); | 1476 optional_api_permissions, optional_host_permissions, URLPatternSet()); |
| 1477 initial_api_permissions_.reset(); |
1476 | 1478 |
1477 return true; | 1479 return true; |
1478 } | 1480 } |
1479 | 1481 |
1480 bool Extension::LoadAppIsolation(const APIPermissionSet& api_permissions, | 1482 bool Extension::LoadAppIsolation(string16* error) { |
1481 string16* error) { | |
1482 // Platform apps always get isolated storage. | 1483 // Platform apps always get isolated storage. |
1483 if (is_platform_app()) { | 1484 if (is_platform_app()) { |
1484 is_storage_isolated_ = true; | 1485 is_storage_isolated_ = true; |
1485 return true; | 1486 return true; |
1486 } | 1487 } |
1487 | 1488 |
1488 // Other apps only get it if it is requested _and_ experimental APIs are | 1489 // Other apps only get it if it is requested _and_ experimental APIs are |
1489 // enabled. | 1490 // enabled. |
1490 if (!api_permissions.count(APIPermission::kExperimental) || !is_app()) | 1491 if (!initial_api_permissions()->count(APIPermission::kExperimental) |
| 1492 || !is_app()) |
1491 return true; | 1493 return true; |
1492 | 1494 |
1493 Value* tmp_isolation = NULL; | 1495 Value* tmp_isolation = NULL; |
1494 if (!manifest_->Get(keys::kIsolation, &tmp_isolation)) | 1496 if (!manifest_->Get(keys::kIsolation, &tmp_isolation)) |
1495 return true; | 1497 return true; |
1496 | 1498 |
1497 if (tmp_isolation->GetType() != Value::TYPE_LIST) { | 1499 if (tmp_isolation->GetType() != Value::TYPE_LIST) { |
1498 *error = ASCIIToUTF16(errors::kInvalidIsolation); | 1500 *error = ASCIIToUTF16(errors::kInvalidIsolation); |
1499 return false; | 1501 return false; |
1500 } | 1502 } |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 } | 1803 } |
1802 } else if (id() == extension_misc::kChromeAppId) { | 1804 } else if (id() == extension_misc::kChromeAppId) { |
1803 // Override launch url to new tab. | 1805 // Override launch url to new tab. |
1804 launch_web_url_ = chrome::kChromeUINewTabURL; | 1806 launch_web_url_ = chrome::kChromeUINewTabURL; |
1805 extent_.ClearPatterns(); | 1807 extent_.ClearPatterns(); |
1806 } | 1808 } |
1807 | 1809 |
1808 return true; | 1810 return true; |
1809 } | 1811 } |
1810 | 1812 |
1811 bool Extension::LoadSharedFeatures( | 1813 bool Extension::LoadSharedFeatures(string16* error) { |
1812 const APIPermissionSet& api_permissions, | |
1813 string16* error) { | |
1814 if (!LoadDescription(error) || | 1814 if (!LoadDescription(error) || |
1815 !LoadIcons(error) || | 1815 !LoadIcons(error) || |
1816 !ManifestHandler::ParseExtension(this, error) || | 1816 !ManifestHandler::ParseExtension(this, error) || |
1817 !LoadPlugins(error) || | 1817 !LoadPlugins(error) || |
1818 !LoadNaClModules(error) || | 1818 !LoadNaClModules(error) || |
1819 !LoadSandboxedPages(error) || | 1819 !LoadSandboxedPages(error) || |
1820 !LoadRequirements(error) || | 1820 !LoadRequirements(error) || |
1821 !LoadOfflineEnabled(error) || | 1821 !LoadOfflineEnabled(error) || |
1822 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). | 1822 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). |
1823 !LoadBackgroundScripts(error) || | 1823 !LoadBackgroundScripts(error) || |
1824 !LoadBackgroundPage(api_permissions, error) || | 1824 !LoadBackgroundPage(error) || |
1825 !LoadBackgroundPersistent(api_permissions, error) || | 1825 !LoadBackgroundPersistent(error) || |
1826 !LoadBackgroundAllowJSAccess(api_permissions, error)) | 1826 !LoadBackgroundAllowJSAccess(error)) |
1827 return false; | 1827 return false; |
1828 | 1828 |
1829 return true; | 1829 return true; |
1830 } | 1830 } |
1831 | 1831 |
1832 bool Extension::LoadDescription(string16* error) { | 1832 bool Extension::LoadDescription(string16* error) { |
1833 if (manifest_->HasKey(keys::kDescription) && | 1833 if (manifest_->HasKey(keys::kDescription) && |
1834 !manifest_->GetString(keys::kDescription, &description_)) { | 1834 !manifest_->GetString(keys::kDescription, &description_)) { |
1835 *error = ASCIIToUTF16(errors::kInvalidDescription); | 1835 *error = ASCIIToUTF16(errors::kInvalidDescription); |
1836 return false; | 1836 return false; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2140 *error = ErrorUtils::FormatErrorMessageUTF16( | 2140 *error = ErrorUtils::FormatErrorMessageUTF16( |
2141 errors::kInvalidBackgroundScript, base::IntToString(i)); | 2141 errors::kInvalidBackgroundScript, base::IntToString(i)); |
2142 return false; | 2142 return false; |
2143 } | 2143 } |
2144 background_scripts_.push_back(script); | 2144 background_scripts_.push_back(script); |
2145 } | 2145 } |
2146 | 2146 |
2147 return true; | 2147 return true; |
2148 } | 2148 } |
2149 | 2149 |
2150 bool Extension::LoadBackgroundPage( | 2150 bool Extension::LoadBackgroundPage(string16* error) { |
2151 const APIPermissionSet& api_permissions, | |
2152 string16* error) { | |
2153 if (is_platform_app()) { | 2151 if (is_platform_app()) { |
2154 return LoadBackgroundPage( | 2152 return LoadBackgroundPage(keys::kPlatformAppBackgroundPage, error); |
2155 keys::kPlatformAppBackgroundPage, api_permissions, error); | |
2156 } | 2153 } |
2157 | 2154 |
2158 if (!LoadBackgroundPage(keys::kBackgroundPage, api_permissions, error)) | 2155 if (!LoadBackgroundPage(keys::kBackgroundPage, error)) |
2159 return false; | 2156 return false; |
2160 if (background_url_.is_empty()) { | 2157 if (background_url_.is_empty()) { |
2161 return LoadBackgroundPage( | 2158 return LoadBackgroundPage( |
2162 keys::kBackgroundPageLegacy, api_permissions, error); | 2159 keys::kBackgroundPageLegacy, error); |
2163 } | 2160 } |
2164 return true; | 2161 return true; |
2165 } | 2162 } |
2166 | 2163 |
2167 bool Extension::LoadBackgroundPage( | 2164 bool Extension::LoadBackgroundPage(const std::string& key, string16* error) { |
2168 const std::string& key, | |
2169 const APIPermissionSet& api_permissions, | |
2170 string16* error) { | |
2171 base::Value* background_page_value = NULL; | 2165 base::Value* background_page_value = NULL; |
2172 if (!manifest_->Get(key, &background_page_value)) | 2166 if (!manifest_->Get(key, &background_page_value)) |
2173 return true; | 2167 return true; |
2174 | 2168 |
2175 if (!background_scripts_.empty()) { | 2169 if (!background_scripts_.empty()) { |
2176 *error = ASCIIToUTF16(errors::kInvalidBackgroundCombination); | 2170 *error = ASCIIToUTF16(errors::kInvalidBackgroundCombination); |
2177 return false; | 2171 return false; |
2178 } | 2172 } |
2179 | 2173 |
2180 | 2174 |
2181 std::string background_str; | 2175 std::string background_str; |
2182 if (!background_page_value->GetAsString(&background_str)) { | 2176 if (!background_page_value->GetAsString(&background_str)) { |
2183 *error = ASCIIToUTF16(errors::kInvalidBackground); | 2177 *error = ASCIIToUTF16(errors::kInvalidBackground); |
2184 return false; | 2178 return false; |
2185 } | 2179 } |
2186 | 2180 |
2187 if (is_hosted_app()) { | 2181 if (is_hosted_app()) { |
2188 background_url_ = GURL(background_str); | 2182 background_url_ = GURL(background_str); |
2189 | 2183 |
2190 // Make sure "background" permission is set. | 2184 // Make sure "background" permission is set. |
2191 if (!api_permissions.count(APIPermission::kBackground)) { | 2185 if (!initial_api_permissions()->count(APIPermission::kBackground)) { |
2192 *error = ASCIIToUTF16(errors::kBackgroundPermissionNeeded); | 2186 *error = ASCIIToUTF16(errors::kBackgroundPermissionNeeded); |
2193 return false; | 2187 return false; |
2194 } | 2188 } |
2195 // Hosted apps require an absolute URL. | 2189 // Hosted apps require an absolute URL. |
2196 if (!background_url_.is_valid()) { | 2190 if (!background_url_.is_valid()) { |
2197 *error = ASCIIToUTF16(errors::kInvalidBackgroundInHostedApp); | 2191 *error = ASCIIToUTF16(errors::kInvalidBackgroundInHostedApp); |
2198 return false; | 2192 return false; |
2199 } | 2193 } |
2200 | 2194 |
2201 if (!(background_url_.SchemeIs("https") || | 2195 if (!(background_url_.SchemeIs("https") || |
2202 (CommandLine::ForCurrentProcess()->HasSwitch( | 2196 (CommandLine::ForCurrentProcess()->HasSwitch( |
2203 switches::kAllowHTTPBackgroundPage) && | 2197 switches::kAllowHTTPBackgroundPage) && |
2204 background_url_.SchemeIs("http")))) { | 2198 background_url_.SchemeIs("http")))) { |
2205 *error = ASCIIToUTF16(errors::kInvalidBackgroundInHostedApp); | 2199 *error = ASCIIToUTF16(errors::kInvalidBackgroundInHostedApp); |
2206 return false; | 2200 return false; |
2207 } | 2201 } |
2208 } else { | 2202 } else { |
2209 background_url_ = GetResourceURL(background_str); | 2203 background_url_ = GetResourceURL(background_str); |
2210 } | 2204 } |
2211 | 2205 |
2212 return true; | 2206 return true; |
2213 } | 2207 } |
2214 | 2208 |
2215 bool Extension::LoadBackgroundPersistent( | 2209 bool Extension::LoadBackgroundPersistent(string16* error) { |
2216 const APIPermissionSet& api_permissions, | |
2217 string16* error) { | |
2218 if (is_platform_app()) { | 2210 if (is_platform_app()) { |
2219 background_page_is_persistent_ = false; | 2211 background_page_is_persistent_ = false; |
2220 return true; | 2212 return true; |
2221 } | 2213 } |
2222 | 2214 |
2223 Value* background_persistent = NULL; | 2215 Value* background_persistent = NULL; |
2224 if (!manifest_->Get(keys::kBackgroundPersistent, &background_persistent)) | 2216 if (!manifest_->Get(keys::kBackgroundPersistent, &background_persistent)) |
2225 return true; | 2217 return true; |
2226 | 2218 |
2227 if (!background_persistent->GetAsBoolean(&background_page_is_persistent_)) { | 2219 if (!background_persistent->GetAsBoolean(&background_page_is_persistent_)) { |
2228 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistent); | 2220 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistent); |
2229 return false; | 2221 return false; |
2230 } | 2222 } |
2231 | 2223 |
2232 if (!has_background_page()) { | 2224 if (!has_background_page()) { |
2233 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistentNoPage); | 2225 *error = ASCIIToUTF16(errors::kInvalidBackgroundPersistentNoPage); |
2234 return false; | 2226 return false; |
2235 } | 2227 } |
2236 | 2228 |
2237 return true; | 2229 return true; |
2238 } | 2230 } |
2239 | 2231 |
2240 bool Extension::LoadBackgroundAllowJSAccess( | 2232 bool Extension::LoadBackgroundAllowJSAccess(string16* error) { |
2241 const APIPermissionSet& api_permissions, | |
2242 string16* error) { | |
2243 Value* allow_js_access = NULL; | 2233 Value* allow_js_access = NULL; |
2244 if (!manifest_->Get(keys::kBackgroundAllowJsAccess, &allow_js_access)) | 2234 if (!manifest_->Get(keys::kBackgroundAllowJsAccess, &allow_js_access)) |
2245 return true; | 2235 return true; |
2246 | 2236 |
2247 if (!allow_js_access->IsType(Value::TYPE_BOOLEAN) || | 2237 if (!allow_js_access->IsType(Value::TYPE_BOOLEAN) || |
2248 !allow_js_access->GetAsBoolean(&allow_background_js_access_)) { | 2238 !allow_js_access->GetAsBoolean(&allow_background_js_access_)) { |
2249 *error = ASCIIToUTF16(errors::kInvalidBackgroundAllowJsAccess); | 2239 *error = ASCIIToUTF16(errors::kInvalidBackgroundAllowJsAccess); |
2250 return false; | 2240 return false; |
2251 } | 2241 } |
2252 | 2242 |
2253 return true; | 2243 return true; |
2254 } | 2244 } |
2255 | 2245 |
2256 bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions, | 2246 bool Extension::LoadExtensionFeatures(string16* error) { |
2257 string16* error) { | |
2258 if (manifest_->HasKey(keys::kConvertedFromUserScript)) | 2247 if (manifest_->HasKey(keys::kConvertedFromUserScript)) |
2259 manifest_->GetBoolean(keys::kConvertedFromUserScript, | 2248 manifest_->GetBoolean(keys::kConvertedFromUserScript, |
2260 &converted_from_user_script_); | 2249 &converted_from_user_script_); |
2261 | 2250 |
2262 if (!LoadContentScripts(error) || | 2251 if (!LoadContentScripts(error) || |
2263 !LoadSystemIndicator(api_permissions, error) || | 2252 !LoadSystemIndicator(error) || |
2264 !LoadIncognitoMode(error) || | 2253 !LoadIncognitoMode(error) || |
2265 !LoadContentSecurityPolicy(error)) | 2254 !LoadContentSecurityPolicy(error)) |
2266 return false; | 2255 return false; |
2267 | 2256 |
2268 return true; | 2257 return true; |
2269 } | 2258 } |
2270 | 2259 |
2271 bool Extension::LoadContentScripts(string16* error) { | 2260 bool Extension::LoadContentScripts(string16* error) { |
2272 if (!manifest_->HasKey(keys::kContentScripts)) | 2261 if (!manifest_->HasKey(keys::kContentScripts)) |
2273 return true; | 2262 return true; |
(...skipping 17 matching lines...) Expand all Loading... |
2291 script.set_extension_id(id()); | 2280 script.set_extension_id(id()); |
2292 if (converted_from_user_script_) { | 2281 if (converted_from_user_script_) { |
2293 script.set_emulate_greasemonkey(true); | 2282 script.set_emulate_greasemonkey(true); |
2294 script.set_match_all_frames(true); // Greasemonkey matches all frames. | 2283 script.set_match_all_frames(true); // Greasemonkey matches all frames. |
2295 } | 2284 } |
2296 content_scripts_.push_back(script); | 2285 content_scripts_.push_back(script); |
2297 } | 2286 } |
2298 return true; | 2287 return true; |
2299 } | 2288 } |
2300 | 2289 |
2301 bool Extension::LoadSystemIndicator(APIPermissionSet* api_permissions, | 2290 bool Extension::LoadSystemIndicator(string16* error) { |
2302 string16* error) { | |
2303 if (!manifest_->HasKey(keys::kSystemIndicator)) { | 2291 if (!manifest_->HasKey(keys::kSystemIndicator)) { |
2304 // There was no manifest entry for the system indicator. | 2292 // There was no manifest entry for the system indicator. |
2305 return true; | 2293 return true; |
2306 } | 2294 } |
2307 | 2295 |
2308 DictionaryValue* system_indicator_value = NULL; | 2296 DictionaryValue* system_indicator_value = NULL; |
2309 if (!manifest_->GetDictionary(keys::kSystemIndicator, | 2297 if (!manifest_->GetDictionary(keys::kSystemIndicator, |
2310 &system_indicator_value)) { | 2298 &system_indicator_value)) { |
2311 *error = ASCIIToUTF16(errors::kInvalidSystemIndicator); | 2299 *error = ASCIIToUTF16(errors::kInvalidSystemIndicator); |
2312 return false; | 2300 return false; |
2313 } | 2301 } |
2314 | 2302 |
2315 system_indicator_info_ = LoadExtensionActionInfoHelper( | 2303 system_indicator_info_ = LoadExtensionActionInfoHelper( |
2316 this, system_indicator_value, error); | 2304 this, system_indicator_value, error); |
2317 | 2305 |
2318 if (!system_indicator_info_.get()) { | 2306 if (!system_indicator_info_.get()) { |
2319 return false; | 2307 return false; |
2320 } | 2308 } |
2321 | 2309 |
2322 // Because the manifest was successfully parsed, auto-grant the permission. | 2310 // Because the manifest was successfully parsed, auto-grant the permission. |
2323 // TODO(dewittj) Add this for all extension action APIs. | 2311 // TODO(dewittj) Add this for all extension action APIs. |
2324 api_permissions->insert(APIPermission::kSystemIndicator); | 2312 initial_api_permissions()->insert(APIPermission::kSystemIndicator); |
2325 | 2313 |
2326 return true; | 2314 return true; |
2327 } | 2315 } |
2328 | 2316 |
2329 bool Extension::LoadIncognitoMode(string16* error) { | 2317 bool Extension::LoadIncognitoMode(string16* error) { |
2330 // Apps default to split mode, extensions default to spanning. | 2318 // Apps default to split mode, extensions default to spanning. |
2331 incognito_split_mode_ = is_app(); | 2319 incognito_split_mode_ = is_app(); |
2332 if (!manifest_->HasKey(keys::kIncognito)) | 2320 if (!manifest_->HasKey(keys::kIncognito)) |
2333 return true; | 2321 return true; |
2334 std::string value; | 2322 std::string value; |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2794 | 2782 |
2795 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 2783 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
2796 const Extension* extension, | 2784 const Extension* extension, |
2797 const PermissionSet* permissions, | 2785 const PermissionSet* permissions, |
2798 Reason reason) | 2786 Reason reason) |
2799 : reason(reason), | 2787 : reason(reason), |
2800 extension(extension), | 2788 extension(extension), |
2801 permissions(permissions) {} | 2789 permissions(permissions) {} |
2802 | 2790 |
2803 } // namespace extensions | 2791 } // namespace extensions |
OLD | NEW |