Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 7826017: Add PPB_Fullscreen;0.5. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 plugin_pdf_interface_(NULL), 232 plugin_pdf_interface_(NULL),
233 plugin_policy_updated_interface_(NULL), 233 plugin_policy_updated_interface_(NULL),
234 plugin_selection_interface_(NULL), 234 plugin_selection_interface_(NULL),
235 plugin_zoom_interface_(NULL), 235 plugin_zoom_interface_(NULL),
236 checked_for_plugin_input_event_interface_(false), 236 checked_for_plugin_input_event_interface_(false),
237 checked_for_plugin_messaging_interface_(false), 237 checked_for_plugin_messaging_interface_(false),
238 plugin_print_interface_(NULL), 238 plugin_print_interface_(NULL),
239 plugin_graphics_3d_interface_(NULL), 239 plugin_graphics_3d_interface_(NULL),
240 always_on_top_(false), 240 always_on_top_(false),
241 fullscreen_container_(NULL), 241 fullscreen_container_(NULL),
242 flash_fullscreen_(false),
243 desired_fullscreen_state_(false),
242 fullscreen_(false), 244 fullscreen_(false),
243 message_channel_(NULL), 245 message_channel_(NULL),
244 sad_plugin_(NULL), 246 sad_plugin_(NULL),
245 input_event_mask_(0), 247 input_event_mask_(0),
246 filtered_input_event_mask_(0), 248 filtered_input_event_mask_(0),
247 lock_mouse_callback_(PP_BlockUntilComplete()) { 249 lock_mouse_callback_(PP_BlockUntilComplete()) {
248 pp_instance_ = ResourceTracker::Get()->AddInstance(this); 250 pp_instance_ = ResourceTracker::Get()->AddInstance(this);
249 251
250 memset(&current_print_settings_, 0, sizeof(current_print_settings_)); 252 memset(&current_print_settings_, 0, sizeof(current_print_settings_));
251 DCHECK(delegate); 253 DCHECK(delegate);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 else if (container_) 356 else if (container_)
355 container_->commitBackingTexture(); 357 container_->commitBackingTexture();
356 } 358 }
357 359
358 void PluginInstance::InstanceCrashed() { 360 void PluginInstance::InstanceCrashed() {
359 // Force free all resources and vars. 361 // Force free all resources and vars.
360 ResourceTracker::Get()->InstanceCrashed(pp_instance()); 362 ResourceTracker::Get()->InstanceCrashed(pp_instance());
361 363
362 // Free any associated graphics. 364 // Free any associated graphics.
363 SetFullscreen(false, false); 365 SetFullscreen(false, false);
366 FlashSetFullscreen(false, false);
364 bound_graphics_ = NULL; 367 bound_graphics_ = NULL;
365 InvalidateRect(gfx::Rect()); 368 InvalidateRect(gfx::Rect());
366 369
367 delegate()->PluginCrashed(this); 370 delegate()->PluginCrashed(this);
368 } 371 }
369 372
370 bool PluginInstance::SetCursor(PP_CursorType_Dev type, 373 bool PluginInstance::SetCursor(PP_CursorType_Dev type,
371 PP_Resource custom_image, 374 PP_Resource custom_image,
372 const PP_Point* hot_spot) { 375 const PP_Point* hot_spot) {
373 if (type != PP_CURSORTYPE_CUSTOM) { 376 if (type != PP_CURSORTYPE_CUSTOM) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 if (!clip.IsEmpty()) 529 if (!clip.IsEmpty())
527 new_clip = clip; 530 new_clip = clip;
528 531
529 // Don't notify the plugin if we've already sent these same params before. 532 // Don't notify the plugin if we've already sent these same params before.
530 if (sent_did_change_view_ && position == position_ && new_clip == clip_) 533 if (sent_did_change_view_ && position == position_ && new_clip == clip_)
531 return; 534 return;
532 535
533 sent_did_change_view_ = true; 536 sent_did_change_view_ = true;
534 position_ = position; 537 position_ = position;
535 clip_ = new_clip; 538 clip_ = new_clip;
536 fullscreen_ = (fullscreen_container_ != NULL); 539 fullscreen_ = desired_fullscreen_state_;
540 flash_fullscreen_ = (fullscreen_container_ != NULL);
537 541
538 PP_Rect pp_position, pp_clip; 542 PP_Rect pp_position, pp_clip;
539 RectToPPRect(position_, &pp_position); 543 RectToPPRect(position_, &pp_position);
540 RectToPPRect(clip_, &pp_clip); 544 RectToPPRect(clip_, &pp_clip);
541 instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip); 545 instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip);
542 } 546 }
543 547
544 void PluginInstance::SetWebKitFocus(bool has_focus) { 548 void PluginInstance::SetWebKitFocus(bool has_focus) {
545 if (has_webkit_focus_ == has_focus) 549 if (has_webkit_focus_ == has_focus)
546 return; 550 return;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 } 793 }
790 794
791 bool PluginInstance::PluginHasFocus() const { 795 bool PluginInstance::PluginHasFocus() const {
792 return has_webkit_focus_ && has_content_area_focus_; 796 return has_webkit_focus_ && has_content_area_focus_;
793 } 797 }
794 798
795 void PluginInstance::ReportGeometry() { 799 void PluginInstance::ReportGeometry() {
796 // If this call was delayed, we may have transitioned back to fullscreen in 800 // If this call was delayed, we may have transitioned back to fullscreen in
797 // the mean time, so only report the geometry if we are actually in normal 801 // the mean time, so only report the geometry if we are actually in normal
798 // mode. 802 // mode.
799 if (container_ && !fullscreen_container_) 803 if (container_ && !fullscreen_container_ && !flash_fullscreen_)
800 container_->reportGeometry(); 804 container_->reportGeometry();
801 } 805 }
802 806
803 bool PluginInstance::GetPreferredPrintOutputFormat( 807 bool PluginInstance::GetPreferredPrintOutputFormat(
804 PP_PrintOutputFormat_Dev* format) { 808 PP_PrintOutputFormat_Dev* format) {
805 // Keep a reference on the stack. See NOTE above. 809 // Keep a reference on the stack. See NOTE above.
806 scoped_refptr<PluginInstance> ref(this); 810 scoped_refptr<PluginInstance> ref(this);
807 if (!LoadPrintInterface()) 811 if (!LoadPrintInterface())
808 return false; 812 return false;
809 uint32_t supported_formats = 813 uint32_t supported_formats =
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 DCHECK(plugin_print_interface_); 911 DCHECK(plugin_print_interface_);
908 if (plugin_print_interface_) 912 if (plugin_print_interface_)
909 plugin_print_interface_->End(pp_instance()); 913 plugin_print_interface_->End(pp_instance());
910 914
911 memset(&current_print_settings_, 0, sizeof(current_print_settings_)); 915 memset(&current_print_settings_, 0, sizeof(current_print_settings_));
912 #if defined(OS_MACOSX) 916 #if defined(OS_MACOSX)
913 last_printed_page_ = NULL; 917 last_printed_page_ = NULL;
914 #endif // defined(OS_MACOSX) 918 #endif // defined(OS_MACOSX)
915 } 919 }
916 920
921 bool PluginInstance::FlashIsFullscreenOrPending() {
922 return fullscreen_container_ != NULL;
923 }
924
917 bool PluginInstance::IsFullscreenOrPending() { 925 bool PluginInstance::IsFullscreenOrPending() {
918 return fullscreen_container_ != NULL; 926 return desired_fullscreen_state_;
919 } 927 }
920 928
921 void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) { 929 void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) {
922 // Keep a reference on the stack. See NOTE above. 930 // Keep a reference on the stack. See NOTE above.
923 scoped_refptr<PluginInstance> ref(this); 931 scoped_refptr<PluginInstance> ref(this);
924 932
925 // We check whether we are trying to switch to the state we're already going 933 // We check whether we are trying to switch to the state we're already going
926 // to (i.e. if we're already switching to fullscreen but the fullscreen 934 // to (i.e. if we're already switching to fullscreen but the fullscreen
927 // container isn't ready yet, don't do anything more). 935 // container isn't ready yet, don't do anything more).
928 if (fullscreen == IsFullscreenOrPending()) 936 if (fullscreen == IsFullscreenOrPending())
929 return; 937 return;
930 938
939 // Unbind current 2D or 3D graphics context.
940 BindGraphics(pp_instance(), 0);
941
942 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off");
943 desired_fullscreen_state_ = fullscreen;
944 if (fullscreen)
945 container_->element().requestFullScreen();
946 else
947 container_->element().document().cancelFullScreen();
948 if (!delay_report) {
949 ReportGeometry();
950 } else {
951 MessageLoop::current()->PostTask(
952 FROM_HERE, NewRunnableMethod(this, &PluginInstance::ReportGeometry));
953 }
954 }
955
956 void PluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) {
957 // Keep a reference on the stack. See NOTE above.
958 scoped_refptr<PluginInstance> ref(this);
959
960 // We check whether we are trying to switch to the state we're already going
961 // to (i.e. if we're already switching to fullscreen but the fullscreen
962 // container isn't ready yet, don't do anything more).
963 if (fullscreen == FlashIsFullscreenOrPending())
964 return;
965
966 // Unbind current 2D or 3D graphics context.
931 BindGraphics(pp_instance(), 0); 967 BindGraphics(pp_instance(), 0);
932 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); 968 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off");
933 if (fullscreen) { 969 if (fullscreen) {
934 DCHECK(!fullscreen_container_); 970 DCHECK(!fullscreen_container_);
935 fullscreen_container_ = delegate_->CreateFullscreenContainer(this); 971 fullscreen_container_ = delegate_->CreateFullscreenContainer(this);
936 } else { 972 } else {
937 DCHECK(fullscreen_container_); 973 DCHECK(fullscreen_container_);
938 fullscreen_container_->Destroy(); 974 fullscreen_container_->Destroy();
939 fullscreen_container_ = NULL; 975 fullscreen_container_ = NULL;
940 fullscreen_ = false; 976 flash_fullscreen_ = false;
941 if (!delay_report) { 977 if (!delay_report) {
942 ReportGeometry(); 978 ReportGeometry();
943 } else { 979 } else {
944 MessageLoop::current()->PostTask( 980 MessageLoop::current()->PostTask(
945 FROM_HERE, NewRunnableMethod(this, &PluginInstance::ReportGeometry)); 981 FROM_HERE, NewRunnableMethod(this, &PluginInstance::ReportGeometry));
946 } 982 }
947 } 983 }
948 } 984 }
949 985
950 int32_t PluginInstance::Navigate(PPB_URLRequestInfo_Impl* request, 986 int32_t PluginInstance::Navigate(PPB_URLRequestInfo_Impl* request,
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 PPB_Surface3D_Impl* PluginInstance::GetBoundSurface3D() const { 1292 PPB_Surface3D_Impl* PluginInstance::GetBoundSurface3D() const {
1257 if (bound_graphics_.get() == NULL) 1293 if (bound_graphics_.get() == NULL)
1258 return NULL; 1294 return NULL;
1259 1295
1260 if (bound_graphics_->AsPPB_Surface3D_API()) 1296 if (bound_graphics_->AsPPB_Surface3D_API())
1261 return static_cast<PPB_Surface3D_Impl*>(bound_graphics_.get()); 1297 return static_cast<PPB_Surface3D_Impl*>(bound_graphics_.get());
1262 return NULL; 1298 return NULL;
1263 } 1299 }
1264 1300
1265 void PluginInstance::setBackingTextureId(unsigned int id) { 1301 void PluginInstance::setBackingTextureId(unsigned int id) {
1266 // If we have a full-screen container_ then the plugin is fullscreen, 1302 // If we have a fullscreen_container_ (under PPB_FlashFullscreen)
1267 // and the parent context is not the one for the browser page, but for the 1303 // or desired_fullscreen_state is true (under PPB_Fullscreen_Dev),
1268 // full-screen window, and so the parent texture ID doesn't correspond to 1304 // then the plugin is fullscreen or transitioning to fullscreen
1269 // anything in the page's context. 1305 // and the parent context is not the one for the browser page,
1306 // but for the fullscreen window, and so the parent texture ID
1307 // doesn't correspond to anything in the page's context.
1270 // 1308 //
1271 // TODO(alokp): It would be better at some point to have the equivalent 1309 // TODO(alokp): It would be better at some point to have the equivalent
1272 // in the FullscreenContainer so that we don't need to poll 1310 // in the FullscreenContainer so that we don't need to poll
1273 if (fullscreen_container_) 1311 if (fullscreen_container_ || desired_fullscreen_state_)
1274 return; 1312 return;
1275 1313
1276 if (container_) 1314 if (container_)
1277 container_->setBackingTextureId(id); 1315 container_->setBackingTextureId(id);
1278 } 1316 }
1279 1317
1280 void PluginInstance::AddPluginObject(PluginObject* plugin_object) { 1318 void PluginInstance::AddPluginObject(PluginObject* plugin_object) {
1281 DCHECK(live_plugin_objects_.find(plugin_object) == 1319 DCHECK(live_plugin_objects_.find(plugin_object) ==
1282 live_plugin_objects_.end()); 1320 live_plugin_objects_.end());
1283 live_plugin_objects_.insert(plugin_object); 1321 live_plugin_objects_.insert(plugin_object);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 bound_graphics_ = NULL; 1363 bound_graphics_ = NULL;
1326 } 1364 }
1327 1365
1328 // Special-case clearing the current device. 1366 // Special-case clearing the current device.
1329 if (!device) { 1367 if (!device) {
1330 setBackingTextureId(0); 1368 setBackingTextureId(0);
1331 InvalidateRect(gfx::Rect()); 1369 InvalidateRect(gfx::Rect());
1332 return PP_TRUE; 1370 return PP_TRUE;
1333 } 1371 }
1334 1372
1335 // Refuse to bind if we're transitioning to fullscreen. 1373 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or
1336 if (fullscreen_container_ && !fullscreen_) 1374 // to/from fullscreen with PPB_Fullscreen_Dev.
1375 if ((fullscreen_container_ && !flash_fullscreen_) ||
1376 desired_fullscreen_state_ != fullscreen_)
1337 return PP_FALSE; 1377 return PP_FALSE;
1338 1378
1339 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); 1379 EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false);
1340 PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? 1380 PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ?
1341 static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL; 1381 static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL;
1342 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); 1382 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false);
1343 PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ? 1383 PPB_Graphics3D_Impl* graphics_3d = enter_3d.succeeded() ?
1344 static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL; 1384 static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) : NULL;
1345 EnterResourceNoLock<PPB_Surface3D_API> enter_surface_3d(device, false); 1385 EnterResourceNoLock<PPB_Surface3D_API> enter_surface_3d(device, false);
1346 PPB_Surface3D_Impl* surface_3d = enter_surface_3d.succeeded() ? 1386 PPB_Surface3D_Impl* surface_3d = enter_surface_3d.succeeded() ?
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 delegate_->NumberOfFindResultsChanged(find_identifier_, total, 1538 delegate_->NumberOfFindResultsChanged(find_identifier_, total,
1499 PP_ToBool(final_result)); 1539 PP_ToBool(final_result));
1500 } 1540 }
1501 1541
1502 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, 1542 void PluginInstance::SelectedFindResultChanged(PP_Instance instance,
1503 int32_t index) { 1543 int32_t index) {
1504 DCHECK_NE(find_identifier_, -1); 1544 DCHECK_NE(find_identifier_, -1);
1505 delegate_->SelectedFindResultChanged(find_identifier_, index); 1545 delegate_->SelectedFindResultChanged(find_identifier_, index);
1506 } 1546 }
1507 1547
1548 PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) {
1549 return PP_FromBool(fullscreen_);
1550 }
1551
1508 PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) { 1552 PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) {
1509 return PP_FromBool(fullscreen_); 1553 return PP_FromBool(flash_fullscreen_);
1554 }
1555
1556 PP_Bool PluginInstance::SetFullscreen(PP_Instance instance,
1557 PP_Bool fullscreen) {
1558 SetFullscreen(PP_ToBool(fullscreen), true);
1559 return PP_TRUE;
1510 } 1560 }
1511 1561
1512 PP_Bool PluginInstance::FlashSetFullscreen(PP_Instance instance, 1562 PP_Bool PluginInstance::FlashSetFullscreen(PP_Instance instance,
1513 PP_Bool fullscreen) { 1563 PP_Bool fullscreen) {
1514 SetFullscreen(PP_ToBool(fullscreen), true); 1564 FlashSetFullscreen(PP_ToBool(fullscreen), true);
1565 return PP_TRUE;
1566 }
1567
1568 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) {
1569 gfx::Size screen_size = delegate()->GetScreenSize();
1570 *size = PP_MakeSize(screen_size.width(), screen_size.height());
1515 return PP_TRUE; 1571 return PP_TRUE;
1516 } 1572 }
1517 1573
1518 PP_Bool PluginInstance::FlashGetScreenSize(PP_Instance instance, 1574 PP_Bool PluginInstance::FlashGetScreenSize(PP_Instance instance,
1519 PP_Size* size) { 1575 PP_Size* size) {
1520 gfx::Size screen_size = delegate()->GetScreenSize(); 1576 return GetScreenSize(instance, size);
1521 *size = PP_MakeSize(screen_size.width(), screen_size.height());
1522 return PP_TRUE;
1523 } 1577 }
1524 1578
1525 int32_t PluginInstance::RequestInputEvents(PP_Instance instance, 1579 int32_t PluginInstance::RequestInputEvents(PP_Instance instance,
1526 uint32_t event_classes) { 1580 uint32_t event_classes) {
1527 input_event_mask_ |= event_classes; 1581 input_event_mask_ |= event_classes;
1528 filtered_input_event_mask_ &= ~(event_classes); 1582 filtered_input_event_mask_ &= ~(event_classes);
1529 return ValidateRequestInputEvents(false, event_classes); 1583 return ValidateRequestInputEvents(false, event_classes);
1530 } 1584 }
1531 1585
1532 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance, 1586 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 } 1654 }
1601 1655
1602 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { 1656 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) {
1603 cursor_.reset(cursor); 1657 cursor_.reset(cursor);
1604 if (fullscreen_container_) 1658 if (fullscreen_container_)
1605 fullscreen_container_->DidChangeCursor(*cursor); 1659 fullscreen_container_->DidChangeCursor(*cursor);
1606 } 1660 }
1607 1661
1608 } // namespace ppapi 1662 } // namespace ppapi
1609 } // namespace webkit 1663 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | webkit/plugins/ppapi/ppapi_webplugin_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698