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