Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1099)

Unified Diff: ppapi/cpp/private/flash_clipboard.cc

Issue 9207012: Pepper/Flapper: Add C++ wrappers for PPB_Flash_Clipboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pp::flash::FlashClipboard -> pp::flash::Clipboard Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/cpp/private/flash_clipboard.h ('k') | ppapi/ppapi_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/private/flash_clipboard.cc
diff --git a/ppapi/cpp/private/flash_clipboard.cc b/ppapi/cpp/private/flash_clipboard.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8634eafc8adde463a9fa2be7609ab2a8dfca857d
--- /dev/null
+++ b/ppapi/cpp/private/flash_clipboard.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2012 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 "ppapi/cpp/private/flash_clipboard.h"
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/module_impl.h"
+#include "ppapi/cpp/var.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_Flash_Clipboard>() {
+ return PPB_FLASH_CLIPBOARD_INTERFACE;
+}
+
+} // namespace
+
+namespace flash {
+
+// static
+bool Clipboard::IsAvailable() {
+ return has_interface<PPB_Flash_Clipboard>();
+}
+
+// static
+bool Clipboard::IsFormatAvailable(Instance* instance,
+ PP_Flash_Clipboard_Type clipboard_type,
+ PP_Flash_Clipboard_Format format) {
+ bool rv = false;
+ if (has_interface<PPB_Flash_Clipboard>()) {
+ rv = PP_ToBool(get_interface<PPB_Flash_Clipboard>()->IsFormatAvailable(
+ instance->pp_instance(), clipboard_type, format));
+ }
+ return rv;
+}
+
+// static
+bool Clipboard::ReadPlainText(Instance* instance,
+ PP_Flash_Clipboard_Type clipboard_type,
+ std::string* text_out) {
+ bool rv = false;
+ if (has_interface<PPB_Flash_Clipboard>()) {
+ Var v(Var::PassRef(),
+ get_interface<PPB_Flash_Clipboard>()->ReadPlainText(
+ instance->pp_instance(),
+ clipboard_type));
+ if (v.is_string()) {
+ rv = true;
+ *text_out = v.AsString();
+ }
+ }
+ return rv;
+}
+
+// static
+bool Clipboard::WritePlainText(Instance* instance,
+ PP_Flash_Clipboard_Type clipboard_type,
+ const std::string& text) {
+ bool rv = false;
+ if (has_interface<PPB_Flash_Clipboard>()) {
+ rv = (get_interface<PPB_Flash_Clipboard>()->WritePlainText(
+ instance->pp_instance(),
+ clipboard_type,
+ Var(text).pp_var()) == PP_OK);
+ }
+ return rv;
+}
+
+} // namespace flash
+} // namespace pp
« no previous file with comments | « ppapi/cpp/private/flash_clipboard.h ('k') | ppapi/ppapi_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698