[email protected] | e689367 | 2014-05-01 17:29:13 | [diff] [blame^] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | ecde191 | 2012-03-16 06:25:31 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | e689367 | 2014-05-01 17:29:13 | [diff] [blame^] | 5 | #ifndef EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_ |
6 | #define EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_ | ||||
[email protected] | ecde191 | 2012-03-16 06:25:31 | [diff] [blame] | 7 | |
8 | #include <map> | ||||
9 | #include <string> | ||||
10 | |||||
[email protected] | e689367 | 2014-05-01 17:29:13 | [diff] [blame^] | 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_ascii_string_resource.h" | ||||
16 | #include "v8/include/v8.h" | ||||
17 | |||||
[email protected] | ecde191 | 2012-03-16 06:25:31 | [diff] [blame] | 18 | namespace ui { |
[email protected] | e689367 | 2014-05-01 17:29:13 | [diff] [blame^] | 19 | class ResourceBundle; |
[email protected] | ecde191 | 2012-03-16 06:25:31 | [diff] [blame] | 20 | } |
21 | |||||
[email protected] | e689367 | 2014-05-01 17:29:13 | [diff] [blame^] | 22 | namespace extensions { |
23 | |||||
[email protected] | 3c6babd | 2012-08-28 03:17:29 | [diff] [blame] | 24 | class ResourceBundleSourceMap : public extensions::ModuleSystem::SourceMap { |
[email protected] | ecde191 | 2012-03-16 06:25:31 | [diff] [blame] | 25 | public: |
26 | explicit ResourceBundleSourceMap(const ui::ResourceBundle* resource_bundle); | ||||
[email protected] | 14411494 | 2012-12-04 07:23:23 | [diff] [blame] | 27 | virtual ~ResourceBundleSourceMap(); |
[email protected] | ecde191 | 2012-03-16 06:25:31 | [diff] [blame] | 28 | |
[email protected] | 6f59d3b | 2013-12-02 12:50:50 | [diff] [blame] | 29 | virtual v8::Handle<v8::Value> GetSource(v8::Isolate* isolate, |
30 | const std::string& name) OVERRIDE; | ||||
[email protected] | ecde191 | 2012-03-16 06:25:31 | [diff] [blame] | 31 | virtual bool Contains(const std::string& name) OVERRIDE; |
32 | |||||
33 | void RegisterSource(const std::string& name, int resource_id); | ||||
34 | |||||
35 | private: | ||||
[email protected] | 6f59d3b | 2013-12-02 12:50:50 | [diff] [blame] | 36 | v8::Handle<v8::String> ConvertString(v8::Isolate* isolate, |
37 | const base::StringPiece& string); | ||||
[email protected] | ecde191 | 2012-03-16 06:25:31 | [diff] [blame] | 38 | |
39 | const ui::ResourceBundle* resource_bundle_; | ||||
40 | std::map<std::string, int> resource_id_map_; | ||||
41 | }; | ||||
42 | |||||
[email protected] | e689367 | 2014-05-01 17:29:13 | [diff] [blame^] | 43 | } // namespace extensions |
44 | |||||
45 | #endif // EXTENSIONS_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_ |