summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi/resource_helper.cc
blob: fd0321af6b17c9974037c4b36e8de8eab833b3de (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
35
36
37
38
39
// Copyright (c) 2010 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.

#include "webkit/plugins/ppapi/resource_helper.h"

#include "base/logging.h"
#include "ppapi/shared_impl/resource.h"
#include "webkit/plugins/ppapi/host_globals.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/host_resource_tracker.h"

namespace webkit {
namespace ppapi {

// static
PluginInstance* ResourceHelper::GetPluginInstance(
    const ::ppapi::Resource* resource) {
  return HostGlobals::Get()->host_resource_tracker()->GetInstance(
      resource->pp_instance());
}

PluginModule* ResourceHelper::GetPluginModule(
    const ::ppapi::Resource* resource) {
  PluginInstance* instance = GetPluginInstance(resource);
  return instance ? instance->module() : NULL;
}

PluginDelegate* ResourceHelper::GetPluginDelegate(
    const ::ppapi::Resource* resource) {
  PluginInstance* instance = GetPluginInstance(resource);
  return instance ? instance->delegate() : NULL;
}

}  // namespace ppapi
}  // namespace webkit