| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 } | 536 } |
| 537 | 537 |
| 538 bool Extension::is_platform_app() const { | 538 bool Extension::is_platform_app() const { |
| 539 return manifest_->is_platform_app(); | 539 return manifest_->is_platform_app(); |
| 540 } | 540 } |
| 541 | 541 |
| 542 bool Extension::is_hosted_app() const { | 542 bool Extension::is_hosted_app() const { |
| 543 return manifest()->is_hosted_app(); | 543 return manifest()->is_hosted_app(); |
| 544 } | 544 } |
| 545 | 545 |
| 546 bool Extension::is_packaged_app() const { | 546 bool Extension::is_legacy_packaged_app() const { |
| 547 return manifest()->is_packaged_app(); | 547 return manifest()->is_legacy_packaged_app(); |
| 548 } | 548 } |
| 549 | 549 |
| 550 bool Extension::is_theme() const { | 550 bool Extension::is_theme() const { |
| 551 return manifest()->is_theme(); | 551 return manifest()->is_theme(); |
| 552 } | 552 } |
| 553 | 553 |
| 554 GURL Extension::GetBackgroundURL() const { | 554 GURL Extension::GetBackgroundURL() const { |
| 555 if (background_scripts_.empty()) | 555 if (background_scripts_.empty()) |
| 556 return background_url_; | 556 return background_url_; |
| 557 return GetResourceURL(extension_filenames::kGeneratedBackgroundPageFilename); | 557 return GetResourceURL(extension_filenames::kGeneratedBackgroundPageFilename); |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 GURL url(launch_url); | 1218 GURL url(launch_url); |
| 1219 URLPattern pattern(kValidWebExtentSchemes); | 1219 URLPattern pattern(kValidWebExtentSchemes); |
| 1220 if (!url.is_valid() || !pattern.SetScheme(url.scheme())) { | 1220 if (!url.is_valid() || !pattern.SetScheme(url.scheme())) { |
| 1221 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 1221 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 1222 errors::kInvalidLaunchValue, | 1222 errors::kInvalidLaunchValue, |
| 1223 keys::kLaunchWebURL); | 1223 keys::kLaunchWebURL); |
| 1224 return false; | 1224 return false; |
| 1225 } | 1225 } |
| 1226 | 1226 |
| 1227 launch_web_url_ = launch_url; | 1227 launch_web_url_ = launch_url; |
| 1228 } else if (is_packaged_app() || is_hosted_app()) { | 1228 } else if (is_legacy_packaged_app() || is_hosted_app()) { |
| 1229 *error = ASCIIToUTF16(errors::kLaunchURLRequired); | 1229 *error = ASCIIToUTF16(errors::kLaunchURLRequired); |
| 1230 return false; | 1230 return false; |
| 1231 } | 1231 } |
| 1232 | 1232 |
| 1233 // If there is no extent, we default the extent based on the launch URL. | 1233 // If there is no extent, we default the extent based on the launch URL. |
| 1234 if (web_extent().is_empty() && !launch_web_url().empty()) { | 1234 if (web_extent().is_empty() && !launch_web_url().empty()) { |
| 1235 GURL launch_url(launch_web_url()); | 1235 GURL launch_url(launch_web_url()); |
| 1236 URLPattern pattern(kValidWebExtentSchemes); | 1236 URLPattern pattern(kValidWebExtentSchemes); |
| 1237 if (!pattern.SetScheme("*")) { | 1237 if (!pattern.SetScheme("*")) { |
| 1238 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 1238 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1994 if (!intent_service.GetString(keys::kIntentHref, &href)) { | 1994 if (!intent_service.GetString(keys::kIntentHref, &href)) { |
| 1995 *error = ASCIIToUTF16(errors::kInvalidIntentHref); | 1995 *error = ASCIIToUTF16(errors::kInvalidIntentHref); |
| 1996 return false; | 1996 return false; |
| 1997 } | 1997 } |
| 1998 } | 1998 } |
| 1999 | 1999 |
| 2000 // For packaged/hosted apps, empty href implies the respective launch URLs. | 2000 // For packaged/hosted apps, empty href implies the respective launch URLs. |
| 2001 if (href.empty()) { | 2001 if (href.empty()) { |
| 2002 if (is_hosted_app()) { | 2002 if (is_hosted_app()) { |
| 2003 href = launch_web_url(); | 2003 href = launch_web_url(); |
| 2004 } else if (is_packaged_app()) { | 2004 } else if (is_legacy_packaged_app()) { |
| 2005 href = launch_local_path(); | 2005 href = launch_local_path(); |
| 2006 } | 2006 } |
| 2007 } | 2007 } |
| 2008 | 2008 |
| 2009 // If there still is not an href, the manifest is malformed, unless this is a | 2009 // If there still is not an href, the manifest is malformed, unless this is a |
| 2010 // platform app in which case the href should not be present. | 2010 // platform app in which case the href should not be present. |
| 2011 if (href.empty() && !is_platform_app()) { | 2011 if (href.empty() && !is_platform_app()) { |
| 2012 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2012 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 2013 errors::kInvalidIntentHrefEmpty, action_name); | 2013 errors::kInvalidIntentHrefEmpty, action_name); |
| 2014 return false; | 2014 return false; |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2620 #endif | 2620 #endif |
| 2621 | 2621 |
| 2622 if (is_override || !overrides->GetStringWithoutPathExpansion(*iter, &val)) { | 2622 if (is_override || !overrides->GetStringWithoutPathExpansion(*iter, &val)) { |
| 2623 *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides); | 2623 *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides); |
| 2624 return false; | 2624 return false; |
| 2625 } | 2625 } |
| 2626 // Replace the entry with a fully qualified chrome-extension:// URL. | 2626 // Replace the entry with a fully qualified chrome-extension:// URL. |
| 2627 chrome_url_overrides_[page] = GetResourceURL(val); | 2627 chrome_url_overrides_[page] = GetResourceURL(val); |
| 2628 | 2628 |
| 2629 // For component extensions, add override URL to extent patterns. | 2629 // For component extensions, add override URL to extent patterns. |
| 2630 if (is_packaged_app() && location() == COMPONENT) { | 2630 if (is_legacy_packaged_app() && location() == COMPONENT) { |
| 2631 URLPattern pattern(URLPattern::SCHEME_CHROMEUI); | 2631 URLPattern pattern(URLPattern::SCHEME_CHROMEUI); |
| 2632 std::string url = base::StringPrintf(kOverrideExtentUrlPatternFormat, | 2632 std::string url = base::StringPrintf(kOverrideExtentUrlPatternFormat, |
| 2633 page.c_str()); | 2633 page.c_str()); |
| 2634 if (pattern.Parse(url) != URLPattern::PARSE_SUCCESS) { | 2634 if (pattern.Parse(url) != URLPattern::PARSE_SUCCESS) { |
| 2635 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2635 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 2636 errors::kInvalidURLPatternError, url); | 2636 errors::kInvalidURLPatternError, url); |
| 2637 return false; | 2637 return false; |
| 2638 } | 2638 } |
| 2639 extent_.AddPattern(pattern); | 2639 extent_.AddPattern(pattern); |
| 2640 } | 2640 } |
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3795 return SYNC_TYPE_EXTENSION; | 3795 return SYNC_TYPE_EXTENSION; |
| 3796 | 3796 |
| 3797 case Extension::TYPE_USER_SCRIPT: | 3797 case Extension::TYPE_USER_SCRIPT: |
| 3798 // We only want to sync user scripts with gallery update URLs. | 3798 // We only want to sync user scripts with gallery update URLs. |
| 3799 if (UpdatesFromGallery()) | 3799 if (UpdatesFromGallery()) |
| 3800 return SYNC_TYPE_EXTENSION; | 3800 return SYNC_TYPE_EXTENSION; |
| 3801 else | 3801 else |
| 3802 return SYNC_TYPE_NONE; | 3802 return SYNC_TYPE_NONE; |
| 3803 | 3803 |
| 3804 case Extension::TYPE_HOSTED_APP: | 3804 case Extension::TYPE_HOSTED_APP: |
| 3805 case Extension::TYPE_PACKAGED_APP: | 3805 case Extension::TYPE_LEGACY_PACKAGED_APP: |
| 3806 return SYNC_TYPE_APP; | 3806 return SYNC_TYPE_APP; |
| 3807 | 3807 |
| 3808 default: | 3808 default: |
| 3809 return SYNC_TYPE_NONE; | 3809 return SYNC_TYPE_NONE; |
| 3810 } | 3810 } |
| 3811 } | 3811 } |
| 3812 | 3812 |
| 3813 bool Extension::IsSyncable() const { | 3813 bool Extension::IsSyncable() const { |
| 3814 // TODO(akalin): Figure out if we need to allow some other types. | 3814 // TODO(akalin): Figure out if we need to allow some other types. |
| 3815 | 3815 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4025 | 4025 |
| 4026 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 4026 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 4027 const Extension* extension, | 4027 const Extension* extension, |
| 4028 const PermissionSet* permissions, | 4028 const PermissionSet* permissions, |
| 4029 Reason reason) | 4029 Reason reason) |
| 4030 : reason(reason), | 4030 : reason(reason), |
| 4031 extension(extension), | 4031 extension(extension), |
| 4032 permissions(permissions) {} | 4032 permissions(permissions) {} |
| 4033 | 4033 |
| 4034 } // namespace extensions | 4034 } // namespace extensions |
| OLD | NEW |