Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 { | |
|
Devlin
2015/01/20 17:51:05
Could we instead just use a std::string for this?
Xi Han
2015/01/21 21:30:16
Ok, I will change it to std::string, and change it
| |
| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 DCHECK(master_); | 152 DCHECK(master_); |
| 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_; |
| 162 // The lifetime of the master_ is managed by DeclarativeUserScriptManager, | |
|
Devlin
2015/01/20 17:51:05
nit: newline before this.
nit: Document why the li
Xi Han
2015/01/21 21:30:16
Lifetime is hard to explain, so I try my best to a
| |
| 163 // which manages a map of master objects. | |
| 153 DeclarativeUserScriptMaster* master_; | 164 DeclarativeUserScriptMaster* master_; |
| 154 | 165 |
| 155 DISALLOW_COPY_AND_ASSIGN(RequestContentScript); | 166 DISALLOW_COPY_AND_ASSIGN(RequestContentScript); |
| 156 }; | 167 }; |
| 157 | 168 |
| 158 typedef DeclarativeActionSet<ContentAction> ContentActionSet; | 169 typedef DeclarativeActionSet<ContentAction> ContentActionSet; |
| 159 | 170 |
| 160 } // namespace extensions | 171 } // namespace extensions |
| 161 | 172 |
| 162 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ | 173 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ |
| OLD | NEW |