OLD | NEW |
(Empty) | |
| 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 #include "extensions/renderer/string_source_map.h" |
| 6 |
| 7 #include "gin/converter.h" |
| 8 |
| 9 namespace extensions { |
| 10 |
| 11 StringSourceMap::StringSourceMap() {} |
| 12 StringSourceMap::~StringSourceMap() {} |
| 13 |
| 14 v8::Local<v8::String> StringSourceMap::GetSource( |
| 15 v8::Isolate* isolate, |
| 16 const std::string& name) const { |
| 17 const auto& iter = sources_.find(name); |
| 18 if (iter == sources_.end()) |
| 19 return v8::Local<v8::String>(); |
| 20 return gin::StringToV8(isolate, iter->second); |
| 21 } |
| 22 |
| 23 bool StringSourceMap::Contains(const std::string& name) const { |
| 24 return sources_.find(name) != sources_.end(); |
| 25 } |
| 26 |
| 27 void StringSourceMap::RegisterModule(const std::string& name, |
| 28 const std::string& source) { |
| 29 CHECK_EQ(0u, sources_.count(name)) << "A module for '" << name |
| 30 << "' already exists."; |
| 31 sources_[name] = source; |
| 32 } |
| 33 |
| 34 } // namespace extensions |
OLD | NEW |