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.
4
5#include "mojo/examples/pepper_container_app/interface_list.h"
6
7#include "base/memory/singleton.h"
8#include "mojo/examples/pepper_container_app/thunk.h"
9#include "ppapi/c/ppb_core.h"
10#include "ppapi/c/ppb_graphics_3d.h"
11#include "ppapi/c/ppb_instance.h"
12#include "ppapi/c/ppb_opengles2.h"
13#include "ppapi/c/ppb_view.h"
14#include "ppapi/thunk/thunk.h"
15
16namespace mojo {
17namespace examples {
18
19InterfaceList::InterfaceList() {
20  browser_interfaces_[PPB_CORE_INTERFACE_1_0] = GetPPB_Core_1_0_Thunk();
21  browser_interfaces_[PPB_GRAPHICS_3D_INTERFACE_1_0] =
22      ppapi::thunk::GetPPB_Graphics3D_1_0_Thunk();
23  browser_interfaces_[PPB_OPENGLES2_INTERFACE_1_0] =
24      GetPPB_OpenGLES2_Thunk();
25  browser_interfaces_[PPB_INSTANCE_INTERFACE_1_0] =
26      ppapi::thunk::GetPPB_Instance_1_0_Thunk();
27  browser_interfaces_[PPB_VIEW_INTERFACE_1_0] =
28      ppapi::thunk::GetPPB_View_1_0_Thunk();
29  browser_interfaces_[PPB_VIEW_INTERFACE_1_1] =
30      ppapi::thunk::GetPPB_View_1_1_Thunk();
31}
32
33InterfaceList::~InterfaceList() {}
34
35// static
36InterfaceList* InterfaceList::GetInstance() {
37  return Singleton<InterfaceList>::get();
38}
39
40const void* InterfaceList::GetBrowserInterface(const std::string& name) const {
41  NameToInterfaceMap::const_iterator iter = browser_interfaces_.find(name);
42
43  if (iter == browser_interfaces_.end())
44    return NULL;
45
46  return iter->second;
47}
48
49}  // namespace examples
50}  // namespace mojo
51