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

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

Issue 174277: override chrome:// URLs via extensions. (Closed)
Patch Set: fix linux errors Created 11 years, 4 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_constants.h » ('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 134ee3fa4e17b84a9781c181945ae120b3217d74..6cf5c338ff0df0de5d92b9c0c7e2f4d4a6d3b2fa 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -997,6 +997,37 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id,
set_default_locale(default_locale);
}
+ // Chrome URL overrides (optional)
+ if (source.HasKey(keys::kChromeURLOverrides)) {
+ DictionaryValue* overrides;
+ if (!source.GetDictionary(keys::kChromeURLOverrides, &overrides)) {
+ *error = errors::kInvalidChromeURLOverrides;
+ return false;
+ }
+ // Validate that the overrides are all strings
+ DictionaryValue::key_iterator iter = overrides->begin_keys();
+ while (iter != overrides->end_keys()) {
+ // For now, only allow the new tab page. Others will work when we remove
+ // this check, but let's keep it simple for now.
+ // TODO(erikkay) enable other pages as well
+ if (WideToUTF8(*iter) != chrome::kChromeUINewTabHost) {
+ *error = errors::kInvalidChromeURLOverrides;
+ return false;
+ }
+ std::string val;
+ if (!overrides->GetString(*iter, &val)) {
+ *error = errors::kInvalidChromeURLOverrides;
+ return false;
+ }
+ // Replace the entry with a fully qualified chrome-extension:// URL.
+ GURL url = GetResourceURL(val);
+ overrides->SetString(*iter, url.spec());
+ ++iter;
+ }
+ chrome_url_overrides_.reset(
+ static_cast<DictionaryValue*>(overrides->DeepCopy()));
+ }
+
return true;
}
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698