| 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 "content/plugin/webplugin_delegate_stub.h" | 5 #include "content/plugin/webplugin_delegate_stub.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // A plugin can execute a script to delete itself in any of its NPP methods. | 86 // A plugin can execute a script to delete itself in any of its NPP methods. |
| 87 // Hold an extra reference to ourself so that if this does occur and we're | 87 // Hold an extra reference to ourself so that if this does occur and we're |
| 88 // handling a sync message, we don't crash when attempting to send a reply. | 88 // handling a sync message, we don't crash when attempting to send a reply. |
| 89 // The exception to this is when we're already in the destructor. | 89 // The exception to this is when we're already in the destructor. |
| 90 if (!in_destructor_) | 90 if (!in_destructor_) |
| 91 AddRef(); | 91 AddRef(); |
| 92 | 92 |
| 93 bool handled = true; | 93 bool handled = true; |
| 94 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateStub, msg) | 94 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateStub, msg) |
| 95 IPC_MESSAGE_HANDLER(PluginMsg_Init, OnInit) | 95 IPC_MESSAGE_HANDLER(PluginMsg_Init, OnInit) |
| 96 IPC_MESSAGE_HANDLER(PluginMsg_WillSendRequest, OnWillSendRequest) | |
| 97 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveResponse, OnDidReceiveResponse) | |
| 98 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveData, OnDidReceiveData) | |
| 99 IPC_MESSAGE_HANDLER(PluginMsg_DidFinishLoading, OnDidFinishLoading) | |
| 100 IPC_MESSAGE_HANDLER(PluginMsg_DidFail, OnDidFail) | |
| 101 IPC_MESSAGE_HANDLER(PluginMsg_SetFocus, OnSetFocus) | 96 IPC_MESSAGE_HANDLER(PluginMsg_SetFocus, OnSetFocus) |
| 102 IPC_MESSAGE_HANDLER(PluginMsg_HandleInputEvent, OnHandleInputEvent) | 97 IPC_MESSAGE_HANDLER(PluginMsg_HandleInputEvent, OnHandleInputEvent) |
| 103 IPC_MESSAGE_HANDLER(PluginMsg_Paint, OnPaint) | 98 IPC_MESSAGE_HANDLER(PluginMsg_Paint, OnPaint) |
| 104 IPC_MESSAGE_HANDLER(PluginMsg_DidPaint, OnDidPaint) | 99 IPC_MESSAGE_HANDLER(PluginMsg_DidPaint, OnDidPaint) |
| 105 IPC_MESSAGE_HANDLER(PluginMsg_GetPluginScriptableObject, | 100 IPC_MESSAGE_HANDLER(PluginMsg_GetPluginScriptableObject, |
| 106 OnGetPluginScriptableObject) | 101 OnGetPluginScriptableObject) |
| 107 IPC_MESSAGE_HANDLER(PluginMsg_GetFormValue, OnGetFormValue) | 102 IPC_MESSAGE_HANDLER(PluginMsg_GetFormValue, OnGetFormValue) |
| 108 IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometry, OnUpdateGeometry) | 103 IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometry, OnUpdateGeometry) |
| 109 IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometrySync, OnUpdateGeometry) | 104 IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometrySync, OnUpdateGeometry) |
| 110 IPC_MESSAGE_HANDLER(PluginMsg_SetContentAreaFocus, OnSetContentAreaFocus) | 105 IPC_MESSAGE_HANDLER(PluginMsg_SetContentAreaFocus, OnSetContentAreaFocus) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 delegate_->GetPluginNPP()); | 170 delegate_->GetPluginNPP()); |
| 176 | 171 |
| 177 *result = delegate_->Initialize(params.url, | 172 *result = delegate_->Initialize(params.url, |
| 178 arg_names, | 173 arg_names, |
| 179 arg_values, | 174 arg_values, |
| 180 params.load_manually); | 175 params.load_manually); |
| 181 *transparent = delegate_->instance()->transparent(); | 176 *transparent = delegate_->instance()->transparent(); |
| 182 } | 177 } |
| 183 } | 178 } |
| 184 | 179 |
| 185 void WebPluginDelegateStub::OnWillSendRequest(int id, const GURL& url, | |
| 186 int http_status_code) { | |
| 187 WebPluginResourceClient* client = webplugin_->GetResourceClient(id); | |
| 188 if (!client) | |
| 189 return; | |
| 190 | |
| 191 client->WillSendRequest(url, http_status_code); | |
| 192 } | |
| 193 | |
| 194 void WebPluginDelegateStub::OnDidReceiveResponse( | |
| 195 const PluginMsg_DidReceiveResponseParams& params) { | |
| 196 WebPluginResourceClient* client = webplugin_->GetResourceClient(params.id); | |
| 197 if (!client) | |
| 198 return; | |
| 199 | |
| 200 client->DidReceiveResponse(params.mime_type, | |
| 201 params.headers, | |
| 202 params.expected_length, | |
| 203 params.last_modified, | |
| 204 params.request_is_seekable); | |
| 205 } | |
| 206 | |
| 207 void WebPluginDelegateStub::OnDidReceiveData(int id, | |
| 208 const std::vector<char>& buffer, | |
| 209 int data_offset) { | |
| 210 WebPluginResourceClient* client = webplugin_->GetResourceClient(id); | |
| 211 if (!client) | |
| 212 return; | |
| 213 | |
| 214 client->DidReceiveData(&buffer.front(), static_cast<int>(buffer.size()), | |
| 215 data_offset); | |
| 216 } | |
| 217 | |
| 218 void WebPluginDelegateStub::OnDidFinishLoading(int id) { | |
| 219 WebPluginResourceClient* client = webplugin_->GetResourceClient(id); | |
| 220 if (!client) | |
| 221 return; | |
| 222 | |
| 223 client->DidFinishLoading(id); | |
| 224 } | |
| 225 | |
| 226 void WebPluginDelegateStub::OnDidFail(int id) { | |
| 227 WebPluginResourceClient* client = webplugin_->GetResourceClient(id); | |
| 228 if (!client) | |
| 229 return; | |
| 230 | |
| 231 client->DidFail(id); | |
| 232 } | |
| 233 | |
| 234 void WebPluginDelegateStub::OnSetFocus(bool focused) { | 180 void WebPluginDelegateStub::OnSetFocus(bool focused) { |
| 235 delegate_->SetFocus(focused); | 181 delegate_->SetFocus(focused); |
| 236 #if defined(OS_WIN) && !defined(USE_AURA) | 182 #if defined(OS_WIN) && !defined(USE_AURA) |
| 237 if (focused) | 183 if (focused) |
| 238 webplugin_->UpdateIMEStatus(); | 184 webplugin_->UpdateIMEStatus(); |
| 239 #endif | 185 #endif |
| 240 } | 186 } |
| 241 | 187 |
| 242 void WebPluginDelegateStub::OnHandleInputEvent( | 188 void WebPluginDelegateStub::OnHandleInputEvent( |
| 243 const blink::WebInputEvent *event, | 189 const blink::WebInputEvent *event, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 289 } |
| 344 | 290 |
| 345 void WebPluginDelegateStub::OnImeCompositionCompleted( | 291 void WebPluginDelegateStub::OnImeCompositionCompleted( |
| 346 const base::string16& text) { | 292 const base::string16& text) { |
| 347 if (delegate_) | 293 if (delegate_) |
| 348 delegate_->ImeCompositionCompleted(text); | 294 delegate_->ImeCompositionCompleted(text); |
| 349 } | 295 } |
| 350 #endif // OS_MACOSX | 296 #endif // OS_MACOSX |
| 351 | 297 |
| 352 } // namespace content | 298 } // namespace content |
| OLD | NEW |