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 using RequestKey = std::string; | |
| 100 | |
| 98 RequestContentScript(content::BrowserContext* browser_context, | 101 RequestContentScript(content::BrowserContext* browser_context, |
| 99 const Extension* extension, | 102 const Extension* extension, |
| 100 const ScriptData& script_data); | 103 const ScriptData& script_data); |
| 101 RequestContentScript(DeclarativeUserScriptMaster* master, | 104 RequestContentScript(DeclarativeUserScriptMaster* master, |
| 102 const Extension* extension, | 105 const Extension* extension, |
| 103 const ScriptData& script_data); | 106 const ScriptData& script_data); |
| 104 | 107 |
| 105 static scoped_refptr<ContentAction> Create( | 108 static scoped_refptr<ContentAction> Create( |
| 106 content::BrowserContext* browser_context, | 109 content::BrowserContext* browser_context, |
| 107 const Extension* extension, | 110 const Extension* extension, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 DCHECK(master_); | 146 DCHECK(master_); |
| 144 master_->AddScript(script_); | 147 master_->AddScript(script_); |
| 145 } | 148 } |
| 146 | 149 |
| 147 ~RequestContentScript() override; | 150 ~RequestContentScript() override; |
| 148 | 151 |
| 149 void InstructRenderProcessToInject(content::WebContents* contents, | 152 void InstructRenderProcessToInject(content::WebContents* contents, |
| 150 const std::string& extension_id) const; | 153 const std::string& extension_id) const; |
| 151 | 154 |
| 152 UserScript script_; | 155 UserScript script_; |
| 156 | |
| 157 // The lifetime of the |master_| is managed by DeclarativeUserScriptManager, | |
|
Devlin
2015/01/21 23:25:20
How about instead
"Since the lifetime of Declarati
Xi Han
2015/01/22 17:19:36
Sounds better, thanks!
| |
| 158 // which manages a map of master objects. | |
| 159 // DeclarativeUserScriptManager is owned by ExtensionSystemImpl::Shared, and a | |
| 160 // master object will only be desctructed when the | |
| 161 // DeclarativeUserScriptManager is desctructed. | |
| 162 // So it is safe to use a raw pointer here. | |
| 153 DeclarativeUserScriptMaster* master_; | 163 DeclarativeUserScriptMaster* master_; |
| 154 | 164 |
| 155 DISALLOW_COPY_AND_ASSIGN(RequestContentScript); | 165 DISALLOW_COPY_AND_ASSIGN(RequestContentScript); |
| 156 }; | 166 }; |
| 157 | 167 |
| 158 typedef DeclarativeActionSet<ContentAction> ContentActionSet; | 168 typedef DeclarativeActionSet<ContentAction> ContentActionSet; |
| 159 | 169 |
| 160 } // namespace extensions | 170 } // namespace extensions |
| 161 | 171 |
| 162 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ | 172 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ |
| OLD | NEW |