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

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

Issue 11624036: Move the parsing of homepage_url" and "devtools_page" out of Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: patch-rebased- 2 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
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 9a0ebe54199c71082b76b58f3490c001c41147fa..bbbc5b7025ae9bfee7a9aeb6ff3f0c771ba8a9d5 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -34,6 +34,7 @@
#include "chrome/common/extensions/features/feature.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/extensions/manifest_handler.h"
+#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/extensions/permissions/permission_set.h"
#include "chrome/common/extensions/permissions/permissions_info.h"
#include "chrome/common/extensions/user_script.h"
@@ -470,7 +471,7 @@ void Extension::GetBasicInfo(bool enabled,
info->SetString(info_keys::kOptionsUrlKey,
options_url().possibly_invalid_spec());
info->SetString(info_keys::kHomepageUrlKey,
- GetHomepageURL().possibly_invalid_spec());
+ ManifestURL::GetHomepageURL(this).possibly_invalid_spec());
info->SetString(info_keys::kDetailsUrlKey,
details_url().possibly_invalid_spec());
info->SetBoolean(info_keys::kPackagedAppKey, is_platform_app());
@@ -935,14 +936,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())|
@@ -1624,6 +1617,8 @@ bool Extension::InitFromValue(int flags, string16* error) {
return false;
}
+ finished_parsing_manifest_ = true;
+
runtime_data_.SetActivePermissions(new PermissionSet(
this, api_permissions, host_permissions));
required_permission_set_ = new PermissionSet(
@@ -1631,8 +1626,6 @@ bool Extension::InitFromValue(int flags, string16* error) {
optional_permission_set_ = new PermissionSet(
optional_api_permissions, optional_host_permissions, URLPatternSet());
- finished_parsing_manifest_ = true;
-
return true;
}
@@ -1971,7 +1964,6 @@ bool Extension::LoadSharedFeatures(
const APIPermissionSet& api_permissions,
string16* error) {
if (!LoadDescription(error) ||
- !LoadHomepageURL(error) ||
!LoadUpdateURL(error) ||
!LoadIcons(error) ||
!LoadCommands(error) ||
@@ -2029,26 +2021,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;
@@ -2665,7 +2637,6 @@ bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions,
&converted_from_user_script_);
if (!LoadManifestHandlerFeatures(error) ||
- !LoadDevToolsPage(error) ||
!LoadContentScripts(error) ||
!LoadPageAction(error) ||
!LoadBrowserAction(error) ||
@@ -2692,18 +2663,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::LoadContentScripts(string16* error) {
if (!manifest_->HasKey(keys::kContentScripts))
return true;
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/manifest_tests/extension_manifests_devtools_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698