OLD | NEW |
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 "webkit/plugins/ppapi/ppb_broker_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_broker_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/shared_impl/platform_file.h" | 8 #include "ppapi/shared_impl/platform_file.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
9 #include "webkit/plugins/ppapi/common.h" | 12 #include "webkit/plugins/ppapi/common.h" |
10 #include "webkit/plugins/ppapi/plugin_module.h" | 13 #include "webkit/plugins/ppapi/plugin_module.h" |
11 #include "webkit/plugins/ppapi/resource_helper.h" | 14 #include "webkit/plugins/ppapi/resource_helper.h" |
12 | 15 |
13 using ppapi::PlatformFileToInt; | 16 using ppapi::PlatformFileToInt; |
14 using ppapi::thunk::PPB_Broker_API; | 17 using ppapi::thunk::PPB_Broker_API; |
15 using ppapi::TrackedCallback; | 18 using ppapi::TrackedCallback; |
16 | 19 |
17 namespace webkit { | 20 namespace webkit { |
18 namespace ppapi { | 21 namespace ppapi { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return PP_OK_COMPLETIONPENDING; | 71 return PP_OK_COMPLETIONPENDING; |
69 } | 72 } |
70 | 73 |
71 int32_t PPB_Broker_Impl::GetHandle(int32_t* handle) { | 74 int32_t PPB_Broker_Impl::GetHandle(int32_t* handle) { |
72 if (pipe_handle_ == PlatformFileToInt(base::kInvalidPlatformFileValue)) | 75 if (pipe_handle_ == PlatformFileToInt(base::kInvalidPlatformFileValue)) |
73 return PP_ERROR_FAILED; // Handle not set yet. | 76 return PP_ERROR_FAILED; // Handle not set yet. |
74 *handle = pipe_handle_; | 77 *handle = pipe_handle_; |
75 return PP_OK; | 78 return PP_OK; |
76 } | 79 } |
77 | 80 |
| 81 GURL PPB_Broker_Impl::GetDocumentUrl() { |
| 82 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 83 return plugin_instance->container()->element().document().url(); |
| 84 } |
| 85 |
78 // Transfers ownership of the handle to the plugin. | 86 // Transfers ownership of the handle to the plugin. |
79 void PPB_Broker_Impl::BrokerConnected(int32_t handle, int32_t result) { | 87 void PPB_Broker_Impl::BrokerConnected(int32_t handle, int32_t result) { |
80 DCHECK(pipe_handle_ == | 88 DCHECK(pipe_handle_ == |
81 PlatformFileToInt(base::kInvalidPlatformFileValue)); | 89 PlatformFileToInt(base::kInvalidPlatformFileValue)); |
82 DCHECK(result == PP_OK || | 90 DCHECK(result == PP_OK || |
83 handle == PlatformFileToInt(base::kInvalidPlatformFileValue)); | 91 handle == PlatformFileToInt(base::kInvalidPlatformFileValue)); |
84 | 92 |
85 pipe_handle_ = handle; | 93 pipe_handle_ = handle; |
86 | 94 |
87 // Synchronous calls are not supported. | 95 // Synchronous calls are not supported. |
88 DCHECK(TrackedCallback::IsPending(connect_callback_)); | 96 DCHECK(TrackedCallback::IsPending(connect_callback_)); |
89 | 97 |
90 TrackedCallback::ClearAndRun(&connect_callback_, result); | 98 TrackedCallback::ClearAndRun(&connect_callback_, result); |
91 } | 99 } |
92 | 100 |
93 } // namespace ppapi | 101 } // namespace ppapi |
94 } // namespace webkit | 102 } // namespace webkit |
OLD | NEW |