| 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
|
|
|