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

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

Issue 291483010: <webview>: Move name attribute to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@newwindow_refactor
Patch Set: Addressed John's comments Created 6 years, 7 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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.h" 5 #include "content/renderer/browser_plugin/browser_plugin.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 OnCompositorFrameSwapped(message)) 110 OnCompositorFrameSwapped(message))
111 IPC_MESSAGE_HANDLER(BrowserPluginMsg_CopyFromCompositingSurface, 111 IPC_MESSAGE_HANDLER(BrowserPluginMsg_CopyFromCompositingSurface,
112 OnCopyFromCompositingSurface) 112 OnCopyFromCompositingSurface)
113 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady, 113 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestContentWindowReady,
114 OnGuestContentWindowReady) 114 OnGuestContentWindowReady)
115 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone) 115 IPC_MESSAGE_HANDLER(BrowserPluginMsg_GuestGone, OnGuestGone)
116 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor) 116 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetCursor, OnSetCursor)
117 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock) 117 IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock)
118 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, 118 IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents,
119 OnShouldAcceptTouchEvents) 119 OnShouldAcceptTouchEvents)
120 IPC_MESSAGE_HANDLER(BrowserPluginMsg_UpdatedName, OnUpdatedName)
121 IPC_MESSAGE_HANDLER(BrowserPluginMsg_UpdateRect, OnUpdateRect) 120 IPC_MESSAGE_HANDLER(BrowserPluginMsg_UpdateRect, OnUpdateRect)
122 IPC_MESSAGE_UNHANDLED(handled = false) 121 IPC_MESSAGE_UNHANDLED(handled = false)
123 IPC_END_MESSAGE_MAP() 122 IPC_END_MESSAGE_MAP()
124 return handled; 123 return handled;
125 } 124 }
126 125
127 void BrowserPlugin::UpdateDOMAttribute(const std::string& attribute_name, 126 void BrowserPlugin::UpdateDOMAttribute(const std::string& attribute_name,
128 const std::string& attribute_value) { 127 const std::string& attribute_value) {
129 if (!container()) 128 if (!container())
130 return; 129 return;
(...skipping 27 matching lines...) Expand all
158 } 157 }
159 158
160 bool BrowserPlugin::HasDOMAttribute(const std::string& attribute_name) const { 159 bool BrowserPlugin::HasDOMAttribute(const std::string& attribute_name) const {
161 if (!container()) 160 if (!container())
162 return false; 161 return false;
163 162
164 return container()->element().hasAttribute( 163 return container()->element().hasAttribute(
165 blink::WebString::fromUTF8(attribute_name)); 164 blink::WebString::fromUTF8(attribute_name));
166 } 165 }
167 166
168 std::string BrowserPlugin::GetNameAttribute() const {
169 return GetDOMAttributeValue(browser_plugin::kAttributeName);
170 }
171
172 bool BrowserPlugin::GetAllowTransparencyAttribute() const { 167 bool BrowserPlugin::GetAllowTransparencyAttribute() const {
173 return HasDOMAttribute(browser_plugin::kAttributeAllowTransparency); 168 return HasDOMAttribute(browser_plugin::kAttributeAllowTransparency);
174 } 169 }
175 170
176 std::string BrowserPlugin::GetSrcAttribute() const { 171 std::string BrowserPlugin::GetSrcAttribute() const {
177 return GetDOMAttributeValue(browser_plugin::kAttributeSrc); 172 return GetDOMAttributeValue(browser_plugin::kAttributeSrc);
178 } 173 }
179 174
180 bool BrowserPlugin::GetAutoSizeAttribute() const { 175 bool BrowserPlugin::GetAutoSizeAttribute() const {
181 return HasDOMAttribute(browser_plugin::kAttributeAutoSize); 176 return HasDOMAttribute(browser_plugin::kAttributeAutoSize);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // unset (or set to 0), we set it to the container size. 229 // unset (or set to 0), we set it to the container size.
235 min_width = min_width ? min_width : width(); 230 min_width = min_width ? min_width : width();
236 // For autosize, minWidth should not be bigger than maxWidth. 231 // For autosize, minWidth should not be bigger than maxWidth.
237 return std::min(min_width, GetAdjustedMaxWidth()); 232 return std::min(min_width, GetAdjustedMaxWidth());
238 } 233 }
239 234
240 std::string BrowserPlugin::GetPartitionAttribute() const { 235 std::string BrowserPlugin::GetPartitionAttribute() const {
241 return GetDOMAttributeValue(browser_plugin::kAttributePartition); 236 return GetDOMAttributeValue(browser_plugin::kAttributePartition);
242 } 237 }
243 238
244 void BrowserPlugin::ParseNameAttribute() {
245 if (!HasGuestInstanceID())
246 return;
247 browser_plugin_manager()->Send(
248 new BrowserPluginHostMsg_SetName(render_view_routing_id_,
249 guest_instance_id_,
250 GetNameAttribute()));
251 }
252
253 void BrowserPlugin::ParseAllowTransparencyAttribute() { 239 void BrowserPlugin::ParseAllowTransparencyAttribute() {
254 if (!HasGuestInstanceID()) 240 if (!HasGuestInstanceID())
255 return; 241 return;
256 242
257 bool opaque = !GetAllowTransparencyAttribute(); 243 bool opaque = !GetAllowTransparencyAttribute();
258 244
259 if (compositing_helper_) 245 if (compositing_helper_)
260 compositing_helper_->SetContentsOpaque(opaque); 246 compositing_helper_->SetContentsOpaque(opaque);
261 247
262 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetContentsOpaque( 248 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetContentsOpaque(
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 // This API may be called directly without setting the src attribute. 359 // This API may be called directly without setting the src attribute.
374 // In that case, we need to make sure we don't allocate another instance ID. 360 // In that case, we need to make sure we don't allocate another instance ID.
375 before_first_navigation_ = false; 361 before_first_navigation_ = false;
376 guest_instance_id_ = guest_instance_id; 362 guest_instance_id_ = guest_instance_id;
377 browser_plugin_manager()->AddBrowserPlugin(guest_instance_id, this); 363 browser_plugin_manager()->AddBrowserPlugin(guest_instance_id, this);
378 364
379 BrowserPluginHostMsg_Attach_Params attach_params; 365 BrowserPluginHostMsg_Attach_Params attach_params;
380 attach_params.focused = ShouldGuestBeFocused(); 366 attach_params.focused = ShouldGuestBeFocused();
381 attach_params.visible = visible_; 367 attach_params.visible = visible_;
382 attach_params.opaque = !GetAllowTransparencyAttribute(); 368 attach_params.opaque = !GetAllowTransparencyAttribute();
383 attach_params.name = GetNameAttribute();
384 attach_params.storage_partition_id = storage_partition_id_; 369 attach_params.storage_partition_id = storage_partition_id_;
385 attach_params.persist_storage = persist_storage_; 370 attach_params.persist_storage = persist_storage_;
386 attach_params.src = GetSrcAttribute(); 371 attach_params.src = GetSrcAttribute();
387 attach_params.embedder_frame_url = embedder_frame_url_; 372 attach_params.embedder_frame_url = embedder_frame_url_;
388 GetSizeParams(&attach_params.auto_size_params, 373 GetSizeParams(&attach_params.auto_size_params,
389 &attach_params.resize_guest_params, 374 &attach_params.resize_guest_params,
390 false); 375 false);
391 376
392 browser_plugin_manager()->Send( 377 browser_plugin_manager()->Send(
393 new BrowserPluginHostMsg_Attach(render_view_routing_id_, 378 new BrowserPluginHostMsg_Attach(render_view_routing_id_,
394 guest_instance_id_, attach_params, 379 guest_instance_id_, attach_params,
395 *extra_params)); 380 *extra_params));
396 } 381 }
397 382
398 void BrowserPlugin::DidCommitCompositorFrame() { 383 void BrowserPlugin::DidCommitCompositorFrame() {
399 if (compositing_helper_.get()) 384 if (compositing_helper_.get())
400 compositing_helper_->DidCommitCompositorFrame(); 385 compositing_helper_->DidCommitCompositorFrame();
401 } 386 }
402 387
403 void BrowserPlugin::OnAdvanceFocus(int guest_instance_id, bool reverse) { 388 void BrowserPlugin::OnAdvanceFocus(int guest_instance_id, bool reverse) {
404 DCHECK(render_view_.get()); 389 DCHECK(render_view_.get());
405 render_view_->GetWebView()->advanceFocus(reverse); 390 render_view_->GetWebView()->advanceFocus(reverse);
406 } 391 }
407 392
408 void BrowserPlugin::OnAttachACK( 393 void BrowserPlugin::OnAttachACK(
409 int guest_instance_id, 394 int guest_instance_id,
410 const BrowserPluginMsg_Attach_ACK_Params& params) { 395 const BrowserPluginMsg_Attach_ACK_Params& params) {
411 // Update BrowserPlugin attributes to match the state of the guest.
412 if (!params.name.empty())
413 OnUpdatedName(guest_instance_id, params.name);
414 if (!params.storage_partition_id.empty()) { 396 if (!params.storage_partition_id.empty()) {
415 std::string partition_name = 397 std::string partition_name =
416 (params.persist_storage ? browser_plugin::kPersistPrefix : "") + 398 (params.persist_storage ? browser_plugin::kPersistPrefix : "") +
417 params.storage_partition_id; 399 params.storage_partition_id;
418 UpdateDOMAttribute(browser_plugin::kAttributePartition, partition_name); 400 UpdateDOMAttribute(browser_plugin::kAttributePartition, partition_name);
419 } 401 }
420 attached_ = true; 402 attached_ = true;
421 } 403 }
422 404
423 void BrowserPlugin::OnBuffersSwapped( 405 void BrowserPlugin::OnBuffersSwapped(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 491
510 void BrowserPlugin::OnShouldAcceptTouchEvents(int guest_instance_id, 492 void BrowserPlugin::OnShouldAcceptTouchEvents(int guest_instance_id,
511 bool accept) { 493 bool accept) {
512 if (container()) { 494 if (container()) {
513 container()->requestTouchEventType(accept ? 495 container()->requestTouchEventType(accept ?
514 blink::WebPluginContainer::TouchEventRequestTypeRaw : 496 blink::WebPluginContainer::TouchEventRequestTypeRaw :
515 blink::WebPluginContainer::TouchEventRequestTypeNone); 497 blink::WebPluginContainer::TouchEventRequestTypeNone);
516 } 498 }
517 } 499 }
518 500
519 void BrowserPlugin::OnUpdatedName(int guest_instance_id,
520 const std::string& name) {
521 UpdateDOMAttribute(browser_plugin::kAttributeName, name);
522 }
523
524 void BrowserPlugin::OnUpdateRect( 501 void BrowserPlugin::OnUpdateRect(
525 int guest_instance_id, 502 int guest_instance_id,
526 const BrowserPluginMsg_UpdateRect_Params& params) { 503 const BrowserPluginMsg_UpdateRect_Params& params) {
527 // Note that there is no need to send ACK for this message. 504 // Note that there is no need to send ACK for this message.
528 // If the guest has updated pixels then it is no longer crashed. 505 // If the guest has updated pixels then it is no longer crashed.
529 guest_crashed_ = false; 506 guest_crashed_ = false;
530 507
531 bool auto_size = GetAutoSizeAttribute(); 508 bool auto_size = GetAutoSizeAttribute();
532 // We receive a resize ACK in regular mode, but not in autosize. 509 // We receive a resize ACK in regular mode, but not in autosize.
533 // In Compositing mode, we need to do it here so we can continue sending 510 // In Compositing mode, we need to do it here so we can continue sending
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 case BrowserPluginMsg_AdvanceFocus::ID: 839 case BrowserPluginMsg_AdvanceFocus::ID:
863 case BrowserPluginMsg_Attach_ACK::ID: 840 case BrowserPluginMsg_Attach_ACK::ID:
864 case BrowserPluginMsg_BuffersSwapped::ID: 841 case BrowserPluginMsg_BuffersSwapped::ID:
865 case BrowserPluginMsg_CompositorFrameSwapped::ID: 842 case BrowserPluginMsg_CompositorFrameSwapped::ID:
866 case BrowserPluginMsg_CopyFromCompositingSurface::ID: 843 case BrowserPluginMsg_CopyFromCompositingSurface::ID:
867 case BrowserPluginMsg_GuestContentWindowReady::ID: 844 case BrowserPluginMsg_GuestContentWindowReady::ID:
868 case BrowserPluginMsg_GuestGone::ID: 845 case BrowserPluginMsg_GuestGone::ID:
869 case BrowserPluginMsg_SetCursor::ID: 846 case BrowserPluginMsg_SetCursor::ID:
870 case BrowserPluginMsg_SetMouseLock::ID: 847 case BrowserPluginMsg_SetMouseLock::ID:
871 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID: 848 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID:
872 case BrowserPluginMsg_UpdatedName::ID:
873 case BrowserPluginMsg_UpdateRect::ID: 849 case BrowserPluginMsg_UpdateRect::ID:
874 return true; 850 return true;
875 default: 851 default:
876 break; 852 break;
877 } 853 }
878 return false; 854 return false;
879 } 855 }
880 856
881 void BrowserPlugin::updateGeometry( 857 void BrowserPlugin::updateGeometry(
882 const WebRect& window_rect, 858 const WebRect& window_rect,
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 const blink::WebMouseEvent& event) { 1150 const blink::WebMouseEvent& event) {
1175 browser_plugin_manager()->Send( 1151 browser_plugin_manager()->Send(
1176 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 1152 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
1177 guest_instance_id_, 1153 guest_instance_id_,
1178 plugin_rect_, 1154 plugin_rect_,
1179 &event)); 1155 &event));
1180 return true; 1156 return true;
1181 } 1157 }
1182 1158
1183 } // namespace content 1159 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.h ('k') | content/renderer/browser_plugin/browser_plugin_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698