diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-31 21:41:08 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-31 21:41:08 +0000 |
commit | b29aa74b75d57e1dc78bb151f1b7b2153d13ae3f (patch) | |
tree | c06576af8874b736101b045e4e1d75cfed7ba897 /ppapi/cpp | |
parent | 314e594492cfd5c23225763cb46c5cd190b5551c (diff) | |
download | chromium_src-b29aa74b75d57e1dc78bb151f1b7b2153d13ae3f.zip chromium_src-b29aa74b75d57e1dc78bb151f1b7b2153d13ae3f.tar.gz chromium_src-b29aa74b75d57e1dc78bb151f1b7b2153d13ae3f.tar.bz2 |
Pepper/Flapper: First pass at context menu implementation.
This meets the needs of Flapper. We may want to generalize/restrict/modify the
API for inclusion into PPAPI, but hopefully this lays a foundation.
BUG=none
TEST=Flapper context menus work (with the right version of Flapper)
Review URL: http://codereview.chromium.org/6253017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r-- | ppapi/cpp/private/flash_menu.cc | 48 | ||||
-rw-r--r-- | ppapi/cpp/private/flash_menu.h | 36 |
2 files changed, 84 insertions, 0 deletions
diff --git a/ppapi/cpp/private/flash_menu.cc b/ppapi/cpp/private/flash_menu.cc new file mode 100644 index 0000000..8596fc9 --- /dev/null +++ b/ppapi/cpp/private/flash_menu.cc @@ -0,0 +1,48 @@ +// Copyright (c) 2011 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. + +// TODO(viettrungluu): See the comment in corresponding .h file. + +#include "ppapi/cpp/private/flash_menu.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/point.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_Flash_Menu>() { + return PPB_FLASH_MENU_INTERFACE; +} + +} // namespace + +namespace flash { + +Menu::Menu(const Instance& instance, const struct PP_Flash_Menu* menu_data) { + if (has_interface<PPB_Flash_Menu>()) { + PassRefFromConstructor(get_interface<PPB_Flash_Menu>()->Create( + instance.pp_instance(), menu_data)); + } +} + +int32_t Menu::Show(const Point& location, + int32_t* selected_id, + const CompletionCallback& cc) { + if (!has_interface<PPB_Flash_Menu>()) + return PP_ERROR_NOINTERFACE; + return get_interface<PPB_Flash_Menu>()->Show( + pp_resource(), + &location.pp_point(), + selected_id, + cc.pp_completion_callback()); +} + +} // namespace flash +} // namespace pp diff --git a/ppapi/cpp/private/flash_menu.h b/ppapi/cpp/private/flash_menu.h new file mode 100644 index 0000000..a5d4408 --- /dev/null +++ b/ppapi/cpp/private/flash_menu.h @@ -0,0 +1,36 @@ +// Copyright (c) 2011 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. + +// TODO(viettrungluu): This (and the .cc file) contain C++ wrappers for some +// things in ppapi/c/private/ppb_flash_menu.h. This is currently not used in (or +// even compiled with) Chromium. + +#ifndef PPAPI_CPP_PRIVATE_FLASH_MENU_H_ +#define PPAPI_CPP_PRIVATE_FLASH_MENU_H_ + +#include "ppapi/c/private/ppb_flash_menu.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class CompletionCallback; +class Instance; +class Point; + +namespace flash { + +class Menu : public Resource { + public: + // TODO(viettrungluu): Write a proper C++ wrapper of |PP_Flash_Menu|. + Menu(const Instance& instance, const struct PP_Flash_Menu* menu_data); + + int32_t Show(const Point& location, + int32_t* selected_id, + const CompletionCallback& cc); +}; + +} // namespace flash +} // namespace pp + +#endif // PPAPI_CPP_PRIVATE_FLASH_H_ |