summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/extensions/bindings_utils.h
blob: 84fb32f54874b8723a2b72cbb489916df4f4020b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_
#define CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_

#include "base/singleton.h"
#include "chrome/common/resource_bundle.h"

#include <string>

class RenderView;

template<int kResourceId>
struct StringResourceTemplate {
  StringResourceTemplate()
      : resource(ResourceBundle::GetSharedInstance().GetRawDataResource(
            kResourceId).as_string()) {
  }
  std::string resource;
};

template<int kResourceId>
const char* GetStringResource() {
  return
      Singleton< StringResourceTemplate<kResourceId> >::get()->resource.c_str();
}

// Returns the active RenderView, based on which V8 context is active.  It is
// an error to call this when not in a V8 context.
RenderView* GetActiveRenderView();

#endif  // CHROME_RENDERER_EXTENSIONS_BINDINGS_UTILS_H_