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

Side by Side Diff: chrome/browser/extensions/api/declarative_content/content_action.h

Issue 822453002: Introduce HostID and de-couple Extensions from "script injection System" [browser side] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the test failures. Created 5 years, 11 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
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
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 protected: 88 protected:
89 friend class base::RefCounted<ContentAction>; 89 friend class base::RefCounted<ContentAction>;
90 virtual ~ContentAction(); 90 virtual ~ContentAction();
91 }; 91 };
92 92
93 // Action that injects a content script. 93 // Action that injects a content script.
94 class RequestContentScript : public ContentAction { 94 class RequestContentScript : public ContentAction {
95 public: 95 public:
96 struct ScriptData; 96 struct ScriptData;
97 97
98 // TODO(hanxi): add RulesRegistryID to the RequestKey.
99 struct RequestKey {
100 explicit RequestKey(const std::string& host_id) : host_id(host_id) {}
101 bool operator<(const RequestKey& key) const {
102 return host_id.compare(key.host_id) < 0;
103 }
104 std::string host_id;
105 };
106
98 RequestContentScript(content::BrowserContext* browser_context, 107 RequestContentScript(content::BrowserContext* browser_context,
99 const Extension* extension, 108 const Extension* extension,
100 const ScriptData& script_data); 109 const ScriptData& script_data);
101 RequestContentScript(DeclarativeUserScriptMaster* master, 110 RequestContentScript(DeclarativeUserScriptMaster* master,
102 const Extension* extension, 111 const Extension* extension,
103 const ScriptData& script_data); 112 const ScriptData& script_data);
104 113
105 static scoped_refptr<ContentAction> Create( 114 static scoped_refptr<ContentAction> Create(
106 content::BrowserContext* browser_context, 115 content::BrowserContext* browser_context,
107 const Extension* extension, 116 const Extension* extension,
(...skipping 25 matching lines...) Expand all
133 ApplyInfo* apply_info) const override; 142 ApplyInfo* apply_info) const override;
134 143
135 void Revert(const std::string& extension_id, 144 void Revert(const std::string& extension_id,
136 const base::Time& extension_install_time, 145 const base::Time& extension_install_time,
137 ApplyInfo* apply_info) const override; 146 ApplyInfo* apply_info) const override;
138 147
139 private: 148 private:
140 void InitScript(const Extension* extension, const ScriptData& script_data); 149 void InitScript(const Extension* extension, const ScriptData& script_data);
141 150
142 void AddScript() { 151 void AddScript() {
143 DCHECK(master_); 152 DCHECK(master_.get());
144 master_->AddScript(script_); 153 master_->AddScript(script_);
145 } 154 }
146 155
147 ~RequestContentScript() override; 156 ~RequestContentScript() override;
148 157
149 void InstructRenderProcessToInject(content::WebContents* contents, 158 void InstructRenderProcessToInject(content::WebContents* contents,
150 const std::string& extension_id) const; 159 const std::string& extension_id) const;
151 160
152 UserScript script_; 161 UserScript script_;
153 DeclarativeUserScriptMaster* master_; 162 linked_ptr<DeclarativeUserScriptMaster> master_;
Devlin 2015/01/14 16:45:08 I don't think it's wise to make this a linked_ptr.
Xi Han 2015/01/14 23:46:02 linked_ptr was removed from here. Also I have to d
Devlin 2015/01/16 17:05:03 That's my bad - when I say "weak pointer", I mean
Xi Han 2015/01/19 22:40:05 Sounds good:)
154 163
155 DISALLOW_COPY_AND_ASSIGN(RequestContentScript); 164 DISALLOW_COPY_AND_ASSIGN(RequestContentScript);
156 }; 165 };
157 166
158 typedef DeclarativeActionSet<ContentAction> ContentActionSet; 167 typedef DeclarativeActionSet<ContentAction> ContentActionSet;
159 168
160 } // namespace extensions 169 } // namespace extensions
161 170
162 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ 171 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698