summaryrefslogtreecommitdiffstats
path: root/content/renderer/pepper/resource_helper.cc
blob: 8a4e9dde1693c892b7af58b4538b62b3211a8751 (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
// 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 "content/renderer/pepper/resource_helper.h"

#include "base/logging.h"
#include "content/renderer/pepper/host_globals.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/plugin_module.h"
#include "ppapi/shared_impl/resource.h"

namespace content {

// static
PepperPluginInstanceImpl* ResourceHelper::GetPluginInstance(
    const ::ppapi::Resource* resource) {
  return PPInstanceToPluginInstance(resource->pp_instance());
}

PepperPluginInstanceImpl* ResourceHelper::PPInstanceToPluginInstance(
    PP_Instance instance) {
  return HostGlobals::Get()->GetInstance(instance);
}

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

PepperHelperImpl* ResourceHelper::GetHelper(const ::ppapi::Resource* resource) {
  PepperPluginInstanceImpl* instance = GetPluginInstance(resource);
  return instance ? instance->helper() : NULL;
}

}  // namespace content