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

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

Issue 1530002: Move history API out of experimental. Allow extensions to override history page. (Closed)
Patch Set: Rebase for commit. Created 10 years, 9 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 7deff534298e15cce0e1744a3cba657603e0ee96..c583bc99a70bee72df5f718d1d2433f16d741331 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -106,13 +106,15 @@ const char* Extension::kBookmarkPermission = "bookmarks";
const char* Extension::kNotificationPermission = "notifications";
const char* Extension::kExperimentalPermission = "experimental";
const char* Extension::kUnlimitedStoragePermission = "unlimited_storage";
+const char* Extension::kHistoryPermission = "history";
const char* Extension::kPermissionNames[] = {
Extension::kTabPermission,
Extension::kBookmarkPermission,
Extension::kNotificationPermission,
Extension::kExperimentalPermission,
- Extension::kUnlimitedStoragePermission
+ Extension::kUnlimitedStoragePermission,
+ Extension::kHistoryPermission
};
const size_t Extension::kNumPermissions =
arraysize(Extension::kPermissionNames);
@@ -1371,12 +1373,11 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
for (DictionaryValue::key_iterator iter = overrides->begin_keys();
iter != overrides->end_keys(); ++iter) {
std::string page = WideToUTF8(*iter);
- // 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
std::string val;
+ // Restrict override pages to a list of supported URLs.
if ((page != chrome::kChromeUINewTabHost &&
- page != chrome::kChromeUIBookmarksHost) ||
+ page != chrome::kChromeUIBookmarksHost &&
+ page != chrome::kChromeUIHistoryHost) ||
!overrides->GetStringWithoutPathExpansion(*iter, &val)) {
*error = errors::kInvalidChromeURLOverrides;
return false;
@@ -1384,6 +1385,12 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
// Replace the entry with a fully qualified chrome-extension:// URL.
chrome_url_overrides_[page] = GetResourceURL(val);
}
+
+ // An extension may override at most one page.
+ if (overrides->size() > 1) {
+ *error = errors::kMultipleOverrides;
+ return false;
+ }
}
if (!CheckAppsAreEnabled(manifest_value_.get(), error) ||
« 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