rdevlin.cronin | 892cc67 | 2016-12-19 20:00:18 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef EXTENSIONS_RENDERER_STRING_SOURCE_MAP_H_ |
| 6 | #define EXTENSIONS_RENDERER_STRING_SOURCE_MAP_H_ |
| 7 | |
| 8 | #include <map> |
| 9 | #include <string> |
| 10 | |
| 11 | #include "base/macros.h" |
| 12 | #include "extensions/renderer/source_map.h" |
| 13 | |
| 14 | namespace extensions { |
| 15 | |
| 16 | // A testing implementation of the source map that takes strings for source |
| 17 | // contents. |
| 18 | class StringSourceMap : public SourceMap { |
| 19 | public: |
| 20 | StringSourceMap(); |
| 21 | ~StringSourceMap() override; |
| 22 | |
| 23 | // Adds a new string to be used in the source map. |
Yuzhu Shen | bcd734d | 2017-11-15 20:40:58 | [diff] [blame] | 24 | void RegisterModule(const std::string& name, |
| 25 | const std::string& source, |
| 26 | bool gzipped = false); |
rdevlin.cronin | 892cc67 | 2016-12-19 20:00:18 | [diff] [blame] | 27 | |
| 28 | // SourceMap: |
| 29 | v8::Local<v8::String> GetSource(v8::Isolate* isolate, |
| 30 | const std::string& name) const override; |
| 31 | bool Contains(const std::string& name) const override; |
| 32 | |
| 33 | private: |
| 34 | std::map<std::string, std::string> sources_; |
| 35 | |
| 36 | DISALLOW_COPY_AND_ASSIGN(StringSourceMap); |
| 37 | }; |
| 38 | |
| 39 | } // namespace extensions |
| 40 | |
| 41 | #endif // EXTENSIONS_RENDERER_STRING_SOURCE_MAP_H_ |