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

Unified Diff: chrome/common/extensions/extension.cc

Issue 11726002: Move the parsing of 'update_url' & 'options_page' URLs out of Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@url_parse
Patch Set: fixed HomepageURLManifestTest.GetHomepageURL Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_file_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 4fef5528de775e98b122f920cb3a2ae6e61851b2..3bfa0163d3b09ef50eb31a7033a43053726dd52f 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -464,7 +464,7 @@ void Extension::GetBasicInfo(bool enabled,
info->SetString(info_keys::kVersionKey, VersionString());
info->SetString(info_keys::kDescriptionKey, description());
info->SetString(info_keys::kOptionsUrlKey,
- options_url().possibly_invalid_spec());
+ ManifestURL::GetOptionsPage(this).possibly_invalid_spec());
info->SetString(info_keys::kHomepageUrlKey,
ManifestURL::GetHomepageURL(this).possibly_invalid_spec());
info->SetString(info_keys::kDetailsUrlKey,
@@ -1120,7 +1120,7 @@ bool Extension::CanCaptureVisiblePage(const GURL& page_url,
}
bool Extension::UpdatesFromGallery() const {
- return extension_urls::IsWebstoreUpdateUrl(update_url());
+ return extension_urls::IsWebstoreUpdateUrl(ManifestURL::GetUpdateURL(this));
}
bool Extension::OverlapsWithOrigin(const GURL& origin) const {
@@ -1153,7 +1153,7 @@ Extension::SyncType Extension::GetSyncType() const {
//
// TODO(akalin): Relax this restriction once we've put in UI to
// approve synced extensions.
- if (!update_url().is_empty() && !UpdatesFromGallery())
+ if (!ManifestURL::GetUpdateURL(this).is_empty() && !UpdatesFromGallery())
return SYNC_TYPE_NONE;
// Disallow extensions with native code plugins.
@@ -1963,7 +1963,6 @@ bool Extension::LoadSharedFeatures(
const APIPermissionSet& api_permissions,
string16* error) {
if (!LoadDescription(error) ||
- !LoadUpdateURL(error) ||
!LoadIcons(error) ||
!LoadCommands(error) ||
!LoadPlugins(error) ||
@@ -1973,7 +1972,6 @@ bool Extension::LoadSharedFeatures(
!LoadRequirements(error) ||
!LoadDefaultLocale(error) ||
!LoadOfflineEnabled(error) ||
- !LoadOptionsPage(error) ||
// LoadBackgroundScripts() must be called before LoadBackgroundPage().
!LoadBackgroundScripts(error) ||
!LoadBackgroundPage(api_permissions, error) ||
@@ -2020,25 +2018,6 @@ bool Extension::LoadManifestVersion(string16* error) {
return true;
}
-bool Extension::LoadUpdateURL(string16* error) {
- if (!manifest_->HasKey(keys::kUpdateURL))
- return true;
- std::string tmp_update_url;
- if (!manifest_->GetString(keys::kUpdateURL, &tmp_update_url)) {
- *error = ErrorUtils::FormatErrorMessageUTF16(
- errors::kInvalidUpdateURL, "");
- return false;
- }
- update_url_ = GURL(tmp_update_url);
- if (!update_url_.is_valid() ||
- update_url_.has_ref()) {
- *error = ErrorUtils::FormatErrorMessageUTF16(
- errors::kInvalidUpdateURL, tmp_update_url);
- return false;
- }
- return true;
-}
-
bool Extension::LoadIcons(string16* error) {
if (!manifest_->HasKey(keys::kIcons))
return true;
@@ -2390,40 +2369,6 @@ bool Extension::LoadOfflineEnabled(string16* error) {
return true;
}
-bool Extension::LoadOptionsPage(string16* error) {
- if (!manifest_->HasKey(keys::kOptionsPage))
- return true;
- std::string options_str;
- if (!manifest_->GetString(keys::kOptionsPage, &options_str)) {
- *error = ASCIIToUTF16(errors::kInvalidOptionsPage);
- return false;
- }
-
- if (is_hosted_app()) {
- // hosted apps require an absolute URL.
- GURL options_url(options_str);
- if (!options_url.is_valid() ||
- !(options_url.SchemeIs("http") || options_url.SchemeIs("https"))) {
- *error = ASCIIToUTF16(errors::kInvalidOptionsPageInHostedApp);
- return false;
- }
- options_url_ = options_url;
- } else {
- GURL absolute(options_str);
- if (absolute.is_valid()) {
- *error = ASCIIToUTF16(errors::kInvalidOptionsPageExpectUrlInPackage);
- return false;
- }
- options_url_ = GetResourceURL(options_str);
- if (!options_url_.is_valid()) {
- *error = ASCIIToUTF16(errors::kInvalidOptionsPage);
- return false;
- }
- }
-
- return true;
-}
-
bool Extension::LoadBackgroundScripts(string16* error) {
const std::string& key = is_platform_app() ?
keys::kPlatformAppBackgroundScripts : keys::kBackgroundScripts;
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698