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

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

Issue 11446034: SupportsUserData and manifest handlers for Extension; use them for the Omnibox API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + manifestdata Created 8 years 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/manifest_handler.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 872ef54e97172f0120bc04c4d97b68bb1be868fb..d42bd9cfa4eff7573743ba9252d3c31506c993bd 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -34,6 +34,7 @@
#include "chrome/common/extensions/features/simple_feature_provider.h"
#include "chrome/common/extensions/file_browser_handler.h"
#include "chrome/common/extensions/manifest.h"
+#include "chrome/common/extensions/manifest_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"
@@ -1272,6 +1273,21 @@ void Extension::ClearTabSpecificPermissions(int tab_id) const {
runtime_data_.ClearTabSpecificPermissions(tab_id);
}
+Extension::ManifestData* Extension::GetManifestData(const std::string& key)
+ const {
+ DCHECK(finished_parsing_manifest_);
+ ManifestDataMap::const_iterator iter = manifest_data_.find(key);
+ if (iter != manifest_data_.end())
+ return iter->second.get();
+ return NULL;
+}
+
+void Extension::SetManifestData(const std::string& key,
+ Extension::ManifestData* data) {
+ DCHECK(!finished_parsing_manifest_);
+ manifest_data_[key] = linked_ptr<ManifestData>(data);
+}
+
Extension::Location Extension::location() const {
return manifest_->location();
}
@@ -1430,6 +1446,7 @@ Extension::Extension(const FilePath& path,
background_page_is_persistent_(true),
allow_background_js_access_(true),
manifest_(manifest.release()),
+ finished_parsing_manifest_(false),
is_storage_isolated_(false),
launch_container_(extension_misc::LAUNCH_TAB),
launch_width_(0),
@@ -1547,6 +1564,8 @@ 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;
}
@@ -2741,7 +2760,8 @@ bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions,
manifest_->GetBoolean(keys::kConvertedFromUserScript,
&converted_from_user_script_);
- if (!LoadDevToolsPage(error) ||
+ if (!LoadManifestHandlerFeatures(error) ||
+ !LoadDevToolsPage(error) ||
!LoadInputComponents(*api_permissions, error) ||
!LoadContentScripts(error) ||
!LoadPageAction(error) ||
@@ -2750,7 +2770,6 @@ bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions,
!LoadScriptBadge(error) ||
!LoadFileBrowserHandlers(error) ||
!LoadChromeURLOverrides(error) ||
- !LoadOmnibox(error) ||
!LoadTextToSpeechVoices(error) ||
!LoadIncognitoMode(error) ||
!LoadFileHandlers(error) ||
@@ -2760,6 +2779,18 @@ bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions,
return true;
}
+bool Extension::LoadManifestHandlerFeatures(string16* error) {
+ std::vector<std::string> keys = ManifestHandler::GetKeys();
+ for (size_t i = 0; i < keys.size(); ++i) {
+ Value* value = NULL;
+ if (!manifest_->Get(keys[i], &value))
+ continue;
+ if (!ManifestHandler::Get(keys[i])->Parse(value, this, error))
+ return false;
+ }
+ return true;
+}
+
bool Extension::LoadDevToolsPage(string16* error) {
if (!manifest_->HasKey(keys::kDevToolsPage))
return true;
@@ -3312,17 +3343,6 @@ bool Extension::LoadChromeURLOverrides(string16* error) {
return true;
}
-bool Extension::LoadOmnibox(string16* error) {
- if (!manifest_->HasKey(keys::kOmnibox))
- return true;
- if (!manifest_->GetString(keys::kOmniboxKeyword, &omnibox_keyword_) ||
- omnibox_keyword_.empty()) {
- *error = ASCIIToUTF16(errors::kInvalidOmniboxKeyword);
- return false;
- }
- return true;
-}
-
bool Extension::LoadTextToSpeechVoices(string16* error) {
if (!manifest_->HasKey(keys::kTtsEngine))
return true;
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/manifest_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698