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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/private/flash_clipboard.h ('k') | ppapi/ppapi_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #include "ppapi/cpp/private/flash_clipboard.h"
6
7 #include "ppapi/c/pp_bool.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/cpp/instance.h"
10 #include "ppapi/cpp/module_impl.h"
11 #include "ppapi/cpp/var.h"
12
13 namespace pp {
14
15 namespace {
16
17 template <> const char* interface_name<PPB_Flash_Clipboard>() {
18 return PPB_FLASH_CLIPBOARD_INTERFACE;
19 }
20
21 } // namespace
22
23 namespace flash {
24
25 // static
26 bool Clipboard::IsAvailable() {
27 return has_interface<PPB_Flash_Clipboard>();
28 }
29
30 // static
31 bool Clipboard::IsFormatAvailable(Instance* instance,
32 PP_Flash_Clipboard_Type clipboard_type,
33 PP_Flash_Clipboard_Format format) {
34 bool rv = false;
35 if (has_interface<PPB_Flash_Clipboard>()) {
36 rv = PP_ToBool(get_interface<PPB_Flash_Clipboard>()->IsFormatAvailable(
37 instance->pp_instance(), clipboard_type, format));
38 }
39 return rv;
40 }
41
42 // static
43 bool Clipboard::ReadPlainText(Instance* instance,
44 PP_Flash_Clipboard_Type clipboard_type,
45 std::string* text_out) {
46 bool rv = false;
47 if (has_interface<PPB_Flash_Clipboard>()) {
48 Var v(Var::PassRef(),
49 get_interface<PPB_Flash_Clipboard>()->ReadPlainText(
50 instance->pp_instance(),
51 clipboard_type));
52 if (v.is_string()) {
53 rv = true;
54 *text_out = v.AsString();
55 }
56 }
57 return rv;
58 }
59
60 // static
61 bool Clipboard::WritePlainText(Instance* instance,
62 PP_Flash_Clipboard_Type clipboard_type,
63 const std::string& text) {
64 bool rv = false;
65 if (has_interface<PPB_Flash_Clipboard>()) {
66 rv = (get_interface<PPB_Flash_Clipboard>()->WritePlainText(
67 instance->pp_instance(),
68 clipboard_type,
69 Var(text).pp_var()) == PP_OK);
70 }
71 return rv;
72 }
73
74 } // namespace flash
75 } // namespace pp
OLDNEW
« 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