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

Side by Side 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, 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "chrome/browser/extensions/api/declarative/declarative_rule.h" 12 #include "chrome/browser/extensions/api/declarative/declarative_rule.h"
13 #include "chrome/browser/extensions/declarative_user_script_master.h"
13 14
14 class Profile; 15 class Profile;
15 16
16 namespace base { 17 namespace base {
17 class Time; 18 class Time;
18 class Value; 19 class Value;
19 } 20 }
20 21
21 namespace content { 22 namespace content {
22 class WebContents; 23 class WebContents;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // Sets |error| and returns NULL in case of a semantic error that cannot 64 // Sets |error| and returns NULL in case of a semantic error that cannot
64 // be caught by schema validation. Sets |bad_message| and returns NULL 65 // be caught by schema validation. Sets |bad_message| and returns NULL
65 // in case the input is syntactically unexpected. 66 // in case the input is syntactically unexpected.
66 static scoped_refptr<ContentAction> Create( 67 static scoped_refptr<ContentAction> Create(
67 content::BrowserContext* browser_context, 68 content::BrowserContext* browser_context,
68 const Extension* extension, 69 const Extension* extension,
69 const base::Value& json_action, 70 const base::Value& json_action,
70 std::string* error, 71 std::string* error,
71 bool* bad_message); 72 bool* bad_message);
72 73
74 // Shared procedure for resetting error state within factories.
75 static void ResetErrorData(std::string* error, bool* bad_message) {
76 *error = "";
77 *bad_message = false;
78 }
79
80 // Shared procedure for validating JSON data.
81 static bool Validate(const base::Value& json_action,
82 std::string* error,
83 bool* bad_message,
84 const base::DictionaryValue** action_dict,
85 std::string* instance_type);
86
73 protected: 87 protected:
74 friend class base::RefCounted<ContentAction>; 88 friend class base::RefCounted<ContentAction>;
75 virtual ~ContentAction(); 89 virtual ~ContentAction();
76 }; 90 };
77 91
92 // Action that injects a content script.
93 class RequestContentScript : public ContentAction {
94 public:
95 struct ScriptData {
96 ScriptData();
97 ~ScriptData();
98
99 std::vector<std::string> css_file_names;
100 std::vector<std::string> js_file_names;
101 bool all_frames;
102 bool match_about_blank;
103 };
104
105 RequestContentScript(content::BrowserContext* browser_context,
106 const Extension* extension,
107 const ScriptData& script_data);
108 RequestContentScript(DeclarativeUserScriptMaster* master,
109 const Extension* extension,
110 const ScriptData& script_data);
111
112 static scoped_refptr<ContentAction> Create(
113 content::BrowserContext* browser_context,
114 const Extension* extension,
115 const base::DictionaryValue* dict,
116 std::string* error,
117 bool* bad_message);
118
119 static scoped_refptr<ContentAction> CreateForTest(
120 DeclarativeUserScriptMaster* master,
121 const Extension* extension,
122 const base::Value& json_action,
123 std::string* error,
124 bool* bad_message);
125
126 static bool InitScriptData(const base::DictionaryValue* dict,
127 std::string* error,
128 bool* bad_message,
129 ScriptData* script_data);
130
131 // Implementation of ContentAction:
132 virtual Type GetType() const OVERRIDE;
133
134 virtual void Apply(const std::string& extension_id,
135 const base::Time& extension_install_time,
136 ApplyInfo* apply_info) const OVERRIDE;
137
138 virtual void Reapply(const std::string& extension_id,
139 const base::Time& extension_install_time,
140 ApplyInfo* apply_info) const OVERRIDE;
141
142 virtual void Revert(const std::string& extension_id,
143 const base::Time& extension_install_time,
144 ApplyInfo* apply_info) const OVERRIDE;
145
146 private:
147 void InitScript(const Extension* extension, const ScriptData& script_data);
148
149 void AddScript() {
150 DCHECK(master_);
151 master_->AddScript(script_);
152 }
153
154 virtual ~RequestContentScript();
155
156 void InstructRenderProcessToInject(content::WebContents* contents,
157 const std::string& extension_id) const;
158
159 UserScript script_;
160 DeclarativeUserScriptMaster* master_;
161
162 DISALLOW_COPY_AND_ASSIGN(RequestContentScript);
163 };
164
78 typedef DeclarativeActionSet<ContentAction> ContentActionSet; 165 typedef DeclarativeActionSet<ContentAction> ContentActionSet;
79 166
80 } // namespace extensions 167 } // namespace extensions
81 168
82 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ 169 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_
OLDNEW
« 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