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 <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "extensions/browser/declarative_user_script_master.h" | 12 #include "extensions/browser/declarative_user_script_master.h" |
13 #include "extensions/common/user_script.h" | 13 #include "extensions/common/user_script.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class Value; | 16 class Value; |
17 class DictionaryValue; | 17 class DictionaryValue; |
18 } | 18 } |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 class BrowserContext; | 21 class BrowserContext; |
(...skipping 25 matching lines...) Expand all Loading... |
47 // changes. Reapply exists to reapply changes to a new page, even if the | 47 // changes. Reapply exists to reapply changes to a new page, even if the |
48 // previous page also matched relevant conditions. | 48 // previous page also matched relevant conditions. |
49 virtual void Apply(const ApplyInfo& apply_info) const = 0; | 49 virtual void Apply(const ApplyInfo& apply_info) const = 0; |
50 virtual void Reapply(const ApplyInfo& apply_info) const = 0; | 50 virtual void Reapply(const ApplyInfo& apply_info) const = 0; |
51 virtual void Revert(const ApplyInfo& apply_info) const = 0; | 51 virtual void Revert(const ApplyInfo& apply_info) const = 0; |
52 | 52 |
53 // Factory method that instantiates a concrete ContentAction implementation | 53 // Factory method that instantiates a concrete ContentAction implementation |
54 // according to |json_action|, the representation of the ContentAction as | 54 // according to |json_action|, the representation of the ContentAction as |
55 // received from the extension API. Sets |error| and returns NULL in case of | 55 // received from the extension API. Sets |error| and returns NULL in case of |
56 // an error. | 56 // an error. |
57 static scoped_ptr<ContentAction> Create( | 57 static std::unique_ptr<ContentAction> Create( |
58 content::BrowserContext* browser_context, | 58 content::BrowserContext* browser_context, |
59 const Extension* extension, | 59 const Extension* extension, |
60 const base::Value& json_action, | 60 const base::Value& json_action, |
61 std::string* error); | 61 std::string* error); |
62 | 62 |
63 protected: | 63 protected: |
64 ContentAction(); | 64 ContentAction(); |
65 }; | 65 }; |
66 | 66 |
67 // Action that injects a content script. | 67 // Action that injects a content script. |
68 class RequestContentScript : public ContentAction { | 68 class RequestContentScript : public ContentAction { |
69 public: | 69 public: |
70 struct ScriptData; | 70 struct ScriptData; |
71 | 71 |
72 RequestContentScript(content::BrowserContext* browser_context, | 72 RequestContentScript(content::BrowserContext* browser_context, |
73 const Extension* extension, | 73 const Extension* extension, |
74 const ScriptData& script_data); | 74 const ScriptData& script_data); |
75 RequestContentScript(DeclarativeUserScriptMaster* master, | 75 RequestContentScript(DeclarativeUserScriptMaster* master, |
76 const Extension* extension, | 76 const Extension* extension, |
77 const ScriptData& script_data); | 77 const ScriptData& script_data); |
78 | 78 |
79 ~RequestContentScript() override; | 79 ~RequestContentScript() override; |
80 | 80 |
81 static scoped_ptr<ContentAction> Create( | 81 static std::unique_ptr<ContentAction> Create( |
82 content::BrowserContext* browser_context, | 82 content::BrowserContext* browser_context, |
83 const Extension* extension, | 83 const Extension* extension, |
84 const base::DictionaryValue* dict, | 84 const base::DictionaryValue* dict, |
85 std::string* error); | 85 std::string* error); |
86 | 86 |
87 static scoped_ptr<ContentAction> CreateForTest( | 87 static std::unique_ptr<ContentAction> CreateForTest( |
88 DeclarativeUserScriptMaster* master, | 88 DeclarativeUserScriptMaster* master, |
89 const Extension* extension, | 89 const Extension* extension, |
90 const base::Value& json_action, | 90 const base::Value& json_action, |
91 std::string* error); | 91 std::string* error); |
92 | 92 |
93 static bool InitScriptData(const base::DictionaryValue* dict, | 93 static bool InitScriptData(const base::DictionaryValue* dict, |
94 std::string* error, | 94 std::string* error, |
95 ScriptData* script_data); | 95 ScriptData* script_data); |
96 | 96 |
97 // Implementation of ContentAction: | 97 // Implementation of ContentAction: |
(...skipping 16 matching lines...) Expand all Loading... |
114 | 114 |
115 UserScript script_; | 115 UserScript script_; |
116 DeclarativeUserScriptMaster* master_; | 116 DeclarativeUserScriptMaster* master_; |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(RequestContentScript); | 118 DISALLOW_COPY_AND_ASSIGN(RequestContentScript); |
119 }; | 119 }; |
120 | 120 |
121 } // namespace extensions | 121 } // namespace extensions |
122 | 122 |
123 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ | 123 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ |
OLD | NEW |