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

Side by Side Diff: ppapi/cpp/private/flash_clipboard.cc

Issue 9381010: Convert resources to take an instance key instead of an Instance*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/cpp/private/flash_clipboard.h" 5 #include "ppapi/cpp/private/flash_clipboard.h"
6 6
7 #include "ppapi/c/pp_bool.h" 7 #include "ppapi/c/pp_bool.h"
8 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/cpp/instance.h" 9 #include "ppapi/cpp/instance_handle.h"
10 #include "ppapi/cpp/module_impl.h" 10 #include "ppapi/cpp/module_impl.h"
11 #include "ppapi/cpp/var.h" 11 #include "ppapi/cpp/var.h"
12 12
13 namespace pp { 13 namespace pp {
14 14
15 namespace { 15 namespace {
16 16
17 template <> const char* interface_name<PPB_Flash_Clipboard>() { 17 template <> const char* interface_name<PPB_Flash_Clipboard>() {
18 return PPB_FLASH_CLIPBOARD_INTERFACE; 18 return PPB_FLASH_CLIPBOARD_INTERFACE;
19 } 19 }
20 20
21 } // namespace 21 } // namespace
22 22
23 namespace flash { 23 namespace flash {
24 24
25 // static 25 // static
26 bool Clipboard::IsAvailable() { 26 bool Clipboard::IsAvailable() {
27 return has_interface<PPB_Flash_Clipboard>(); 27 return has_interface<PPB_Flash_Clipboard>();
28 } 28 }
29 29
30 // static 30 // static
31 bool Clipboard::IsFormatAvailable(Instance* instance, 31 bool Clipboard::IsFormatAvailable(const InstanceHandle& instance,
32 PP_Flash_Clipboard_Type clipboard_type, 32 PP_Flash_Clipboard_Type clipboard_type,
33 PP_Flash_Clipboard_Format format) { 33 PP_Flash_Clipboard_Format format) {
34 bool rv = false; 34 bool rv = false;
35 if (has_interface<PPB_Flash_Clipboard>()) { 35 if (has_interface<PPB_Flash_Clipboard>()) {
36 rv = PP_ToBool(get_interface<PPB_Flash_Clipboard>()->IsFormatAvailable( 36 rv = PP_ToBool(get_interface<PPB_Flash_Clipboard>()->IsFormatAvailable(
37 instance->pp_instance(), clipboard_type, format)); 37 instance.pp_instance(), clipboard_type, format));
38 } 38 }
39 return rv; 39 return rv;
40 } 40 }
41 41
42 // static 42 // static
43 bool Clipboard::ReadPlainText(Instance* instance, 43 bool Clipboard::ReadPlainText(const InstanceHandle& instance,
44 PP_Flash_Clipboard_Type clipboard_type, 44 PP_Flash_Clipboard_Type clipboard_type,
45 std::string* text_out) { 45 std::string* text_out) {
46 bool rv = false; 46 bool rv = false;
47 if (has_interface<PPB_Flash_Clipboard>()) { 47 if (has_interface<PPB_Flash_Clipboard>()) {
48 Var v(Var::PassRef(), 48 Var v(PASS_REF,
49 get_interface<PPB_Flash_Clipboard>()->ReadPlainText( 49 get_interface<PPB_Flash_Clipboard>()->ReadPlainText(
50 instance->pp_instance(), 50 instance.pp_instance(),
51 clipboard_type)); 51 clipboard_type));
52 if (v.is_string()) { 52 if (v.is_string()) {
53 rv = true; 53 rv = true;
54 *text_out = v.AsString(); 54 *text_out = v.AsString();
55 } 55 }
56 } 56 }
57 return rv; 57 return rv;
58 } 58 }
59 59
60 // static 60 // static
61 bool Clipboard::WritePlainText(Instance* instance, 61 bool Clipboard::WritePlainText(const InstanceHandle& instance,
62 PP_Flash_Clipboard_Type clipboard_type, 62 PP_Flash_Clipboard_Type clipboard_type,
63 const std::string& text) { 63 const std::string& text) {
64 bool rv = false; 64 bool rv = false;
65 if (has_interface<PPB_Flash_Clipboard>()) { 65 if (has_interface<PPB_Flash_Clipboard>()) {
66 rv = (get_interface<PPB_Flash_Clipboard>()->WritePlainText( 66 rv = (get_interface<PPB_Flash_Clipboard>()->WritePlainText(
67 instance->pp_instance(), 67 instance.pp_instance(),
68 clipboard_type, 68 clipboard_type,
69 Var(text).pp_var()) == PP_OK); 69 Var(text).pp_var()) == PP_OK);
70 } 70 }
71 return rv; 71 return rv;
72 } 72 }
73 73
74 } // namespace flash 74 } // namespace flash
75 } // namespace pp 75 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698