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

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

Issue 6871040: Rename Instance_Trusted to Instance_Private, wire it up in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix up based on review comments. Created 9 years, 8 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
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "ppapi/c/dev/ppb_find_dev.h" 12 #include "ppapi/c/dev/ppb_find_dev.h"
13 #include "ppapi/c/dev/ppb_fullscreen_dev.h" 13 #include "ppapi/c/dev/ppb_fullscreen_dev.h"
14 #include "ppapi/c/dev/ppb_zoom_dev.h" 14 #include "ppapi/c/dev/ppb_zoom_dev.h"
15 #include "ppapi/c/dev/ppp_find_dev.h" 15 #include "ppapi/c/dev/ppp_find_dev.h"
16 #include "ppapi/c/dev/ppp_selection_dev.h" 16 #include "ppapi/c/dev/ppp_selection_dev.h"
17 #include "ppapi/c/dev/ppp_zoom_dev.h" 17 #include "ppapi/c/dev/ppp_zoom_dev.h"
18 #include "ppapi/c/pp_input_event.h" 18 #include "ppapi/c/pp_input_event.h"
19 #include "ppapi/c/pp_instance.h" 19 #include "ppapi/c/pp_instance.h"
20 #include "ppapi/c/pp_rect.h" 20 #include "ppapi/c/pp_rect.h"
21 #include "ppapi/c/pp_resource.h" 21 #include "ppapi/c/pp_resource.h"
22 #include "ppapi/c/pp_var.h" 22 #include "ppapi/c/pp_var.h"
23 #include "ppapi/c/ppb_core.h" 23 #include "ppapi/c/ppb_core.h"
24 #include "ppapi/c/ppb_instance.h" 24 #include "ppapi/c/ppb_instance.h"
25 #include "ppapi/c/ppb_messaging.h" 25 #include "ppapi/c/ppb_messaging.h"
26 #include "ppapi/c/ppp_instance.h" 26 #include "ppapi/c/ppp_instance.h"
27 #include "ppapi/c/ppp_messaging.h" 27 #include "ppapi/c/ppp_messaging.h"
28 #include "ppapi/c/private/ppb_instance_private.h"
29 #include "ppapi/c/private/ppp_instance_private.h"
28 #include "printing/units.h" 30 #include "printing/units.h"
29 #include "skia/ext/platform_canvas.h" 31 #include "skia/ext/platform_canvas.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 208 }
207 209
208 const PPB_Instance ppb_instance = { 210 const PPB_Instance ppb_instance = {
209 &GetWindowObject, 211 &GetWindowObject,
210 &GetOwnerElementObject, 212 &GetOwnerElementObject,
211 &BindGraphics, 213 &BindGraphics,
212 &IsFullFrame, 214 &IsFullFrame,
213 &ExecuteScript, 215 &ExecuteScript,
214 }; 216 };
215 217
218 const PPB_Instance_Private ppb_instance_private = {
219 &GetWindowObject,
220 &GetOwnerElementObject,
221 &ExecuteScript
222 };
223
216 void NumberOfFindResultsChanged(PP_Instance instance_id, 224 void NumberOfFindResultsChanged(PP_Instance instance_id,
217 int32_t total, 225 int32_t total,
218 PP_Bool final_result) { 226 PP_Bool final_result) {
219 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); 227 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
220 if (!instance) 228 if (!instance)
221 return; 229 return;
222 230
223 DCHECK_NE(instance->find_identifier(), -1); 231 DCHECK_NE(instance->find_identifier(), -1);
224 instance->delegate()->NumberOfFindResultsChanged( 232 instance->delegate()->NumberOfFindResultsChanged(
225 instance->find_identifier(), total, PPBoolToBool(final_result)); 233 instance->find_identifier(), total, PPBoolToBool(final_result));
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 const PPB_Fullscreen_Dev* PluginInstance::GetFullscreenInterface() { 406 const PPB_Fullscreen_Dev* PluginInstance::GetFullscreenInterface() {
399 return &ppb_fullscreen; 407 return &ppb_fullscreen;
400 } 408 }
401 409
402 // static 410 // static
403 const PPB_Messaging* PluginInstance::GetMessagingInterface() { 411 const PPB_Messaging* PluginInstance::GetMessagingInterface() {
404 return &ppb_messaging; 412 return &ppb_messaging;
405 } 413 }
406 414
407 // static 415 // static
416 const PPB_Instance_Private* PluginInstance::GetPrivateInterface() {
417 return &ppb_instance_private;
418 }
419
420 // static
408 const PPB_Zoom_Dev* PluginInstance::GetZoomInterface() { 421 const PPB_Zoom_Dev* PluginInstance::GetZoomInterface() {
409 return &ppb_zoom; 422 return &ppb_zoom;
410 } 423 }
411 424
412 // NOTE: Any of these methods that calls into the plugin needs to take into 425 // NOTE: Any of these methods that calls into the plugin needs to take into
413 // account that the plugin may use Var to remove the <embed> from the DOM, which 426 // account that the plugin may use Var to remove the <embed> from the DOM, which
414 // will make the WebPluginImpl drop its reference, usually the last one. If a 427 // will make the WebPluginImpl drop its reference, usually the last one. If a
415 // method needs to access a member of the instance after the call has returned, 428 // method needs to access a member of the instance after the call has returned,
416 // then it needs to keep its own reference on the stack. 429 // then it needs to keep its own reference on the stack.
417 430
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 745
733 void PluginInstance::HandleMessage(PP_Var message) { 746 void PluginInstance::HandleMessage(PP_Var message) {
734 // Keep a reference on the stack. See NOTE above. 747 // Keep a reference on the stack. See NOTE above.
735 scoped_refptr<PluginInstance> ref(this); 748 scoped_refptr<PluginInstance> ref(this);
736 if (!LoadMessagingInterface()) 749 if (!LoadMessagingInterface())
737 return; 750 return;
738 plugin_messaging_interface_->HandleMessage(pp_instance(), message); 751 plugin_messaging_interface_->HandleMessage(pp_instance(), message);
739 } 752 }
740 753
741 PP_Var PluginInstance::GetInstanceObject() { 754 PP_Var PluginInstance::GetInstanceObject() {
755 // Try the private interface first. If it is not supported, we fall back to
756 // the primary PPP_Instance interface.
757 // TODO(dmichael): Remove support for PPP_Instance.GetInstanceObject
758 if (LoadPrivateInterface()) {
759 return plugin_private_interface_->GetInstanceObject(pp_instance());
760 }
742 return instance_interface_->GetInstanceObject(pp_instance()); 761 return instance_interface_->GetInstanceObject(pp_instance());
743 } 762 }
744 763
745 void PluginInstance::ViewChanged(const gfx::Rect& position, 764 void PluginInstance::ViewChanged(const gfx::Rect& position,
746 const gfx::Rect& clip) { 765 const gfx::Rect& clip) {
747 fullscreen_ = (fullscreen_container_ != NULL); 766 fullscreen_ = (fullscreen_container_ != NULL);
748 position_ = position; 767 position_ = position;
749 768
750 if (clip.IsEmpty()) { 769 if (clip.IsEmpty()) {
751 // WebKit can give weird (x,y) positions for empty clip rects (since the 770 // WebKit can give weird (x,y) positions for empty clip rects (since the
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 scoped_refptr<PluginInstance> ref(this); 919 scoped_refptr<PluginInstance> ref(this);
901 if (!LoadFindInterface()) 920 if (!LoadFindInterface())
902 return; 921 return;
903 find_identifier_ = -1; 922 find_identifier_ = -1;
904 plugin_find_interface_->StopFind(pp_instance()); 923 plugin_find_interface_->StopFind(pp_instance());
905 } 924 }
906 925
907 bool PluginInstance::LoadFindInterface() { 926 bool PluginInstance::LoadFindInterface() {
908 if (!plugin_find_interface_) { 927 if (!plugin_find_interface_) {
909 plugin_find_interface_ = 928 plugin_find_interface_ =
910 reinterpret_cast<const PPP_Find_Dev*>(module_->GetPluginInterface( 929 static_cast<const PPP_Find_Dev*>(module_->GetPluginInterface(
911 PPP_FIND_DEV_INTERFACE)); 930 PPP_FIND_DEV_INTERFACE));
912 } 931 }
913 932
914 return !!plugin_find_interface_; 933 return !!plugin_find_interface_;
915 } 934 }
916 935
917 bool PluginInstance::LoadMessagingInterface() { 936 bool PluginInstance::LoadMessagingInterface() {
918 if (!checked_for_plugin_messaging_interface_) { 937 if (!checked_for_plugin_messaging_interface_) {
919 checked_for_plugin_messaging_interface_ = true; 938 checked_for_plugin_messaging_interface_ = true;
920 plugin_messaging_interface_ = 939 plugin_messaging_interface_ =
921 reinterpret_cast<const PPP_Messaging*>(module_->GetPluginInterface( 940 static_cast<const PPP_Messaging*>(module_->GetPluginInterface(
922 PPP_MESSAGING_INTERFACE)); 941 PPP_MESSAGING_INTERFACE));
923 } 942 }
924 943
925 return !!plugin_messaging_interface_; 944 return !!plugin_messaging_interface_;
926 } 945 }
927 946
928 bool PluginInstance::LoadPdfInterface() { 947 bool PluginInstance::LoadPdfInterface() {
929 if (!plugin_pdf_interface_) { 948 if (!plugin_pdf_interface_) {
930 plugin_pdf_interface_ = 949 plugin_pdf_interface_ =
931 reinterpret_cast<const PPP_Pdf*>(module_->GetPluginInterface( 950 static_cast<const PPP_Pdf*>(module_->GetPluginInterface(
932 PPP_PDF_INTERFACE)); 951 PPP_PDF_INTERFACE));
933 } 952 }
934 953
935 return !!plugin_pdf_interface_; 954 return !!plugin_pdf_interface_;
936 } 955 }
937 956
938 bool PluginInstance::LoadSelectionInterface() { 957 bool PluginInstance::LoadSelectionInterface() {
939 if (!plugin_selection_interface_) { 958 if (!plugin_selection_interface_) {
940 plugin_selection_interface_ = 959 plugin_selection_interface_ =
941 reinterpret_cast<const PPP_Selection_Dev*>(module_->GetPluginInterface( 960 static_cast<const PPP_Selection_Dev*>(module_->GetPluginInterface(
942 PPP_SELECTION_DEV_INTERFACE)); 961 PPP_SELECTION_DEV_INTERFACE));
943 } 962 }
944 963
945 return !!plugin_selection_interface_; 964 return !!plugin_selection_interface_;
946 } 965 }
947 966
967 bool PluginInstance::LoadPrivateInterface() {
968 if (!plugin_private_interface_) {
969 plugin_private_interface_ = static_cast<const PPP_Instance_Private*>(
970 module_->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE));
971 }
972
973 return !!plugin_private_interface_;
974 }
975
948 bool PluginInstance::LoadZoomInterface() { 976 bool PluginInstance::LoadZoomInterface() {
949 if (!plugin_zoom_interface_) { 977 if (!plugin_zoom_interface_) {
950 plugin_zoom_interface_ = 978 plugin_zoom_interface_ =
951 reinterpret_cast<const PPP_Zoom_Dev*>(module_->GetPluginInterface( 979 static_cast<const PPP_Zoom_Dev*>(module_->GetPluginInterface(
952 PPP_ZOOM_DEV_INTERFACE)); 980 PPP_ZOOM_DEV_INTERFACE));
953 } 981 }
954 982
955 return !!plugin_zoom_interface_; 983 return !!plugin_zoom_interface_;
956 } 984 }
957 985
958 bool PluginInstance::PluginHasFocus() const { 986 bool PluginInstance::PluginHasFocus() const {
959 return has_webkit_focus_ && has_content_area_focus_; 987 return has_webkit_focus_ && has_content_area_focus_;
960 } 988 }
961 989
962 void PluginInstance::ReportGeometry() { 990 void PluginInstance::ReportGeometry() {
963 // If this call was delayed, we may have transitioned back to fullscreen in 991 // If this call was delayed, we may have transitioned back to fullscreen in
964 // the mean time, so only report the geometry if we are actually in normal 992 // the mean time, so only report the geometry if we are actually in normal
965 // mode. 993 // mode.
966 if (container_ && !fullscreen_container_) 994 if (container_ && !fullscreen_container_)
967 container_->reportGeometry(); 995 container_->reportGeometry();
968 } 996 }
969 997
970 bool PluginInstance::GetPreferredPrintOutputFormat( 998 bool PluginInstance::GetPreferredPrintOutputFormat(
971 PP_PrintOutputFormat_Dev* format) { 999 PP_PrintOutputFormat_Dev* format) {
972 // Keep a reference on the stack. See NOTE above. 1000 // Keep a reference on the stack. See NOTE above.
973 scoped_refptr<PluginInstance> ref(this); 1001 scoped_refptr<PluginInstance> ref(this);
974 if (!plugin_print_interface_) { 1002 if (!plugin_print_interface_) {
975 plugin_print_interface_ = 1003 plugin_print_interface_ =
976 reinterpret_cast<const PPP_Printing_Dev*>(module_->GetPluginInterface( 1004 static_cast<const PPP_Printing_Dev*>(module_->GetPluginInterface(
977 PPP_PRINTING_DEV_INTERFACE)); 1005 PPP_PRINTING_DEV_INTERFACE));
978 } 1006 }
979 if (!plugin_print_interface_) 1007 if (!plugin_print_interface_)
980 return false; 1008 return false;
981 uint32_t format_count = 0; 1009 uint32_t format_count = 0;
982 PP_PrintOutputFormat_Dev* supported_formats = 1010 PP_PrintOutputFormat_Dev* supported_formats =
983 plugin_print_interface_->QuerySupportedFormats(pp_instance(), 1011 plugin_print_interface_->QuerySupportedFormats(pp_instance(),
984 &format_count); 1012 &format_count);
985 if (!supported_formats) 1013 if (!supported_formats)
986 return false; 1014 return false;
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 return found->second; 1493 return found->second;
1466 } 1494 }
1467 1495
1468 bool PluginInstance::IsFullPagePlugin() const { 1496 bool PluginInstance::IsFullPagePlugin() const {
1469 WebFrame* frame = container()->element().document().frame(); 1497 WebFrame* frame = container()->element().document().frame();
1470 return frame->view()->mainFrame()->document().isPluginDocument(); 1498 return frame->view()->mainFrame()->document().isPluginDocument();
1471 } 1499 }
1472 1500
1473 } // namespace ppapi 1501 } // namespace ppapi
1474 } // namespace webkit 1502 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698