blob: b77b32fe11baea8962c9a4b734b20a2514c29758 [file] [log] [blame]
[email protected]ecde1912012-03-16 06:25:311// Copyright (c) 2012 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 CHROME_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_
6#define CHROME_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_
[email protected]ecde1912012-03-16 06:25:317
8#include "base/compiler_specific.h"
9#include "base/memory/linked_ptr.h"
10#include "base/string_piece.h"
[email protected]3c6babd2012-08-28 03:17:2911#include "chrome/renderer/extensions/module_system.h"
[email protected]ecde1912012-03-16 06:25:3112#include "chrome/renderer/static_v8_external_string_resource.h"
13#include "v8/include/v8.h"
14
15#include <map>
16#include <string>
17
18namespace ui {
19 class ResourceBundle;
20}
21
[email protected]3c6babd2012-08-28 03:17:2922class ResourceBundleSourceMap : public extensions::ModuleSystem::SourceMap {
[email protected]ecde1912012-03-16 06:25:3123 public:
24 explicit ResourceBundleSourceMap(const ui::ResourceBundle* resource_bundle);
25 ~ResourceBundleSourceMap();
26
27 virtual v8::Handle<v8::Value> GetSource(const std::string& name) OVERRIDE;
28 virtual bool Contains(const std::string& name) OVERRIDE;
29
30 void RegisterSource(const std::string& name, int resource_id);
31
32 private:
33 v8::Handle<v8::String> ConvertString(const base::StringPiece& string);
34
35 const ui::ResourceBundle* resource_bundle_;
36 std::map<std::string, int> resource_id_map_;
37};
38
39#endif // CHROME_RENDERER_RESOURCE_BUNDLE_SOURCE_MAP_H_