OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 class TestManifestHandler : public ManifestHandler { | 77 class TestManifestHandler : public ManifestHandler { |
78 public: | 78 public: |
79 TestManifestHandler(const std::string& name, | 79 TestManifestHandler(const std::string& name, |
80 const std::vector<std::string>& keys, | 80 const std::vector<std::string>& keys, |
81 const std::vector<std::string>& prereqs, | 81 const std::vector<std::string>& prereqs, |
82 ParsingWatcher* watcher) | 82 ParsingWatcher* watcher) |
83 : name_(name), keys_(keys), prereqs_(prereqs), watcher_(watcher) { | 83 : name_(name), keys_(keys), prereqs_(prereqs), watcher_(watcher) { |
84 } | 84 } |
85 | 85 |
86 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE { | 86 virtual bool Parse(Extension* extension, base::string16* error) override { |
87 watcher_->Record(name_); | 87 watcher_->Record(name_); |
88 return true; | 88 return true; |
89 } | 89 } |
90 | 90 |
91 virtual const std::vector<std::string> PrerequisiteKeys() const OVERRIDE { | 91 virtual const std::vector<std::string> PrerequisiteKeys() const override { |
92 return prereqs_; | 92 return prereqs_; |
93 } | 93 } |
94 | 94 |
95 protected: | 95 protected: |
96 std::string name_; | 96 std::string name_; |
97 std::vector<std::string> keys_; | 97 std::vector<std::string> keys_; |
98 std::vector<std::string> prereqs_; | 98 std::vector<std::string> prereqs_; |
99 ParsingWatcher* watcher_; | 99 ParsingWatcher* watcher_; |
100 | 100 |
101 virtual const std::vector<std::string> Keys() const OVERRIDE { | 101 virtual const std::vector<std::string> Keys() const override { |
102 return keys_; | 102 return keys_; |
103 } | 103 } |
104 }; | 104 }; |
105 | 105 |
106 class FailingTestManifestHandler : public TestManifestHandler { | 106 class FailingTestManifestHandler : public TestManifestHandler { |
107 public: | 107 public: |
108 FailingTestManifestHandler(const std::string& name, | 108 FailingTestManifestHandler(const std::string& name, |
109 const std::vector<std::string>& keys, | 109 const std::vector<std::string>& keys, |
110 const std::vector<std::string>& prereqs, | 110 const std::vector<std::string>& prereqs, |
111 ParsingWatcher* watcher) | 111 ParsingWatcher* watcher) |
112 : TestManifestHandler(name, keys, prereqs, watcher) { | 112 : TestManifestHandler(name, keys, prereqs, watcher) { |
113 } | 113 } |
114 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE { | 114 virtual bool Parse(Extension* extension, base::string16* error) override { |
115 *error = base::ASCIIToUTF16(name_); | 115 *error = base::ASCIIToUTF16(name_); |
116 return false; | 116 return false; |
117 } | 117 } |
118 }; | 118 }; |
119 | 119 |
120 class AlwaysParseTestManifestHandler : public TestManifestHandler { | 120 class AlwaysParseTestManifestHandler : public TestManifestHandler { |
121 public: | 121 public: |
122 AlwaysParseTestManifestHandler(const std::string& name, | 122 AlwaysParseTestManifestHandler(const std::string& name, |
123 const std::vector<std::string>& keys, | 123 const std::vector<std::string>& keys, |
124 const std::vector<std::string>& prereqs, | 124 const std::vector<std::string>& prereqs, |
125 ParsingWatcher* watcher) | 125 ParsingWatcher* watcher) |
126 : TestManifestHandler(name, keys, prereqs, watcher) { | 126 : TestManifestHandler(name, keys, prereqs, watcher) { |
127 } | 127 } |
128 | 128 |
129 virtual bool AlwaysParseForType(Manifest::Type type) const OVERRIDE { | 129 virtual bool AlwaysParseForType(Manifest::Type type) const override { |
130 return true; | 130 return true; |
131 } | 131 } |
132 }; | 132 }; |
133 | 133 |
134 class TestManifestValidator : public ManifestHandler { | 134 class TestManifestValidator : public ManifestHandler { |
135 public: | 135 public: |
136 TestManifestValidator(bool return_value, | 136 TestManifestValidator(bool return_value, |
137 bool always_validate, | 137 bool always_validate, |
138 std::vector<std::string> keys) | 138 std::vector<std::string> keys) |
139 : return_value_(return_value), | 139 : return_value_(return_value), |
140 always_validate_(always_validate), | 140 always_validate_(always_validate), |
141 keys_(keys) { | 141 keys_(keys) { |
142 } | 142 } |
143 | 143 |
144 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE { | 144 virtual bool Parse(Extension* extension, base::string16* error) override { |
145 return true; | 145 return true; |
146 } | 146 } |
147 | 147 |
148 virtual bool Validate( | 148 virtual bool Validate( |
149 const Extension* extension, | 149 const Extension* extension, |
150 std::string* error, | 150 std::string* error, |
151 std::vector<InstallWarning>* warnings) const OVERRIDE { | 151 std::vector<InstallWarning>* warnings) const override { |
152 return return_value_; | 152 return return_value_; |
153 } | 153 } |
154 | 154 |
155 virtual bool AlwaysValidateForType(Manifest::Type type) const OVERRIDE { | 155 virtual bool AlwaysValidateForType(Manifest::Type type) const override { |
156 return always_validate_; | 156 return always_validate_; |
157 } | 157 } |
158 | 158 |
159 private: | 159 private: |
160 virtual const std::vector<std::string> Keys() const OVERRIDE { | 160 virtual const std::vector<std::string> Keys() const override { |
161 return keys_; | 161 return keys_; |
162 } | 162 } |
163 | 163 |
164 protected: | 164 protected: |
165 bool return_value_; | 165 bool return_value_; |
166 bool always_validate_; | 166 bool always_validate_; |
167 std::vector<std::string> keys_; | 167 std::vector<std::string> keys_; |
168 }; | 168 }; |
169 }; | 169 }; |
170 | 170 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 EXPECT_TRUE( | 272 EXPECT_TRUE( |
273 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings)); | 273 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings)); |
274 | 274 |
275 // Validates "a" and fails. | 275 // Validates "a" and fails. |
276 (new TestManifestValidator(false, true, SingleKey("a")))->Register(); | 276 (new TestManifestValidator(false, true, SingleKey("a")))->Register(); |
277 EXPECT_FALSE( | 277 EXPECT_FALSE( |
278 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings)); | 278 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings)); |
279 } | 279 } |
280 | 280 |
281 } // namespace extensions | 281 } // namespace extensions |
OLD | NEW |