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/renderer/pepper/pepper_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 request_id, | 471 request_id, |
472 broker_path); | 472 broker_path); |
473 if (!render_view_->Send(msg)) { | 473 if (!render_view_->Send(msg)) { |
474 pending_connect_broker_.Remove(request_id); | 474 pending_connect_broker_.Remove(request_id); |
475 return scoped_refptr<PepperBrokerImpl>(); | 475 return scoped_refptr<PepperBrokerImpl>(); |
476 } | 476 } |
477 | 477 |
478 return broker; | 478 return broker; |
479 } | 479 } |
480 | 480 |
| 481 void PepperPluginDelegateImpl::OnCustomContextMenuAction(int request_id, |
| 482 unsigned action) { |
| 483 // Just save the action. |
| 484 DCHECK(!has_saved_context_menu_action_); |
| 485 has_saved_context_menu_action_ = true; |
| 486 saved_context_menu_action_ = action; |
| 487 } |
| 488 |
| 489 void PepperPluginDelegateImpl::OnCustomContextMenuClosed(int request_id) { |
| 490 PendingContextMenuMap::iterator found = |
| 491 pending_context_menus_.find(request_id); |
| 492 if (found == pending_context_menus_.end()) { |
| 493 NOTREACHED() << "OnContextMenuClosed() called twice for the same menu."; |
| 494 return; |
| 495 } |
| 496 |
| 497 if (has_saved_context_menu_action_) { |
| 498 found->second->CompleteShow(PP_OK, saved_context_menu_action_); |
| 499 has_saved_context_menu_action_ = false; |
| 500 saved_context_menu_action_ = 0; |
| 501 } else { |
| 502 found->second->CompleteShow(PP_ERROR_USERCANCEL, 0); |
| 503 } |
| 504 pending_context_menus_.erase(found); |
| 505 } |
| 506 |
481 void PepperPluginDelegateImpl::OnPpapiBrokerChannelCreated( | 507 void PepperPluginDelegateImpl::OnPpapiBrokerChannelCreated( |
482 int request_id, | 508 int request_id, |
483 const IPC::ChannelHandle& handle) { | 509 const IPC::ChannelHandle& handle) { |
484 scoped_refptr<PepperBrokerImpl>* broker_ptr = | 510 scoped_refptr<PepperBrokerImpl>* broker_ptr = |
485 pending_connect_broker_.Lookup(request_id); | 511 pending_connect_broker_.Lookup(request_id); |
486 if (broker_ptr) { | 512 if (broker_ptr) { |
487 scoped_refptr<PepperBrokerImpl> broker = *broker_ptr; | 513 scoped_refptr<PepperBrokerImpl> broker = *broker_ptr; |
488 pending_connect_broker_.Remove(request_id); | 514 pending_connect_broker_.Remove(request_id); |
489 broker->OnBrokerChannelConnected(handle); | 515 broker->OnBrokerChannelConnected(handle); |
490 } else { | 516 } else { |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 const gfx::Point& position) { | 1390 const gfx::Point& position) { |
1365 int32 render_widget_id = render_view_->routing_id(); | 1391 int32 render_widget_id = render_view_->routing_id(); |
1366 if (instance->flash_fullscreen()) { | 1392 if (instance->flash_fullscreen()) { |
1367 webkit::ppapi::FullscreenContainer* container = | 1393 webkit::ppapi::FullscreenContainer* container = |
1368 instance->fullscreen_container(); | 1394 instance->fullscreen_container(); |
1369 DCHECK(container); | 1395 DCHECK(container); |
1370 render_widget_id = | 1396 render_widget_id = |
1371 static_cast<RenderWidgetFullscreenPepper*>(container)->routing_id(); | 1397 static_cast<RenderWidgetFullscreenPepper*>(container)->routing_id(); |
1372 } | 1398 } |
1373 | 1399 |
1374 int request_id = pending_context_menus_.Add( | |
1375 new scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>(menu)); | |
1376 | |
1377 ContextMenuParams params; | 1400 ContextMenuParams params; |
1378 params.x = position.x(); | 1401 params.x = position.x(); |
1379 params.y = position.y(); | 1402 params.y = position.y(); |
1380 params.custom_context.is_pepper_menu = true; | 1403 params.custom_context.is_pepper_menu = true; |
1381 params.custom_context.request_id = request_id; | |
1382 params.custom_context.render_widget_id = render_widget_id; | |
1383 params.custom_items = menu->menu_data(); | 1404 params.custom_items = menu->menu_data(); |
1384 | 1405 |
1385 // Transform the position to be in render view's coordinates. | 1406 // Transform the position to be in render view's coordinates. |
1386 if (instance->view_data().is_fullscreen || instance->flash_fullscreen()) { | 1407 if (instance->view_data().is_fullscreen || instance->flash_fullscreen()) { |
1387 WebKit::WebRect window_rect = render_view_->windowRect(); | 1408 WebKit::WebRect window_rect = render_view_->windowRect(); |
1388 WebKit::WebRect screen_rect = render_view_->screenInfo().rect; | 1409 WebKit::WebRect screen_rect = render_view_->screenInfo().rect; |
1389 params.x = params.x - window_rect.x + screen_rect.x; | 1410 params.x = params.x - window_rect.x + screen_rect.x; |
1390 params.y = params.y - window_rect.y + screen_rect.y; | 1411 params.y = params.y - window_rect.y + screen_rect.y; |
1391 } else { | 1412 } else { |
1392 params.x += instance->view_data().rect.point.x; | 1413 params.x += instance->view_data().rect.point.x; |
1393 params.y += instance->view_data().rect.point.y; | 1414 params.y += instance->view_data().rect.point.y; |
1394 } | 1415 } |
1395 | 1416 |
1396 IPC::Message* msg = new ViewHostMsg_ContextMenu(render_view_->routing_id(), | 1417 int request_id = render_view_->ShowContextMenu(this, params); |
1397 params); | 1418 pending_context_menus_[request_id] = |
1398 if (!render_view_->Send(msg)) { | 1419 scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>(menu); |
1399 pending_context_menus_.Remove(request_id); | |
1400 return PP_ERROR_FAILED; | |
1401 } | |
1402 | |
1403 return PP_OK_COMPLETIONPENDING; | 1420 return PP_OK_COMPLETIONPENDING; |
1404 } | 1421 } |
1405 | 1422 |
1406 void PepperPluginDelegateImpl::OnContextMenuClosed( | |
1407 const CustomContextMenuContext& custom_context) { | |
1408 int request_id = custom_context.request_id; | |
1409 scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>* menu_ptr = | |
1410 pending_context_menus_.Lookup(request_id); | |
1411 if (!menu_ptr) { | |
1412 NOTREACHED() << "CompleteShowContextMenu() called twice for the same menu."; | |
1413 return; | |
1414 } | |
1415 scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl> menu = *menu_ptr; | |
1416 DCHECK(menu.get()); | |
1417 pending_context_menus_.Remove(request_id); | |
1418 | |
1419 if (has_saved_context_menu_action_) { | |
1420 menu->CompleteShow(PP_OK, saved_context_menu_action_); | |
1421 has_saved_context_menu_action_ = false; | |
1422 saved_context_menu_action_ = 0; | |
1423 } else { | |
1424 menu->CompleteShow(PP_ERROR_USERCANCEL, 0); | |
1425 } | |
1426 } | |
1427 | |
1428 void PepperPluginDelegateImpl::OnCustomContextMenuAction( | |
1429 const CustomContextMenuContext& custom_context, | |
1430 unsigned action) { | |
1431 // Just save the action. | |
1432 DCHECK(!has_saved_context_menu_action_); | |
1433 has_saved_context_menu_action_ = true; | |
1434 saved_context_menu_action_ = action; | |
1435 } | |
1436 | |
1437 webkit::ppapi::FullscreenContainer* | 1423 webkit::ppapi::FullscreenContainer* |
1438 PepperPluginDelegateImpl::CreateFullscreenContainer( | 1424 PepperPluginDelegateImpl::CreateFullscreenContainer( |
1439 webkit::ppapi::PluginInstance* instance) { | 1425 webkit::ppapi::PluginInstance* instance) { |
1440 return render_view_->CreatePepperFullscreenContainer(instance); | 1426 return render_view_->CreatePepperFullscreenContainer(instance); |
1441 } | 1427 } |
1442 | 1428 |
1443 gfx::Size PepperPluginDelegateImpl::GetScreenSize() { | 1429 gfx::Size PepperPluginDelegateImpl::GetScreenSize() { |
1444 WebKit::WebScreenInfo info = render_view_->screenInfo(); | 1430 WebKit::WebScreenInfo info = render_view_->screenInfo(); |
1445 return gfx::Size(info.rect.width, info.rect.height); | 1431 return gfx::Size(info.rect.width, info.rect.height); |
1446 } | 1432 } |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 else | 1858 else |
1873 return render_view_->mouse_lock_dispatcher(); | 1859 return render_view_->mouse_lock_dispatcher(); |
1874 } | 1860 } |
1875 | 1861 |
1876 webkit_glue::ClipboardClient* | 1862 webkit_glue::ClipboardClient* |
1877 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1863 PepperPluginDelegateImpl::CreateClipboardClient() const { |
1878 return new RendererClipboardClient; | 1864 return new RendererClipboardClient; |
1879 } | 1865 } |
1880 | 1866 |
1881 } // namespace content | 1867 } // namespace content |
OLD | NEW |