| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_ | 5 #ifndef EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_ |
| 6 #define EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_ | 6 #define EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 13 #include "base/strings/string_piece.h" | |
| 14 #include "extensions/renderer/module_system.h" | 13 #include "extensions/renderer/module_system.h" |
| 15 #include "extensions/renderer/static_v8_external_one_byte_string_resource.h" | |
| 16 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
| 17 | 15 |
| 18 namespace ui { | 16 namespace ui { |
| 19 class ResourceBundle; | 17 class ResourceBundle; |
| 20 } | 18 } |
| 21 | 19 |
| 22 namespace extensions { | 20 namespace extensions { |
| 23 | 21 |
| 24 class ResourceBundleSourceMap : public extensions::ModuleSystem::SourceMap { | 22 class ResourceBundleSourceMap : public extensions::ModuleSystem::SourceMap { |
| 25 public: | 23 public: |
| 26 explicit ResourceBundleSourceMap(const ui::ResourceBundle* resource_bundle); | 24 explicit ResourceBundleSourceMap(const ui::ResourceBundle* resource_bundle); |
| 27 ~ResourceBundleSourceMap() override; | 25 ~ResourceBundleSourceMap() override; |
| 28 | 26 |
| 29 v8::Local<v8::Value> GetSource(v8::Isolate* isolate, | 27 v8::Local<v8::Value> GetSource(v8::Isolate* isolate, |
| 30 const std::string& name) override; | 28 const std::string& name) const override; |
| 31 bool Contains(const std::string& name) override; | 29 bool Contains(const std::string& name) const override; |
| 32 | 30 |
| 33 void RegisterSource(const std::string& name, int resource_id); | 31 void RegisterSource(const std::string& name, int resource_id); |
| 34 | 32 |
| 35 private: | 33 private: |
| 36 v8::Local<v8::String> ConvertString(v8::Isolate* isolate, | |
| 37 const base::StringPiece& string); | |
| 38 | |
| 39 const ui::ResourceBundle* resource_bundle_; | 34 const ui::ResourceBundle* resource_bundle_; |
| 40 std::map<std::string, int> resource_id_map_; | 35 std::map<std::string, int> resource_id_map_; |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(ResourceBundleSourceMap); |
| 41 }; | 38 }; |
| 42 | 39 |
| 43 } // namespace extensions | 40 } // namespace extensions |
| 44 | 41 |
| 45 #endif // EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_ | 42 #endif // EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_ |
| OLD | NEW |