| Index: chrome/common/extensions/extension.cc
|
| diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
|
| index a3c226a1da941e58cb9b4683c928e4d192d4ce5b..b1557b36d9300b41751b3833c761edd5b0f30fde 100644
|
| --- a/chrome/common/extensions/extension.cc
|
| +++ b/chrome/common/extensions/extension.cc
|
| @@ -26,10 +26,11 @@
|
| #include "chrome/common/chrome_constants.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/chrome_version_info.h"
|
| -// TODO(rdevlin.cronin): Remove this once PageAction, BrowserAction, and
|
| -// SystemIndicator have been moved out of Extension.
|
| +// TODO(rdevlin.cronin): Remove these once all accessors have been moved out of
|
| +// the core Extension class.
|
| #include "chrome/common/extensions/api/extension_action/action_handler_helpers.h"
|
| #include "chrome/common/extensions/api/extension_action/action_info.h"
|
| +#include "chrome/common/extensions/api/extension_urls/extension_urls_handler.h"
|
| #include "chrome/common/extensions/csp_validator.h"
|
| #include "chrome/common/extensions/extension_manifest_constants.h"
|
| #include "chrome/common/extensions/extension_resource.h"
|
| @@ -450,9 +451,9 @@ 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());
|
| + ExtensionURL::GetOptionsURL(this).possibly_invalid_spec());
|
| info->SetString(info_keys::kHomepageUrlKey,
|
| - GetHomepageURL().possibly_invalid_spec());
|
| + ExtensionURL::GetHomepageURL(this).possibly_invalid_spec());
|
| info->SetString(info_keys::kDetailsUrlKey,
|
| details_url().possibly_invalid_spec());
|
| info->SetBoolean(info_keys::kPackagedAppKey, is_platform_app());
|
| @@ -917,14 +918,6 @@ bool Extension::ShowConfigureContextMenus() const {
|
| return location() != Extension::COMPONENT;
|
| }
|
|
|
| -GURL Extension::GetHomepageURL() const {
|
| - if (homepage_url_.is_valid())
|
| - return homepage_url_;
|
| -
|
| - return UpdatesFromGallery() ?
|
| - GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + id()) : GURL();
|
| -}
|
| -
|
| std::set<FilePath> Extension::GetBrowserImages() const {
|
| std::set<FilePath> image_paths;
|
| // TODO(viettrungluu): These |FilePath::FromWStringHack(UTF8ToWide())|
|
| @@ -1115,7 +1108,7 @@ bool Extension::CanCaptureVisiblePage(const GURL& page_url,
|
| }
|
|
|
| bool Extension::UpdatesFromGallery() const {
|
| - return extension_urls::IsWebstoreUpdateUrl(update_url());
|
| + return extension_urls::IsWebstoreUpdateUrl(ExtensionURL::GetUpdateURL(this));
|
| }
|
|
|
| bool Extension::OverlapsWithOrigin(const GURL& origin) const {
|
| @@ -1148,7 +1141,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 (!ExtensionURL::GetUpdateURL(this).is_empty() && !UpdatesFromGallery())
|
| return SYNC_TYPE_NONE;
|
|
|
| // Disallow extensions with native code plugins.
|
| @@ -1907,8 +1900,6 @@ bool Extension::LoadSharedFeatures(
|
| const APIPermissionSet& api_permissions,
|
| string16* error) {
|
| if (!LoadDescription(error) ||
|
| - !LoadHomepageURL(error) ||
|
| - !LoadUpdateURL(error) ||
|
| !LoadIcons(error) ||
|
| !LoadCommands(error) ||
|
| !LoadPlugins(error) ||
|
| @@ -1918,7 +1909,6 @@ bool Extension::LoadSharedFeatures(
|
| !LoadRequirements(error) ||
|
| !LoadDefaultLocale(error) ||
|
| !LoadOfflineEnabled(error) ||
|
| - !LoadOptionsPage(error) ||
|
| // LoadBackgroundScripts() must be called before LoadBackgroundPage().
|
| !LoadBackgroundScripts(error) ||
|
| !LoadBackgroundPage(api_permissions, error) ||
|
| @@ -1966,45 +1956,6 @@ bool Extension::LoadManifestVersion(string16* error) {
|
| return true;
|
| }
|
|
|
| -bool Extension::LoadHomepageURL(string16* error) {
|
| - if (!manifest_->HasKey(keys::kHomepageURL))
|
| - return true;
|
| - std::string tmp_homepage_url;
|
| - if (!manifest_->GetString(keys::kHomepageURL, &tmp_homepage_url)) {
|
| - *error = ErrorUtils::FormatErrorMessageUTF16(
|
| - errors::kInvalidHomepageURL, "");
|
| - return false;
|
| - }
|
| - homepage_url_ = GURL(tmp_homepage_url);
|
| - if (!homepage_url_.is_valid() ||
|
| - (!homepage_url_.SchemeIs("http") &&
|
| - !homepage_url_.SchemeIs("https"))) {
|
| - *error = ErrorUtils::FormatErrorMessageUTF16(
|
| - errors::kInvalidHomepageURL, tmp_homepage_url);
|
| - return false;
|
| - }
|
| - 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;
|
| @@ -2357,40 +2308,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;
|
| @@ -2765,7 +2682,6 @@ bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions,
|
| &converted_from_user_script_);
|
|
|
| if (!LoadManifestHandlerFeatures(error) ||
|
| - !LoadDevToolsPage(error) ||
|
| !LoadInputComponents(*api_permissions, error) ||
|
| !LoadContentScripts(error) ||
|
| !LoadPageAction(error) ||
|
| @@ -2794,18 +2710,6 @@ bool Extension::LoadManifestHandlerFeatures(string16* error) {
|
| return true;
|
| }
|
|
|
| -bool Extension::LoadDevToolsPage(string16* error) {
|
| - if (!manifest_->HasKey(keys::kDevToolsPage))
|
| - return true;
|
| - std::string devtools_str;
|
| - if (!manifest_->GetString(keys::kDevToolsPage, &devtools_str)) {
|
| - *error = ASCIIToUTF16(errors::kInvalidDevToolsPage);
|
| - return false;
|
| - }
|
| - devtools_url_ = GetResourceURL(devtools_str);
|
| - return true;
|
| -}
|
| -
|
| bool Extension::LoadInputComponents(const APIPermissionSet& api_permissions,
|
| string16* error) {
|
| if (!manifest_->HasKey(keys::kInputComponents))
|
|
|