Roll src/third_party/WebKit 9301d6f:4619053 (svn 201058:201059)
[chromium-blink-merge.git] / extensions / renderer / resource_bundle_source_map.h
blob13f8f216697cc4bfc1f619cdcfdfcf67432a072d
1 // Copyright 2014 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.
5 #ifndef EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_
6 #define EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_
8 #include <map>
9 #include <string>
11 #include "base/compiler_specific.h"
12 #include "base/memory/linked_ptr.h"
13 #include "base/strings/string_piece.h"
14 #include "extensions/renderer/module_system.h"
15 #include "extensions/renderer/static_v8_external_one_byte_string_resource.h"
16 #include "v8/include/v8.h"
18 namespace ui {
19 class ResourceBundle;
22 namespace extensions {
24 class ResourceBundleSourceMap : public extensions::ModuleSystem::SourceMap {
25 public:
26 explicit ResourceBundleSourceMap(const ui::ResourceBundle* resource_bundle);
27 ~ResourceBundleSourceMap() override;
29 v8::Local<v8::Value> GetSource(v8::Isolate* isolate,
30 const std::string& name) override;
31 bool Contains(const std::string& name) override;
33 void RegisterSource(const std::string& name, int resource_id);
35 private:
36 v8::Local<v8::String> ConvertString(v8::Isolate* isolate,
37 const base::StringPiece& string);
39 const ui::ResourceBundle* resource_bundle_;
40 std::map<std::string, int> resource_id_map_;
43 } // namespace extensions
45 #endif // EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_