OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_flash_clipboard_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_flash_clipboard_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
13 #include "ppapi/c/private/ppb_flash_clipboard.h" | 13 #include "ppapi/c/private/ppb_flash_clipboard.h" |
14 #include "ppapi/shared_impl/var.h" | 14 #include "ppapi/shared_impl/var.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebClipboard.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebClipboard.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitPlatformSupport
.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitPlatformSupport
.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
20 #include "webkit/plugins/ppapi/common.h" | 20 #include "webkit/plugins/ppapi/common.h" |
21 #include "webkit/plugins/ppapi/host_globals.h" | |
22 #include "webkit/plugins/ppapi/plugin_module.h" | 21 #include "webkit/plugins/ppapi/plugin_module.h" |
23 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
24 #include "webkit/plugins/ppapi/resource_tracker.h" | 23 #include "webkit/plugins/ppapi/resource_tracker.h" |
25 | 24 |
26 using ppapi::StringVar; | 25 using ppapi::StringVar; |
27 | 26 |
28 namespace webkit { | 27 namespace webkit { |
29 namespace ppapi { | 28 namespace ppapi { |
30 | 29 |
31 namespace { | 30 namespace { |
(...skipping 26 matching lines...) Expand all Loading... |
58 default: | 57 default: |
59 NOTREACHED(); | 58 NOTREACHED(); |
60 return WebKit::WebClipboard::FormatPlainText; // Gotta return something. | 59 return WebKit::WebClipboard::FormatPlainText; // Gotta return something. |
61 } | 60 } |
62 } | 61 } |
63 | 62 |
64 PP_Bool IsFormatAvailable(PP_Instance instance_id, | 63 PP_Bool IsFormatAvailable(PP_Instance instance_id, |
65 PP_Flash_Clipboard_Type clipboard_type, | 64 PP_Flash_Clipboard_Type clipboard_type, |
66 PP_Flash_Clipboard_Format format) { | 65 PP_Flash_Clipboard_Format format) { |
67 // If you don't give us an instance, we don't give you anything. | 66 // If you don't give us an instance, we don't give you anything. |
68 PluginInstance* instance = | 67 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
69 HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id); | |
70 if (!instance) | 68 if (!instance) |
71 return PP_FALSE; | 69 return PP_FALSE; |
72 | 70 |
73 WebKit::WebClipboard* web_clipboard = | 71 WebKit::WebClipboard* web_clipboard = |
74 WebKit::webKitPlatformSupport()->clipboard(); | 72 WebKit::webKitPlatformSupport()->clipboard(); |
75 if (!web_clipboard) { | 73 if (!web_clipboard) { |
76 NOTREACHED(); | 74 NOTREACHED(); |
77 return PP_FALSE; | 75 return PP_FALSE; |
78 } | 76 } |
79 | 77 |
80 return BoolToPPBool( | 78 return BoolToPPBool( |
81 web_clipboard->isFormatAvailable(ConvertClipboardFormat(format), | 79 web_clipboard->isFormatAvailable(ConvertClipboardFormat(format), |
82 ConvertClipboardType(clipboard_type))); | 80 ConvertClipboardType(clipboard_type))); |
83 } | 81 } |
84 | 82 |
85 PP_Var ReadPlainText(PP_Instance instance_id, | 83 PP_Var ReadPlainText(PP_Instance instance_id, |
86 PP_Flash_Clipboard_Type clipboard_type) { | 84 PP_Flash_Clipboard_Type clipboard_type) { |
87 PluginInstance* instance = | 85 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
88 HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id); | |
89 if (!instance) | 86 if (!instance) |
90 return PP_MakeNull(); | 87 return PP_MakeNull(); |
91 | 88 |
92 WebKit::WebClipboard* web_clipboard = | 89 WebKit::WebClipboard* web_clipboard = |
93 WebKit::webKitPlatformSupport()->clipboard(); | 90 WebKit::webKitPlatformSupport()->clipboard(); |
94 if (!web_clipboard) { | 91 if (!web_clipboard) { |
95 NOTREACHED(); | 92 NOTREACHED(); |
96 return PP_MakeNull(); | 93 return PP_MakeNull(); |
97 } | 94 } |
98 | 95 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } // namespace | 134 } // namespace |
138 | 135 |
139 // static | 136 // static |
140 const PPB_Flash_Clipboard* | 137 const PPB_Flash_Clipboard* |
141 PPB_Flash_Clipboard_Impl::GetInterface() { | 138 PPB_Flash_Clipboard_Impl::GetInterface() { |
142 return &ppb_flash_clipboard; | 139 return &ppb_flash_clipboard; |
143 } | 140 } |
144 | 141 |
145 } // namespace ppapi | 142 } // namespace ppapi |
146 } // namespace webkit | 143 } // namespace webkit |
OLD | NEW |