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

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

Issue 7917006: Extension loading extracts intents from Manifest data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 af1f538d9c90bcce2b30774aa5c26c33a8de308e..d32fc76fd7b6bdf03c302f4332cc3196a6247343 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -22,6 +22,7 @@
#include "base/values.h"
#include "base/version.h"
#include "crypto/sha2.h"
+#include "chrome/browser/intents/web_intent_data.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
@@ -174,6 +175,72 @@ int GetLocationRank(Extension::Location location) {
return rank;
}
+bool InitializeWebIntents(const DictionaryValue& source,
+ std::vector<WebIntentData>* intents,
+ std::string* error) {
+ DCHECK(intents);
Greg Billock 2011/09/16 15:43:17 Add the flag check.
groby-ooo-7-16 2011/09/16 17:40:37 Which flag check?
Greg Billock 2011/09/16 18:45:51 if (!CommandLine::ForCurrentProcess()->HasSwitch(s
groby-ooo-7-16 2011/09/17 01:14:42 Done.
+ DCHECK(error);
+ if (!source.HasKey(keys::kIntents))
+ return true;
+
+ DictionaryValue* all_intents = NULL;
+ if (!source.GetDictionary(keys::kIntents, &all_intents)) {
+ *error = errors::kInvalidIntents;
+ return false;
+ }
+
+ std::string value;
+ DictionaryValue::key_iterator iter(all_intents->begin_keys());
+ for (; iter != all_intents->end_keys(); ++iter) {
+ WebIntentData intent;
+
+ intent.service_url = GURL(*iter);
+ DictionaryValue* one_intent = NULL;
+ if (!all_intents->GetDictionaryWithoutPathExpansion(*iter, &one_intent)) {
+ *error = errors::kInvalidIntent;
+ return false;
+ }
+
+ // TODO(groby): Support an array of types
+ if (one_intent->HasKey(keys::kIntentType)) {
+ if (!one_intent->GetString(
+ keys::kIntentType, &intent.type)) {
+ *error = errors::kInvalidIntentType;
+ return false;
+ }
+ }
+
+ if (!one_intent->GetString(
+ keys::kIntentAction, &intent.action)) {
+ *error = errors::kInvalidIntentAction;
+ return false;
+ }
+
+ if (one_intent->HasKey(keys::kIntentTitle)) {
+ if (!one_intent->GetString(
+ keys::kIntentTitle, &intent.title)) {
+ *error = errors::kInvalidIntentTitle;
+ return false;
+ }
+ }
+
+ if (one_intent->HasKey(keys::kIntentDisposition)) {
+ if (!one_intent->GetString(keys::kIntentDisposition, &value) ||
+ (value != values::kIntentDispositionWindow &&
+ value != values::kIntentDispositionInline)) {
+ *error = errors::kInvalidIntentDisposition;
+ return false;
+ }
+ if (value == values::kIntentDispositionInline)
+ intent.disposition = WebIntentData::DISPOSITION_INLINE;
+ else
+ intent.disposition = WebIntentData::DISPOSITION_WINDOW;
+ }
+
+ intents->push_back(intent);
+ }
+ return true;
+}
} // namespace
const FilePath::CharType Extension::kManifestFilename[] =
@@ -2272,6 +2339,10 @@ bool Extension::InitFromValue(const DictionaryValue& source, int flags,
}
}
+ // Initialize web intents (optional).
+ if (!InitializeWebIntents(source, &intents_, error))
+ return false;
+
// Initialize incognito behavior. Apps default to split mode, extensions
// default to spanning.
incognito_split_mode_ = is_app();

Powered by Google App Engine
This is Rietveld 408576698