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

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

Issue 311193005: Add the about_page key to shared_module manifest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit Created 6 years, 6 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/manifest_url_handler.cc
diff --git a/chrome/common/extensions/manifest_url_handler.cc b/chrome/common/extensions/manifest_url_handler.cc
index c7b7d47e6c20194ae850996818faaa7a02b8fe57..5eecd48101713f4627dadbfcbabe73146d9c167b 100644
--- a/chrome/common/extensions/manifest_url_handler.cc
+++ b/chrome/common/extensions/manifest_url_handler.cc
@@ -85,6 +85,11 @@ const GURL& ManifestURL::GetOptionsPage(const Extension* extension) {
}
// static
+const GURL& ManifestURL::GetAboutPage(const Extension* extension) {
+ return GetManifestURL(extension, keys::kAboutPage);
+}
+
+// static
const GURL ManifestURL::GetDetailsURL(const Extension* extension) {
return extension->from_webstore() ?
GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + extension->id()) :
@@ -263,6 +268,57 @@ const std::vector<std::string> OptionsPageHandler::Keys() const {
return SingleKey(keys::kOptionsPage);
}
+AboutPageHandler::AboutPageHandler() {
+}
+
+AboutPageHandler::~AboutPageHandler() {
+}
+
+bool AboutPageHandler::Parse(Extension* extension, base::string16* error) {
+ scoped_ptr<ManifestURL> manifest_url(new ManifestURL);
+ std::string about_str;
+ if (!extension->manifest()->GetString(keys::kAboutPage, &about_str)) {
+ *error = base::ASCIIToUTF16(errors::kInvalidAboutPage);
+ return false;
+ }
+
+ GURL absolute(about_str);
+ if (absolute.is_valid()) {
+ *error = base::ASCIIToUTF16(errors::kInvalidAboutPageExpectRelativePath);
+ return false;
+ }
+ manifest_url->url_ = extension->GetResourceURL(about_str);
+ if (!manifest_url->url_.is_valid()) {
+ *error = base::ASCIIToUTF16(errors::kInvalidAboutPage);
+ return false;
+ }
+ extension->SetManifestData(keys::kAboutPage, manifest_url.release());
+ return true;
+}
+
+bool AboutPageHandler::Validate(const Extension* extension,
+ std::string* error,
+ std::vector<InstallWarning>* warnings) const {
+ // Validate path to the options page.
+ if (!extensions::ManifestURL::GetAboutPage(extension).is_empty()) {
+ const base::FilePath about_path =
+ extensions::file_util::ExtensionURLToRelativeFilePath(
+ extensions::ManifestURL::GetAboutPage(extension));
+ const base::FilePath path =
+ extension->GetResource(about_path).GetFilePath();
+ if (path.empty() || !base::PathExists(path)) {
+ *error = l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_ABOUT_PAGE_FAILED,
+ about_path.LossyDisplayName());
+ return false;
+ }
+ }
+ return true;
+}
+
+const std::vector<std::string> AboutPageHandler::Keys() const {
+ return SingleKey(keys::kAboutPage);
+}
+
URLOverridesHandler::URLOverridesHandler() {
}
« no previous file with comments | « chrome/common/extensions/manifest_url_handler.h ('k') | chrome/test/data/extensions/manifest_tests/shared_module_about.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698