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

Unified Diff: chrome/browser/extensions/api/declarative_content/content_action.cc

Issue 344433003: Prepare declarativeContent API for new script injection feature. Added Javascript types and functio… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add note about what it means to revert RequestContentScript 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/browser/extensions/api/declarative_content/content_action.cc
diff --git a/chrome/browser/extensions/api/declarative_content/content_action.cc b/chrome/browser/extensions/api/declarative_content/content_action.cc
index 751f8d53383c946c633b1ef23066a414675e8554..68cc38f99fa034236699e3bee9349e9a920c1478 100644
--- a/chrome/browser/extensions/api/declarative_content/content_action.cc
+++ b/chrome/browser/extensions/api/declarative_content/content_action.cc
@@ -94,6 +94,41 @@ class ShowPageAction : public ContentAction {
DISALLOW_COPY_AND_ASSIGN(ShowPageAction);
};
+// Action that injects a content script.
+class RequestContentScript : public ContentAction {
Fady Samuel 2014/06/23 18:56:28 I feel like this should be called InjectContentScr
Mark Dittmer 2014/06/24 14:14:19 I agree, actually. What do you think kalman@?
+ public:
+ RequestContentScript() {}
+
+ static scoped_refptr<ContentAction> Create(const Extension* extension,
+ const base::DictionaryValue* dict,
+ std::string* error,
+ bool* bad_message) {
+ return scoped_refptr<ContentAction>(new RequestContentScript);
+ }
+
+ // Implementation of ContentAction:
+ virtual Type GetType() const OVERRIDE {
+ return ACTION_REQUEST_CONTENT_SCRIPT;
+ }
Fady Samuel 2014/06/23 18:56:28 Add empty line after this.
Mark Dittmer 2014/06/24 14:14:19 Done.
+ virtual void Apply(const std::string& extension_id,
+ const base::Time& extension_install_time,
+ ApplyInfo* apply_info) const OVERRIDE {
+ // TODO(markdittmer): Invoke UserScriptMaster declarative script loader:
+ // load new user script.
+ }
Fady Samuel 2014/06/23 18:56:28 Add empty line after this.
Mark Dittmer 2014/06/24 14:14:19 Done.
+ virtual void Revert(const std::string& extension_id,
+ const base::Time& extension_install_time,
+ ApplyInfo* apply_info) const OVERRIDE {
+ // TODO(markdittmer): Invoke UserScriptMaster declarative script loader:
+ // unload user script.
+ }
+
+ private:
+ virtual ~RequestContentScript() {}
+
+ DISALLOW_COPY_AND_ASSIGN(RequestContentScript);
+};
+
struct ContentActionFactory {
// Factory methods for ContentAction instances. |extension| is the extension
// for which the action is being created. |dict| contains the json dictionary
@@ -113,6 +148,8 @@ struct ContentActionFactory {
ContentActionFactory() {
factory_methods[keys::kShowPageAction] =
&ShowPageAction::Create;
+ factory_methods[keys::kRequestContentScript] =
+ &RequestContentScript::Create;
}
};

Powered by Google App Engine
This is Rietveld 408576698