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

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

Issue 492133002: Renderer changes for wiring up shared memory with declarative injection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix final nits Created 6 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 | « no previous file | chrome/browser/extensions/api/declarative_content/content_action.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/declarative_content/content_action.h
diff --git a/chrome/browser/extensions/api/declarative_content/content_action.h b/chrome/browser/extensions/api/declarative_content/content_action.h
index ab191c3e2c174f9316efc34366023a3aa6d0ada1..40daa7aa1ed6cae1e3778f7ea2362efa82aa3422 100644
--- a/chrome/browser/extensions/api/declarative_content/content_action.h
+++ b/chrome/browser/extensions/api/declarative_content/content_action.h
@@ -10,6 +10,7 @@
#include "base/memory/ref_counted.h"
#include "chrome/browser/extensions/api/declarative/declarative_rule.h"
+#include "chrome/browser/extensions/declarative_user_script_master.h"
class Profile;
@@ -70,11 +71,97 @@ class ContentAction : public base::RefCounted<ContentAction> {
std::string* error,
bool* bad_message);
+ // Shared procedure for resetting error state within factories.
+ static void ResetErrorData(std::string* error, bool* bad_message) {
+ *error = "";
+ *bad_message = false;
+ }
+
+ // Shared procedure for validating JSON data.
+ static bool Validate(const base::Value& json_action,
+ std::string* error,
+ bool* bad_message,
+ const base::DictionaryValue** action_dict,
+ std::string* instance_type);
+
protected:
friend class base::RefCounted<ContentAction>;
virtual ~ContentAction();
};
+// Action that injects a content script.
+class RequestContentScript : public ContentAction {
+ public:
+ struct ScriptData {
+ ScriptData();
+ ~ScriptData();
+
+ std::vector<std::string> css_file_names;
+ std::vector<std::string> js_file_names;
+ bool all_frames;
+ bool match_about_blank;
+ };
+
+ RequestContentScript(content::BrowserContext* browser_context,
+ const Extension* extension,
+ const ScriptData& script_data);
+ RequestContentScript(DeclarativeUserScriptMaster* master,
+ const Extension* extension,
+ const ScriptData& script_data);
+
+ static scoped_refptr<ContentAction> Create(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ const base::DictionaryValue* dict,
+ std::string* error,
+ bool* bad_message);
+
+ static scoped_refptr<ContentAction> CreateForTest(
+ DeclarativeUserScriptMaster* master,
+ const Extension* extension,
+ const base::Value& json_action,
+ std::string* error,
+ bool* bad_message);
+
+ static bool InitScriptData(const base::DictionaryValue* dict,
+ std::string* error,
+ bool* bad_message,
+ ScriptData* script_data);
+
+ // Implementation of ContentAction:
+ virtual Type GetType() const OVERRIDE;
+
+ virtual void Apply(const std::string& extension_id,
+ const base::Time& extension_install_time,
+ ApplyInfo* apply_info) const OVERRIDE;
+
+ virtual void Reapply(const std::string& extension_id,
+ const base::Time& extension_install_time,
+ ApplyInfo* apply_info) const OVERRIDE;
+
+ virtual void Revert(const std::string& extension_id,
+ const base::Time& extension_install_time,
+ ApplyInfo* apply_info) const OVERRIDE;
+
+ private:
+ void InitScript(const Extension* extension, const ScriptData& script_data);
+
+ void AddScript() {
+ DCHECK(master_);
+ master_->AddScript(script_);
+ }
+
+ virtual ~RequestContentScript();
+
+ void InstructRenderProcessToInject(content::WebContents* contents,
+ const std::string& extension_id) const;
+
+ UserScript script_;
+ DeclarativeUserScriptMaster* master_;
+
+ DISALLOW_COPY_AND_ASSIGN(RequestContentScript);
+};
+
typedef DeclarativeActionSet<ContentAction> ContentActionSet;
} // namespace extensions
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative_content/content_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698