Add/resurrect support for bundles of WebStore items.
[chromium-blink-merge.git] / ppapi / cpp / dev / selection_dev.cc
blob7e1284bb66fba179eb253ed62bf5f70676173fc9
1 // Copyright (c) 2010 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.
5 #include "ppapi/cpp/dev/selection_dev.h"
7 #include "ppapi/cpp/instance.h"
8 #include "ppapi/cpp/instance_handle.h"
9 #include "ppapi/cpp/module.h"
10 #include "ppapi/cpp/var.h"
12 namespace pp {
14 namespace {
16 static const char kPPPSelectionInterface[] = PPP_SELECTION_DEV_INTERFACE;
18 PP_Var GetSelectedText(PP_Instance instance, PP_Bool html) {
19 void* object =
20 pp::Instance::GetPerInstanceObject(instance, kPPPSelectionInterface);
21 if (!object)
22 return Var().Detach();
23 return static_cast<Selection_Dev*>(object)->
24 GetSelectedText(PP_ToBool(html)).Detach();
27 const PPP_Selection_Dev ppp_selection = {
28 &GetSelectedText
31 } // namespace
33 Selection_Dev::Selection_Dev(Instance* instance)
34 : associated_instance_(instance) {
35 Module::Get()->AddPluginInterface(kPPPSelectionInterface, &ppp_selection);
36 instance->AddPerInstanceObject(kPPPSelectionInterface, this);
39 Selection_Dev::~Selection_Dev() {
40 Instance::RemovePerInstanceObject(associated_instance_,
41 kPPPSelectionInterface, this);
44 } // namespace pp