blob: f502a8922ea1ef0fc785f41579f605782be69b0e [file] [log] [blame]
rdevlin.cronin892cc672016-12-19 20:00:181// 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
14namespace extensions {
15
16// A testing implementation of the source map that takes strings for source
17// contents.
18class StringSourceMap : public SourceMap {
19 public:
20 StringSourceMap();
21 ~StringSourceMap() override;
22
23 // Adds a new string to be used in the source map.
Yuzhu Shenbcd734d2017-11-15 20:40:5824 void RegisterModule(const std::string& name,
25 const std::string& source,
26 bool gzipped = false);
rdevlin.cronin892cc672016-12-19 20:00:1827
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_