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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_impl.cc

Issue 12326168: Move <webview> API to chrome layer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years, 9 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) 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/browser_plugin/browser_plugin_impl.h" 5 #include "content/renderer/browser_plugin/browser_plugin_impl.h"
6 6
7 #include "base/json/json_string_value_serializer.h" 7 #include "base/json/json_string_value_serializer.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 WebKit::WebFrame* frame, 78 WebKit::WebFrame* frame,
79 const WebPluginParams& params) 79 const WebPluginParams& params)
80 : instance_id_(browser_plugin::kInstanceIDNone), 80 : instance_id_(browser_plugin::kInstanceIDNone),
81 render_view_(render_view->AsWeakPtr()), 81 render_view_(render_view->AsWeakPtr()),
82 render_view_routing_id_(render_view->GetRoutingID()), 82 render_view_routing_id_(render_view->GetRoutingID()),
83 container_(NULL), 83 container_(NULL),
84 damage_buffer_sequence_id_(0), 84 damage_buffer_sequence_id_(0),
85 resize_ack_received_(true), 85 resize_ack_received_(true),
86 sad_guest_(NULL), 86 sad_guest_(NULL),
87 guest_crashed_(false), 87 guest_crashed_(false),
88 navigate_src_sent_(false), 88 guest_allocated_(false),
89 auto_size_ack_pending_(false), 89 auto_size_ack_pending_(false),
90 guest_process_id_(-1), 90 guest_process_id_(-1),
91 guest_route_id_(-1), 91 guest_route_id_(-1),
92 persist_storage_(false), 92 persist_storage_(false),
93 valid_partition_id_(true), 93 valid_partition_id_(true),
94 content_window_routing_id_(MSG_ROUTING_NONE), 94 content_window_routing_id_(MSG_ROUTING_NONE),
95 plugin_focused_(false), 95 plugin_focused_(false),
96 visible_(true), 96 visible_(true),
97 size_changed_in_flight_(false), 97 size_changed_in_flight_(false),
98 allocate_instance_id_sent_(false), 98 allocate_instance_id_sent_(false),
99 browser_plugin_manager_(render_view->browser_plugin_manager()), 99 browser_plugin_manager_(render_view->browser_plugin_manager()),
100 current_nav_entry_index_(0), 100 current_nav_entry_index_(0),
101 nav_entry_count_(0), 101 nav_entry_count_(0),
102 compositing_enabled_(false), 102 compositing_enabled_(false),
103 ALLOW_THIS_IN_INITIALIZER_LIST( 103 ALLOW_THIS_IN_INITIALIZER_LIST(
104 weak_ptr_factory_(this)) { 104 weak_ptr_factory_(this)) {
105 GetContentClient()->renderer()->BrowserPluginCreated(this);
106 } 105 }
107 106
108 BrowserPluginImpl::~BrowserPluginImpl() { 107 BrowserPluginImpl::~BrowserPluginImpl() {
109 // If the BrowserPlugin has never navigated then the browser process and 108 // If the BrowserPlugin has never navigated then the browser process and
110 // BrowserPluginManager don't know about it and so there is nothing to do 109 // BrowserPluginManager don't know about it and so there is nothing to do
111 // here. 110 // here.
112 if (!navigate_src_sent_) 111 if (!guest_allocated_)
113 return; 112 return;
114 browser_plugin_manager()->RemoveBrowserPlugin(instance_id_); 113 browser_plugin_manager()->RemoveBrowserPlugin(instance_id_);
115 browser_plugin_manager()->Send( 114 browser_plugin_manager()->Send(
116 new BrowserPluginHostMsg_PluginDestroyed(render_view_routing_id_, 115 new BrowserPluginHostMsg_PluginDestroyed(render_view_routing_id_,
117 instance_id_)); 116 instance_id_));
118 } 117 }
119 118
120 void BrowserPluginImpl::AddObserver(BrowserPluginObserver* observer) { 119 void BrowserPluginImpl::AddObserver(BrowserPluginObserver* observer) {
121 observers_.AddObserver(observer); 120 observers_.AddObserver(observer);
122 } 121 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 min_width = min_width ? min_width : width(); 217 min_width = min_width ? min_width : width();
219 // For autosize, minWidth should not be bigger than maxWidth. 218 // For autosize, minWidth should not be bigger than maxWidth.
220 return std::min(min_width, GetAdjustedMaxWidth()); 219 return std::min(min_width, GetAdjustedMaxWidth());
221 } 220 }
222 221
223 std::string BrowserPluginImpl::GetPartitionAttribute() const { 222 std::string BrowserPluginImpl::GetPartitionAttribute() const {
224 return GetDOMAttributeValue(browser_plugin::kAttributePartition); 223 return GetDOMAttributeValue(browser_plugin::kAttributePartition);
225 } 224 }
226 225
227 void BrowserPluginImpl::ParseNameAttribute() { 226 void BrowserPluginImpl::ParseNameAttribute() {
228 if (!navigate_src_sent_) 227 if (!guest_allocated_)
229 return; 228 return;
230 browser_plugin_manager()->Send( 229 browser_plugin_manager()->Send(
231 new BrowserPluginHostMsg_SetName(render_view_routing_id_, 230 new BrowserPluginHostMsg_SetName(render_view_routing_id_,
232 instance_id_, 231 instance_id_,
233 GetNameAttribute())); 232 GetNameAttribute()));
234 } 233 }
235 234
236 bool BrowserPluginImpl::ParseSrcAttribute(std::string* error_message) { 235 bool BrowserPluginImpl::ParseSrcAttribute(std::string* error_message) {
237 if (!valid_partition_id_) { 236 if (!valid_partition_id_) {
238 *error_message = browser_plugin::kErrorInvalidPartition; 237 *error_message = browser_plugin::kErrorInvalidPartition;
239 return false; 238 return false;
240 } 239 }
241 std::string src = GetSrcAttribute(); 240 std::string src = GetSrcAttribute();
242 if (src.empty()) 241 if (src.empty())
243 return true; 242 return true;
244 243
245 // If we haven't created the guest yet, do so now. We will navigate it right 244 // If we haven't created the guest yet, do so now. We will navigate it right
246 // after creation. If |src| is empty, we can delay the creation until we 245 // after creation. If |src| is empty, we can delay the creation until we
247 // actually need it. 246 // actually need it.
248 if (!navigate_src_sent_) { 247 if (!guest_allocated_) {
249 // On initial navigation, we request an instance ID from the browser 248 // On initial navigation, we request an instance ID from the browser
250 // process. We essentially ignore all subsequent calls to SetSrcAttribute 249 // process. We essentially ignore all subsequent calls to SetSrcAttribute
251 // until we receive an instance ID. |allocate_instance_id_sent_| 250 // until we receive an instance ID. |allocate_instance_id_sent_|
252 // prevents BrowserPlugin from allocating more than one instance ID. 251 // prevents BrowserPlugin from allocating more than one instance ID.
253 // Upon receiving an instance ID from the browser process, we continue 252 // Upon receiving an instance ID from the browser process, we continue
254 // the process of navigation by populating the 253 // the process of navigation by populating the
255 // BrowserPluginHostMsg_CreateGuest_Params with the current state of 254 // BrowserPluginHostMsg_CreateGuest_Params with the current state of
256 // BrowserPlugin and sending a BrowserPluginHostMsg_CreateGuest to the 255 // BrowserPlugin and sending a BrowserPluginHostMsg_CreateGuest to the
257 // browser process in order to create a new guest. 256 // browser process in order to create a new guest.
258 if (!allocate_instance_id_sent_) { 257 if (!allocate_instance_id_sent_) {
(...skipping 23 matching lines...) Expand all
282 if (current_auto_size) { 281 if (current_auto_size) {
283 params->max_size = gfx::Size(GetAdjustedMaxWidth(), GetAdjustedMaxHeight()); 282 params->max_size = gfx::Size(GetAdjustedMaxWidth(), GetAdjustedMaxHeight());
284 params->min_size = gfx::Size(GetAdjustedMinWidth(), GetAdjustedMinHeight()); 283 params->min_size = gfx::Size(GetAdjustedMinWidth(), GetAdjustedMinHeight());
285 } 284 }
286 } 285 }
287 286
288 void BrowserPluginImpl::UpdateGuestAutoSizeState(bool current_auto_size) { 287 void BrowserPluginImpl::UpdateGuestAutoSizeState(bool current_auto_size) {
289 // If we haven't yet heard back from the guest about the last resize request, 288 // If we haven't yet heard back from the guest about the last resize request,
290 // then we don't issue another request until we do in 289 // then we don't issue another request until we do in
291 // BrowserPluginImpl::UpdateRect. 290 // BrowserPluginImpl::UpdateRect.
292 if (!navigate_src_sent_ || !resize_ack_received_) 291 if (!guest_allocated_ || !resize_ack_received_)
293 return; 292 return;
294 BrowserPluginHostMsg_AutoSize_Params auto_size_params; 293 BrowserPluginHostMsg_AutoSize_Params auto_size_params;
295 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params; 294 BrowserPluginHostMsg_ResizeGuest_Params resize_guest_params;
296 if (current_auto_size) { 295 if (current_auto_size) {
297 GetDamageBufferWithSizeParams(&auto_size_params, &resize_guest_params); 296 GetDamageBufferWithSizeParams(&auto_size_params, &resize_guest_params);
298 } else { 297 } else {
299 GetDamageBufferWithSizeParams(NULL, &resize_guest_params); 298 GetDamageBufferWithSizeParams(NULL, &resize_guest_params);
300 } 299 }
301 resize_ack_received_ = false; 300 resize_ack_received_ = false;
302 browser_plugin_manager()->Send( 301 browser_plugin_manager()->Send(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 GetDamageBufferWithSizeParams(&create_guest_params.auto_size_params, 349 GetDamageBufferWithSizeParams(&create_guest_params.auto_size_params,
351 &create_guest_params.resize_guest_params); 350 &create_guest_params.resize_guest_params);
352 browser_plugin_manager()->Send( 351 browser_plugin_manager()->Send(
353 new BrowserPluginHostMsg_CreateGuest(render_view_routing_id_, 352 new BrowserPluginHostMsg_CreateGuest(render_view_routing_id_,
354 instance_id_, 353 instance_id_,
355 create_guest_params)); 354 create_guest_params));
356 355
357 // Record that we sent a navigation request to the browser process. 356 // Record that we sent a navigation request to the browser process.
358 // Once this instance has navigated, the storage partition cannot be changed, 357 // Once this instance has navigated, the storage partition cannot be changed,
359 // so this value is used for enforcing this. 358 // so this value is used for enforcing this.
360 navigate_src_sent_ = true; 359 guest_allocated_ = true;
361 } 360 }
362 361
363 void BrowserPluginImpl::OnAdvanceFocus(int instance_id, bool reverse) { 362 void BrowserPluginImpl::OnAdvanceFocus(int instance_id, bool reverse) {
364 DCHECK(render_view_); 363 DCHECK(render_view_);
365 render_view_->GetWebView()->advanceFocus(reverse); 364 render_view_->GetWebView()->advanceFocus(reverse);
366 } 365 }
367 366
368 void BrowserPluginImpl::OnBuffersSwapped(int instance_id, 367 void BrowserPluginImpl::OnBuffersSwapped(int instance_id,
369 const gfx::Size& size, 368 const gfx::Size& size,
370 std::string mailbox_name, 369 std::string mailbox_name,
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 persist_storage_ = false; 761 persist_storage_ = false;
763 } 762 }
764 763
765 valid_partition_id_ = true; 764 valid_partition_id_ = true;
766 storage_partition_id_ = input; 765 storage_partition_id_ = input;
767 return true; 766 return true;
768 } 767 }
769 768
770 bool BrowserPluginImpl::CanRemovePartitionAttribute( 769 bool BrowserPluginImpl::CanRemovePartitionAttribute(
771 std::string* error_message) { 770 std::string* error_message) {
772 if (navigate_src_sent_) 771 if (guest_allocated_)
773 *error_message = browser_plugin::kErrorCannotRemovePartition; 772 *error_message = browser_plugin::kErrorCannotRemovePartition;
774 return !navigate_src_sent_; 773 return !guest_allocated_;
775 } 774 }
776 775
777 void BrowserPluginImpl::ParseAttributes() { 776 void BrowserPluginImpl::ParseAttributes() {
778 // TODO(mthiesse): Handle errors here? 777 // TODO(mthiesse): Handle errors here?
779 std::string error; 778 std::string error;
780 ParsePartitionAttribute(&error); 779 ParsePartitionAttribute(&error);
781 780
782 // Parse the 'src' attribute last, as it will set the has_navigated_ flag to 781 // Parse the 'src' attribute last, as it will set the has_navigated_ flag to
783 // true, which prevents changing the 'partition' attribute. 782 // true, which prevents changing the 'partition' attribute.
784 ParseSrcAttribute(&error); 783 ParseSrcAttribute(&error);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 // Asynchronously remove item from |alive_v8_permission_request_objects_|. 843 // Asynchronously remove item from |alive_v8_permission_request_objects_|.
845 // Note that we are using weak pointer for the following PostTask, so we 844 // Note that we are using weak pointer for the following PostTask, so we
846 // don't need to worry about BrowserPlugin going away. 845 // don't need to worry about BrowserPlugin going away.
847 MessageLoop::current()->PostTask( 846 MessageLoop::current()->PostTask(
848 FROM_HERE, 847 FROM_HERE,
849 base::Bind(&BrowserPluginImpl::OnRequestObjectGarbageCollected, 848 base::Bind(&BrowserPluginImpl::OnRequestObjectGarbageCollected,
850 plugin, request_id)); 849 plugin, request_id));
851 } 850 }
852 } 851 }
853 852
854 void BrowserPluginImpl::Back() {
855 if (!navigate_src_sent_)
856 return;
857 browser_plugin_manager()->Send(
858 new BrowserPluginHostMsg_Go(render_view_routing_id_,
859 instance_id_, -1));
860 }
861
862 void BrowserPluginImpl::Forward() {
863 if (!navigate_src_sent_)
864 return;
865 browser_plugin_manager()->Send(
866 new BrowserPluginHostMsg_Go(render_view_routing_id_,
867 instance_id_, 1));
868 }
869
870 void BrowserPluginImpl::Go(int relative_index) {
871 if (!navigate_src_sent_)
872 return;
873 browser_plugin_manager()->Send(
874 new BrowserPluginHostMsg_Go(render_view_routing_id_,
875 instance_id_,
876 relative_index));
877 }
878
879 void BrowserPluginImpl::TerminateGuest() { 853 void BrowserPluginImpl::TerminateGuest() {
880 if (!navigate_src_sent_ || guest_crashed_) 854 if (!guest_allocated_ || guest_crashed_)
881 return; 855 return;
882 browser_plugin_manager()->Send( 856 browser_plugin_manager()->Send(
883 new BrowserPluginHostMsg_TerminateGuest(render_view_routing_id_, 857 new BrowserPluginHostMsg_TerminateGuest(render_view_routing_id_,
884 instance_id_)); 858 instance_id_));
885 } 859 }
886 860
887 void BrowserPluginImpl::Stop() { 861 void BrowserPluginImpl::Stop() {
888 if (!navigate_src_sent_) 862 if (!guest_allocated_)
889 return; 863 return;
890 browser_plugin_manager()->Send( 864 browser_plugin_manager()->Send(
891 new BrowserPluginHostMsg_Stop(render_view_routing_id_, 865 new BrowserPluginHostMsg_Stop(render_view_routing_id_,
892 instance_id_)); 866 instance_id_));
893 } 867 }
894 868
895 void BrowserPluginImpl::Reload() { 869 void BrowserPluginImpl::Reload() {
896 if (!navigate_src_sent_) 870 if (!guest_allocated_)
897 return; 871 return;
898 browser_plugin_manager()->Send( 872 browser_plugin_manager()->Send(
899 new BrowserPluginHostMsg_Reload(render_view_routing_id_, 873 new BrowserPluginHostMsg_Reload(render_view_routing_id_,
900 instance_id_)); 874 instance_id_));
901 } 875 }
902 876
903 void BrowserPluginImpl::UpdateGuestFocusState() { 877 void BrowserPluginImpl::UpdateGuestFocusState() {
904 if (!navigate_src_sent_) 878 if (!guest_allocated_)
905 return; 879 return;
906 bool should_be_focused = ShouldGuestBeFocused(); 880 bool should_be_focused = ShouldGuestBeFocused();
907 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetFocus( 881 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetFocus(
908 render_view_routing_id_, 882 render_view_routing_id_,
909 instance_id_, 883 instance_id_,
910 should_be_focused)); 884 should_be_focused));
911 } 885 }
912 886
913 bool BrowserPluginImpl::ShouldGuestBeFocused() const { 887 bool BrowserPluginImpl::ShouldGuestBeFocused() const {
914 bool embedder_focused = false; 888 bool embedder_focused = false;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 if (!container) 933 if (!container)
960 return false; 934 return false;
961 935
962 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container)) 936 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container))
963 return false; 937 return false;
964 938
965 bindings_.reset(new BrowserPluginBindings(this)); 939 bindings_.reset(new BrowserPluginBindings(this));
966 container_ = container; 940 container_ = container;
967 container_->setWantsWheelEvents(true); 941 container_->setWantsWheelEvents(true);
968 ParseAttributes(); 942 ParseAttributes();
943 GetContentClient()->renderer()->BrowserPluginCreated(this);
969 return true; 944 return true;
970 } 945 }
971 946
972 void BrowserPluginImpl::EnableCompositing(bool enable) { 947 void BrowserPluginImpl::EnableCompositing(bool enable) {
973 if (compositing_enabled_ == enable) 948 if (compositing_enabled_ == enable)
974 return; 949 return;
975 950
976 compositing_enabled_ = enable; 951 compositing_enabled_ = enable;
977 if (enable) { 952 if (enable) {
978 // No need to keep the backing store and damage buffer around if we're now 953 // No need to keep the backing store and damage buffer around if we're now
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 SkIntToScalar(plugin_rect_.height())); 1032 SkIntToScalar(plugin_rect_.height()));
1058 canvas->clipRect(image_data_rect); 1033 canvas->clipRect(image_data_rect);
1059 // Paint black or white in case we have nothing in our backing store or we 1034 // Paint black or white in case we have nothing in our backing store or we
1060 // need to show a gutter. 1035 // need to show a gutter.
1061 SkPaint paint; 1036 SkPaint paint;
1062 paint.setStyle(SkPaint::kFill_Style); 1037 paint.setStyle(SkPaint::kFill_Style);
1063 paint.setColor(guest_crashed_ ? SK_ColorBLACK : SK_ColorWHITE); 1038 paint.setColor(guest_crashed_ ? SK_ColorBLACK : SK_ColorWHITE);
1064 canvas->drawRect(image_data_rect, paint); 1039 canvas->drawRect(image_data_rect, paint);
1065 // Stay a solid color if we have never set a non-empty src, or we don't have a 1040 // Stay a solid color if we have never set a non-empty src, or we don't have a
1066 // backing store. 1041 // backing store.
1067 if (!backing_store_.get() || !navigate_src_sent_) 1042 if (!backing_store_.get() || !guest_allocated_)
1068 return; 1043 return;
1069 float inverse_scale_factor = 1.0f / backing_store_->GetScaleFactor(); 1044 float inverse_scale_factor = 1.0f / backing_store_->GetScaleFactor();
1070 canvas->scale(inverse_scale_factor, inverse_scale_factor); 1045 canvas->scale(inverse_scale_factor, inverse_scale_factor);
1071 canvas->drawBitmap(backing_store_->GetBitmap(), 0, 0); 1046 canvas->drawBitmap(backing_store_->GetBitmap(), 0, 0);
1072 } 1047 }
1073 1048
1074 bool BrowserPluginImpl::InBounds(const gfx::Point& position) const { 1049 bool BrowserPluginImpl::InBounds(const gfx::Point& position) const {
1075 // Note that even for plugins that are rotated using rotate transformations, 1050 // Note that even for plugins that are rotated using rotate transformations,
1076 // we use the the |plugin_rect_| provided by updateGeometry, which means we 1051 // we use the the |plugin_rect_| provided by updateGeometry, which means we
1077 // will be off if |position| is within the plugin rect but does not fall 1052 // will be off if |position| is within the plugin rect but does not fall
1078 // within the actual plugin boundary. Not supporting such edge case is OK 1053 // within the actual plugin boundary. Not supporting such edge case is OK
1079 // since this function should not be used for making security-sensitive 1054 // since this function should not be used for making security-sensitive
1080 // decisions. 1055 // decisions.
1081 // This also does not take overlapping plugins into account. 1056 // This also does not take overlapping plugins into account.
1082 bool result = position.x() >= plugin_rect_.x() && 1057 bool result = position.x() >= plugin_rect_.x() &&
1083 position.x() < plugin_rect_.x() + plugin_rect_.width() && 1058 position.x() < plugin_rect_.x() + plugin_rect_.width() &&
1084 position.y() >= plugin_rect_.y() && 1059 position.y() >= plugin_rect_.y() &&
1085 position.y() < plugin_rect_.y() + plugin_rect_.height(); 1060 position.y() < plugin_rect_.y() + plugin_rect_.height();
1086 return result; 1061 return result;
1087 } 1062 }
1088 1063
1089 RenderView* BrowserPluginImpl::GetRenderView() const {
1090 return render_view_.get();
1091 }
1092
1093 WebKit::WebPluginContainer* BrowserPluginImpl::GetContainer() const {
1094 return container();
1095 }
1096
1097 void BrowserPluginImpl::AddMethodBinding( 1064 void BrowserPluginImpl::AddMethodBinding(
1098 BrowserPluginMethodBinding* method_binding) { 1065 BrowserPluginMethodBinding* method_binding) {
1099 bindings_->AddMethodBinding(method_binding); 1066 bindings_->AddMethodBinding(method_binding);
1100 } 1067 }
1101 1068
1102 void BrowserPluginImpl::AddPropertyBinding( 1069 void BrowserPluginImpl::AddPropertyBinding(
1103 BrowserPluginPropertyBinding* method_binding) { 1070 BrowserPluginPropertyBinding* method_binding) {
1104 bindings_->AddPropertyBinding(method_binding); 1071 bindings_->AddPropertyBinding(method_binding);
1105 } 1072 }
1106 1073
1074 RenderView* BrowserPluginImpl::GetRenderView() const {
1075 return render_view_.get();
1076 }
1077
1078 int BrowserPluginImpl::GetRoutingID() const {
1079 return render_view_routing_id_;
1080 }
1081
1082 WebKit::WebPluginContainer* BrowserPluginImpl::GetContainer() const {
1083 return container();
1084 }
1085
1107 void BrowserPluginImpl::TriggerEvent( 1086 void BrowserPluginImpl::TriggerEvent(
1108 const std::string& event_name, 1087 const std::string& event_name,
1109 std::map<std::string, base::Value*>* props) { 1088 std::map<std::string, base::Value*>* props) {
1110 if (!container() || !container()->element().document().frame()) 1089 if (!container() || !container()->element().document().frame())
1111 return; 1090 return;
1112 v8::HandleScope handle_scope; 1091 v8::HandleScope handle_scope;
1113 std::string json_string; 1092 std::string json_string;
1114 if (props) { 1093 if (props) {
1115 base::DictionaryValue dict; 1094 base::DictionaryValue dict;
1116 for (std::map<std::string, base::Value*>::iterator iter = props->begin(), 1095 for (std::map<std::string, base::Value*>::iterator iter = props->begin(),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 1152
1174 bool BrowserPluginImpl::HasDOMAttribute( 1153 bool BrowserPluginImpl::HasDOMAttribute(
1175 const std::string& attribute_name) const { 1154 const std::string& attribute_name) const {
1176 if (!container()) 1155 if (!container())
1177 return false; 1156 return false;
1178 1157
1179 return container()->element().hasAttribute( 1158 return container()->element().hasAttribute(
1180 WebKit::WebString::fromUTF8(attribute_name)); 1159 WebKit::WebString::fromUTF8(attribute_name));
1181 } 1160 }
1182 1161
1183 bool BrowserPluginImpl::HasNavigated() const { 1162 bool BrowserPluginImpl::HasGuest() const {
1184 return navigate_src_sent_; 1163 return guest_allocated_;
1185 } 1164 }
1186 1165
1187 bool BrowserPluginImpl::Send(IPC::Message* message) { 1166 bool BrowserPluginImpl::Send(IPC::Message* message) {
1188 IPC::Message* wrapper_msg = 1167 IPC::Message* wrapper_msg =
1189 new BrowserPluginHostMsg_ForwardMessage( 1168 new BrowserPluginHostMsg_ForwardMessage(
1190 render_view_routing_id_, instance_id_, *message); 1169 render_view_routing_id_, instance_id_, *message);
1191 delete message; 1170 delete message;
1192 return browser_plugin_manager()->Send(wrapper_msg); 1171 return browser_plugin_manager()->Send(wrapper_msg);
1193 } 1172 }
1194 1173
(...skipping 11 matching lines...) Expand all
1206 bool is_visible) { 1185 bool is_visible) {
1207 int old_width = width(); 1186 int old_width = width();
1208 int old_height = height(); 1187 int old_height = height();
1209 plugin_rect_ = window_rect; 1188 plugin_rect_ = window_rect;
1210 // In AutoSize mode, guests don't care when the BrowserPlugin container is 1189 // In AutoSize mode, guests don't care when the BrowserPlugin container is
1211 // resized. If |!resize_ack_received_|, then we are still waiting on a 1190 // resized. If |!resize_ack_received_|, then we are still waiting on a
1212 // previous resize to be ACK'ed and so we don't issue additional resizes 1191 // previous resize to be ACK'ed and so we don't issue additional resizes
1213 // until the previous one is ACK'ed. 1192 // until the previous one is ACK'ed.
1214 // TODO(mthiesse): Assess the performance of calling GetAutoSizeAttribute() on 1193 // TODO(mthiesse): Assess the performance of calling GetAutoSizeAttribute() on
1215 // resize. 1194 // resize.
1216 if (!navigate_src_sent_ || 1195 if (!guest_allocated_ ||
1217 !resize_ack_received_ || 1196 !resize_ack_received_ ||
1218 (old_width == window_rect.width && old_height == window_rect.height) || 1197 (old_width == window_rect.width && old_height == window_rect.height) ||
1219 GetAutoSizeAttribute()) { 1198 GetAutoSizeAttribute()) {
1220 return; 1199 return;
1221 } 1200 }
1222 1201
1223 BrowserPluginHostMsg_ResizeGuest_Params params; 1202 BrowserPluginHostMsg_ResizeGuest_Params params;
1224 PopulateResizeGuestParameters(&params, gfx::Size(width(), height())); 1203 PopulateResizeGuestParameters(&params, gfx::Size(width(), height()));
1225 resize_ack_received_ = false; 1204 resize_ack_received_ = false;
1226 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( 1205 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest(
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 1303
1325 if (ShouldGuestBeFocused() != old_guest_focus_state) 1304 if (ShouldGuestBeFocused() != old_guest_focus_state)
1326 UpdateGuestFocusState(); 1305 UpdateGuestFocusState();
1327 } 1306 }
1328 1307
1329 void BrowserPluginImpl::updateVisibility(bool visible) { 1308 void BrowserPluginImpl::updateVisibility(bool visible) {
1330 if (visible_ == visible) 1309 if (visible_ == visible)
1331 return; 1310 return;
1332 1311
1333 visible_ = visible; 1312 visible_ = visible;
1334 if (!navigate_src_sent_) 1313 if (!guest_allocated_)
1335 return; 1314 return;
1336 1315
1337 if (compositing_helper_) 1316 if (compositing_helper_)
1338 compositing_helper_->UpdateVisibility(visible); 1317 compositing_helper_->UpdateVisibility(visible);
1339 1318
1340 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetVisibility( 1319 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetVisibility(
1341 render_view_routing_id_, 1320 render_view_routing_id_,
1342 instance_id_, 1321 instance_id_,
1343 visible)); 1322 visible));
1344 } 1323 }
1345 1324
1346 bool BrowserPluginImpl::acceptsInputEvents() { 1325 bool BrowserPluginImpl::acceptsInputEvents() {
1347 return true; 1326 return true;
1348 } 1327 }
1349 1328
1350 bool BrowserPluginImpl::handleInputEvent(const WebKit::WebInputEvent& event, 1329 bool BrowserPluginImpl::handleInputEvent(const WebKit::WebInputEvent& event,
1351 WebKit::WebCursorInfo& cursor_info) { 1330 WebKit::WebCursorInfo& cursor_info) {
1352 if (guest_crashed_ || !navigate_src_sent_ || 1331 if (guest_crashed_ || !guest_allocated_ ||
1353 event.type == WebKit::WebInputEvent::ContextMenu) 1332 event.type == WebKit::WebInputEvent::ContextMenu)
1354 return false; 1333 return false;
1355 browser_plugin_manager()->Send( 1334 browser_plugin_manager()->Send(
1356 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 1335 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
1357 instance_id_, 1336 instance_id_,
1358 plugin_rect_, 1337 plugin_rect_,
1359 &event)); 1338 &event));
1360 cursor_.GetCursorInfo(&cursor_info); 1339 cursor_.GetCursorInfo(&cursor_info);
1361 return true; 1340 return true;
1362 } 1341 }
1363 1342
1364 bool BrowserPluginImpl::handleDragStatusUpdate( 1343 bool BrowserPluginImpl::handleDragStatusUpdate(
1365 WebKit::WebDragStatus drag_status, 1344 WebKit::WebDragStatus drag_status,
1366 const WebKit::WebDragData& drag_data, 1345 const WebKit::WebDragData& drag_data,
1367 WebKit::WebDragOperationsMask mask, 1346 WebKit::WebDragOperationsMask mask,
1368 const WebKit::WebPoint& position, 1347 const WebKit::WebPoint& position,
1369 const WebKit::WebPoint& screen) { 1348 const WebKit::WebPoint& screen) {
1370 if (guest_crashed_ || !navigate_src_sent_) 1349 if (guest_crashed_ || !guest_allocated_)
1371 return false; 1350 return false;
1372 browser_plugin_manager()->Send(new BrowserPluginHostMsg_DragStatusUpdate( 1351 browser_plugin_manager()->Send(new BrowserPluginHostMsg_DragStatusUpdate(
1373 render_view_routing_id_, 1352 render_view_routing_id_,
1374 instance_id_, 1353 instance_id_,
1375 drag_status, 1354 drag_status,
1376 WebDropData(drag_data), 1355 WebDropData(drag_data),
1377 mask, 1356 mask,
1378 position)); 1357 position));
1379 return false; 1358 return false;
1380 } 1359 }
(...skipping 15 matching lines...) Expand all
1396 void* notify_data) { 1375 void* notify_data) {
1397 } 1376 }
1398 1377
1399 void BrowserPluginImpl::didFailLoadingFrameRequest( 1378 void BrowserPluginImpl::didFailLoadingFrameRequest(
1400 const WebKit::WebURL& url, 1379 const WebKit::WebURL& url,
1401 void* notify_data, 1380 void* notify_data,
1402 const WebKit::WebURLError& error) { 1381 const WebKit::WebURLError& error) {
1403 } 1382 }
1404 1383
1405 } // namespace content 1384 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin_impl.h ('k') | content/renderer/browser_plugin/browser_plugin_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698