| 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" |
| 21 #include "webkit/plugins/ppapi/plugin_module.h" | 22 #include "webkit/plugins/ppapi/plugin_module.h" |
| 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 23 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 23 #include "webkit/plugins/ppapi/resource_tracker.h" | 24 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 24 | 25 |
| 25 using ppapi::StringVar; | 26 using ppapi::StringVar; |
| 26 | 27 |
| 27 namespace webkit { | 28 namespace webkit { |
| 28 namespace ppapi { | 29 namespace ppapi { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 57 default: | 58 default: |
| 58 NOTREACHED(); | 59 NOTREACHED(); |
| 59 return WebKit::WebClipboard::FormatPlainText; // Gotta return something. | 60 return WebKit::WebClipboard::FormatPlainText; // Gotta return something. |
| 60 } | 61 } |
| 61 } | 62 } |
| 62 | 63 |
| 63 PP_Bool IsFormatAvailable(PP_Instance instance_id, | 64 PP_Bool IsFormatAvailable(PP_Instance instance_id, |
| 64 PP_Flash_Clipboard_Type clipboard_type, | 65 PP_Flash_Clipboard_Type clipboard_type, |
| 65 PP_Flash_Clipboard_Format format) { | 66 PP_Flash_Clipboard_Format format) { |
| 66 // If you don't give us an instance, we don't give you anything. | 67 // If you don't give us an instance, we don't give you anything. |
| 67 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 68 PluginInstance* instance = |
| 69 HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id); |
| 68 if (!instance) | 70 if (!instance) |
| 69 return PP_FALSE; | 71 return PP_FALSE; |
| 70 | 72 |
| 71 WebKit::WebClipboard* web_clipboard = | 73 WebKit::WebClipboard* web_clipboard = |
| 72 WebKit::webKitPlatformSupport()->clipboard(); | 74 WebKit::webKitPlatformSupport()->clipboard(); |
| 73 if (!web_clipboard) { | 75 if (!web_clipboard) { |
| 74 NOTREACHED(); | 76 NOTREACHED(); |
| 75 return PP_FALSE; | 77 return PP_FALSE; |
| 76 } | 78 } |
| 77 | 79 |
| 78 return BoolToPPBool( | 80 return BoolToPPBool( |
| 79 web_clipboard->isFormatAvailable(ConvertClipboardFormat(format), | 81 web_clipboard->isFormatAvailable(ConvertClipboardFormat(format), |
| 80 ConvertClipboardType(clipboard_type))); | 82 ConvertClipboardType(clipboard_type))); |
| 81 } | 83 } |
| 82 | 84 |
| 83 PP_Var ReadPlainText(PP_Instance instance_id, | 85 PP_Var ReadPlainText(PP_Instance instance_id, |
| 84 PP_Flash_Clipboard_Type clipboard_type) { | 86 PP_Flash_Clipboard_Type clipboard_type) { |
| 85 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 87 PluginInstance* instance = |
| 88 HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id); |
| 86 if (!instance) | 89 if (!instance) |
| 87 return PP_MakeNull(); | 90 return PP_MakeNull(); |
| 88 | 91 |
| 89 WebKit::WebClipboard* web_clipboard = | 92 WebKit::WebClipboard* web_clipboard = |
| 90 WebKit::webKitPlatformSupport()->clipboard(); | 93 WebKit::webKitPlatformSupport()->clipboard(); |
| 91 if (!web_clipboard) { | 94 if (!web_clipboard) { |
| 92 NOTREACHED(); | 95 NOTREACHED(); |
| 93 return PP_MakeNull(); | 96 return PP_MakeNull(); |
| 94 } | 97 } |
| 95 | 98 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } // namespace | 137 } // namespace |
| 135 | 138 |
| 136 // static | 139 // static |
| 137 const PPB_Flash_Clipboard* | 140 const PPB_Flash_Clipboard* |
| 138 PPB_Flash_Clipboard_Impl::GetInterface() { | 141 PPB_Flash_Clipboard_Impl::GetInterface() { |
| 139 return &ppb_flash_clipboard; | 142 return &ppb_flash_clipboard; |
| 140 } | 143 } |
| 141 | 144 |
| 142 } // namespace ppapi | 145 } // namespace ppapi |
| 143 } // namespace webkit | 146 } // namespace webkit |
| OLD | NEW |