| 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/browser/browser_plugin/browser_plugin_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 : WebContentsObserver(web_contents), | 73 : WebContentsObserver(web_contents), |
| 74 embedder_web_contents_(NULL), | 74 embedder_web_contents_(NULL), |
| 75 instance_id_(instance_id), | 75 instance_id_(instance_id), |
| 76 guest_device_scale_factor_(1.0f), | 76 guest_device_scale_factor_(1.0f), |
| 77 focused_(false), | 77 focused_(false), |
| 78 mouse_locked_(false), | 78 mouse_locked_(false), |
| 79 pending_lock_request_(false), | 79 pending_lock_request_(false), |
| 80 guest_visible_(false), | 80 guest_visible_(false), |
| 81 guest_opaque_(true), | 81 guest_opaque_(true), |
| 82 embedder_visible_(true), | 82 embedder_visible_(true), |
| 83 auto_size_enabled_(false), | |
| 84 copy_request_id_(0), | 83 copy_request_id_(0), |
| 85 has_render_view_(has_render_view), | 84 has_render_view_(has_render_view), |
| 86 last_seen_auto_size_enabled_(false), | |
| 87 is_in_destruction_(false), | 85 is_in_destruction_(false), |
| 88 last_text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 86 last_text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 89 last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 87 last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
| 90 last_can_compose_inline_(true), | 88 last_can_compose_inline_(true), |
| 91 delegate_(delegate), | 89 delegate_(delegate), |
| 92 weak_ptr_factory_(this) { | 90 weak_ptr_factory_(this) { |
| 93 DCHECK(web_contents); | 91 DCHECK(web_contents); |
| 94 DCHECK(delegate); | 92 DCHECK(delegate); |
| 95 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); | 93 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); |
| 96 web_contents->SetBrowserPluginGuest(this); | 94 web_contents->SetBrowserPluginGuest(this); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 OnHandleInputEvent) | 142 OnHandleInputEvent) |
| 145 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeConfirmComposition, | 143 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeConfirmComposition, |
| 146 OnImeConfirmComposition) | 144 OnImeConfirmComposition) |
| 147 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition, | 145 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition, |
| 148 OnImeSetComposition) | 146 OnImeSetComposition) |
| 149 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck) | 147 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_LockMouse_ACK, OnLockMouseAck) |
| 150 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) | 148 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed, OnPluginDestroyed) |
| 151 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources, | 149 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ReclaimCompositorResources, |
| 152 OnReclaimCompositorResources) | 150 OnReclaimCompositorResources) |
| 153 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) | 151 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) |
| 154 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetAutoSize, OnSetAutoSize) | |
| 155 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent, | 152 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent, |
| 156 OnSetEditCommandsForNextKeyEvent) | 153 OnSetEditCommandsForNextKeyEvent) |
| 157 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) | 154 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) |
| 158 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetContentsOpaque, | 155 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetContentsOpaque, |
| 159 OnSetContentsOpaque) | 156 OnSetContentsOpaque) |
| 160 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility) | 157 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility) |
| 161 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UnlockMouse_ACK, OnUnlockMouseAck) | 158 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UnlockMouse_ACK, OnUnlockMouseAck) |
| 162 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry) | 159 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry) |
| 163 IPC_MESSAGE_UNHANDLED(handled = false) | 160 IPC_MESSAGE_UNHANDLED(handled = false) |
| 164 IPC_END_MESSAGE_MAP() | 161 IPC_END_MESSAGE_MAP() |
| 165 return handled; | 162 return handled; |
| 166 } | 163 } |
| 167 | 164 |
| 168 void BrowserPluginGuest::Initialize( | 165 void BrowserPluginGuest::Initialize( |
| 169 const BrowserPluginHostMsg_Attach_Params& params, | 166 const BrowserPluginHostMsg_Attach_Params& params, |
| 170 WebContentsImpl* embedder_web_contents, | 167 WebContentsImpl* embedder_web_contents, |
| 171 const base::DictionaryValue& extra_params) { | 168 const base::DictionaryValue& extra_params) { |
| 172 focused_ = params.focused; | 169 focused_ = params.focused; |
| 173 guest_visible_ = params.visible; | 170 guest_visible_ = params.visible; |
| 174 guest_opaque_ = params.opaque; | 171 guest_opaque_ = params.opaque; |
| 175 guest_window_rect_ = gfx::Rect(params.origin, | 172 guest_window_rect_ = gfx::Rect(params.origin, |
| 176 params.resize_guest_params.view_size); | 173 params.resize_guest_params.view_size); |
| 177 | 174 |
| 178 auto_size_enabled_ = params.auto_size_params.enable; | |
| 179 max_auto_size_ = params.auto_size_params.max_size; | |
| 180 min_auto_size_ = params.auto_size_params.min_size; | |
| 181 | |
| 182 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to | 175 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to |
| 183 // be attached. | 176 // be attached. |
| 184 embedder_web_contents_ = embedder_web_contents; | 177 embedder_web_contents_ = embedder_web_contents; |
| 185 | 178 |
| 186 WebContentsViewGuest* new_view = | 179 WebContentsViewGuest* new_view = |
| 187 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 180 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
| 188 new_view->OnGuestInitialized(embedder_web_contents->GetView()); | 181 new_view->OnGuestInitialized(embedder_web_contents->GetView()); |
| 189 | 182 |
| 190 RendererPreferences* renderer_prefs = | 183 RendererPreferences* renderer_prefs = |
| 191 GetWebContents()->GetMutableRendererPrefs(); | 184 GetWebContents()->GetMutableRendererPrefs(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 204 // TODO(fsamuel): Remove this once http://crbug.com/169110 is addressed. | 197 // TODO(fsamuel): Remove this once http://crbug.com/169110 is addressed. |
| 205 renderer_prefs->report_frame_name_changes = true; | 198 renderer_prefs->report_frame_name_changes = true; |
| 206 // Navigation is disabled in Chrome Apps. We want to make sure guest-initiated | 199 // Navigation is disabled in Chrome Apps. We want to make sure guest-initiated |
| 207 // navigations still continue to function inside the app. | 200 // navigations still continue to function inside the app. |
| 208 renderer_prefs->browser_handles_all_top_level_requests = false; | 201 renderer_prefs->browser_handles_all_top_level_requests = false; |
| 209 // Disable "client blocked" error page for browser plugin. | 202 // Disable "client blocked" error page for browser plugin. |
| 210 renderer_prefs->disable_client_blocked_error_page = true; | 203 renderer_prefs->disable_client_blocked_error_page = true; |
| 211 | 204 |
| 212 embedder_web_contents_observer_.reset(new EmbedderWebContentsObserver(this)); | 205 embedder_web_contents_observer_.reset(new EmbedderWebContentsObserver(this)); |
| 213 | 206 |
| 214 OnSetAutoSize( | 207 OnResizeGuest(instance_id_, params.resize_guest_params); |
| 215 instance_id_, params.auto_size_params, params.resize_guest_params); | |
| 216 | 208 |
| 217 // Create a swapped out RenderView for the guest in the embedder render | 209 // Create a swapped out RenderView for the guest in the embedder render |
| 218 // process, so that the embedder can access the guest's window object. | 210 // process, so that the embedder can access the guest's window object. |
| 219 int guest_routing_id = | 211 int guest_routing_id = |
| 220 GetWebContents()->CreateSwappedOutRenderView( | 212 GetWebContents()->CreateSwappedOutRenderView( |
| 221 embedder_web_contents_->GetSiteInstance()); | 213 embedder_web_contents_->GetSiteInstance()); |
| 222 SendMessageToEmbedder( | 214 SendMessageToEmbedder( |
| 223 new BrowserPluginMsg_GuestContentWindowReady(instance_id_, | 215 new BrowserPluginMsg_GuestContentWindowReady(instance_id_, |
| 224 guest_routing_id)); | 216 guest_routing_id)); |
| 225 | 217 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 gfx::Point screen_pos(relative_position); | 314 gfx::Point screen_pos(relative_position); |
| 323 screen_pos += guest_window_rect_.OffsetFromOrigin(); | 315 screen_pos += guest_window_rect_.OffsetFromOrigin(); |
| 324 if (embedder_web_contents()->GetBrowserPluginGuest()) { | 316 if (embedder_web_contents()->GetBrowserPluginGuest()) { |
| 325 BrowserPluginGuest* embedder_guest = | 317 BrowserPluginGuest* embedder_guest = |
| 326 embedder_web_contents()->GetBrowserPluginGuest(); | 318 embedder_web_contents()->GetBrowserPluginGuest(); |
| 327 screen_pos += embedder_guest->guest_window_rect_.OffsetFromOrigin(); | 319 screen_pos += embedder_guest->guest_window_rect_.OffsetFromOrigin(); |
| 328 } | 320 } |
| 329 return screen_pos; | 321 return screen_pos; |
| 330 } | 322 } |
| 331 | 323 |
| 332 bool BrowserPluginGuest::InAutoSizeBounds(const gfx::Size& size) const { | |
| 333 return size.width() <= max_auto_size_.width() && | |
| 334 size.height() <= max_auto_size_.height(); | |
| 335 } | |
| 336 | |
| 337 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { | 324 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
| 338 if (!attached()) { | 325 if (!attached()) { |
| 339 // Some pages such as data URLs, javascript URLs, and about:blank | 326 // Some pages such as data URLs, javascript URLs, and about:blank |
| 340 // do not load external resources and so they load prior to attachment. | 327 // do not load external resources and so they load prior to attachment. |
| 341 // As a result, we must save all these IPCs until attachment and then | 328 // As a result, we must save all these IPCs until attachment and then |
| 342 // forward them so that the embedder gets a chance to see and process | 329 // forward them so that the embedder gets a chance to see and process |
| 343 // the load events. | 330 // the load events. |
| 344 pending_messages_.push_back(linked_ptr<IPC::Message>(msg)); | 331 pending_messages_.push_back(linked_ptr<IPC::Message>(msg)); |
| 345 return; | 332 return; |
| 346 } | 333 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 377 PageTransition transition_type) { | 364 PageTransition transition_type) { |
| 378 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate")); | 365 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate")); |
| 379 } | 366 } |
| 380 | 367 |
| 381 void BrowserPluginGuest::RenderViewReady() { | 368 void BrowserPluginGuest::RenderViewReady() { |
| 382 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); | 369 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); |
| 383 // TODO(fsamuel): Investigate whether it's possible to update state earlier | 370 // TODO(fsamuel): Investigate whether it's possible to update state earlier |
| 384 // here (see http://crbug.com/158151). | 371 // here (see http://crbug.com/158151). |
| 385 Send(new InputMsg_SetFocus(routing_id(), focused_)); | 372 Send(new InputMsg_SetFocus(routing_id(), focused_)); |
| 386 UpdateVisibility(); | 373 UpdateVisibility(); |
| 387 if (auto_size_enabled_) | |
| 388 rvh->EnableAutoResize(min_auto_size_, max_auto_size_); | |
| 389 else | |
| 390 rvh->DisableAutoResize(full_size_); | |
| 391 | 374 |
| 392 OnSetContentsOpaque(instance_id_, guest_opaque_); | 375 OnSetContentsOpaque(instance_id_, guest_opaque_); |
| 393 | 376 |
| 394 RenderWidgetHostImpl::From(rvh)->set_hung_renderer_delay_ms( | 377 RenderWidgetHostImpl::From(rvh)->set_hung_renderer_delay_ms( |
| 395 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)); | 378 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)); |
| 396 } | 379 } |
| 397 | 380 |
| 398 void BrowserPluginGuest::RenderProcessGone(base::TerminationStatus status) { | 381 void BrowserPluginGuest::RenderProcessGone(base::TerminationStatus status) { |
| 399 SendMessageToEmbedder(new BrowserPluginMsg_GuestGone(instance_id())); | 382 SendMessageToEmbedder(new BrowserPluginMsg_GuestGone(instance_id())); |
| 400 switch (status) { | 383 switch (status) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 422 case BrowserPluginHostMsg_DragStatusUpdate::ID: | 405 case BrowserPluginHostMsg_DragStatusUpdate::ID: |
| 423 case BrowserPluginHostMsg_ExecuteEditCommand::ID: | 406 case BrowserPluginHostMsg_ExecuteEditCommand::ID: |
| 424 case BrowserPluginHostMsg_ExtendSelectionAndDelete::ID: | 407 case BrowserPluginHostMsg_ExtendSelectionAndDelete::ID: |
| 425 case BrowserPluginHostMsg_HandleInputEvent::ID: | 408 case BrowserPluginHostMsg_HandleInputEvent::ID: |
| 426 case BrowserPluginHostMsg_ImeConfirmComposition::ID: | 409 case BrowserPluginHostMsg_ImeConfirmComposition::ID: |
| 427 case BrowserPluginHostMsg_ImeSetComposition::ID: | 410 case BrowserPluginHostMsg_ImeSetComposition::ID: |
| 428 case BrowserPluginHostMsg_LockMouse_ACK::ID: | 411 case BrowserPluginHostMsg_LockMouse_ACK::ID: |
| 429 case BrowserPluginHostMsg_PluginDestroyed::ID: | 412 case BrowserPluginHostMsg_PluginDestroyed::ID: |
| 430 case BrowserPluginHostMsg_ReclaimCompositorResources::ID: | 413 case BrowserPluginHostMsg_ReclaimCompositorResources::ID: |
| 431 case BrowserPluginHostMsg_ResizeGuest::ID: | 414 case BrowserPluginHostMsg_ResizeGuest::ID: |
| 432 case BrowserPluginHostMsg_SetAutoSize::ID: | |
| 433 case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID: | 415 case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID: |
| 434 case BrowserPluginHostMsg_SetFocus::ID: | 416 case BrowserPluginHostMsg_SetFocus::ID: |
| 435 case BrowserPluginHostMsg_SetContentsOpaque::ID: | 417 case BrowserPluginHostMsg_SetContentsOpaque::ID: |
| 436 case BrowserPluginHostMsg_SetVisibility::ID: | 418 case BrowserPluginHostMsg_SetVisibility::ID: |
| 437 case BrowserPluginHostMsg_UnlockMouse_ACK::ID: | 419 case BrowserPluginHostMsg_UnlockMouse_ACK::ID: |
| 438 case BrowserPluginHostMsg_UpdateGeometry::ID: | 420 case BrowserPluginHostMsg_UpdateGeometry::ID: |
| 439 return true; | 421 return true; |
| 440 default: | 422 default: |
| 441 return false; | 423 return false; |
| 442 } | 424 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 if (GetWebContents()->GetRenderViewHost()) { | 664 if (GetWebContents()->GetRenderViewHost()) { |
| 683 RenderWidgetHostImpl* render_widget_host = | 665 RenderWidgetHostImpl* render_widget_host = |
| 684 RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost()); | 666 RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost()); |
| 685 render_widget_host->ResetSizeAndRepaintPendingFlags(); | 667 render_widget_host->ResetSizeAndRepaintPendingFlags(); |
| 686 | 668 |
| 687 if (guest_device_scale_factor_ != params.scale_factor) { | 669 if (guest_device_scale_factor_ != params.scale_factor) { |
| 688 guest_device_scale_factor_ = params.scale_factor; | 670 guest_device_scale_factor_ = params.scale_factor; |
| 689 render_widget_host->NotifyScreenInfoChanged(); | 671 render_widget_host->NotifyScreenInfoChanged(); |
| 690 } | 672 } |
| 691 } | 673 } |
| 692 // When autosize is turned off and as a result there is a layout change, we | 674 |
| 693 // send a sizechanged event. | 675 if (last_seen_browser_plugin_size_ != params.view_size) { |
| 694 if (!auto_size_enabled_ && last_seen_auto_size_enabled_ && | 676 delegate_->ElementSizeChanged(last_seen_browser_plugin_size_, |
| 695 !params.view_size.IsEmpty()) { | 677 params.view_size); |
| 696 delegate_->SizeChanged(last_seen_view_size_, params.view_size); | 678 last_seen_browser_plugin_size_ = params.view_size; |
| 697 last_seen_auto_size_enabled_ = false; | |
| 698 } | 679 } |
| 680 |
| 699 // Just resize the WebContents and repaint if needed. | 681 // Just resize the WebContents and repaint if needed. |
| 700 full_size_ = params.view_size; | |
| 701 if (!params.view_size.IsEmpty()) | 682 if (!params.view_size.IsEmpty()) |
| 702 GetWebContents()->GetView()->SizeContents(params.view_size); | 683 GetWebContents()->GetView()->SizeContents(params.view_size); |
| 703 if (params.repaint) | 684 if (params.repaint) |
| 704 Send(new ViewMsg_Repaint(routing_id(), params.view_size)); | 685 Send(new ViewMsg_Repaint(routing_id(), params.view_size)); |
| 705 } | 686 } |
| 706 | 687 |
| 707 void BrowserPluginGuest::OnSetFocus(int instance_id, bool focused) { | 688 void BrowserPluginGuest::OnSetFocus(int instance_id, bool focused) { |
| 708 focused_ = focused; | 689 focused_ = focused; |
| 709 Send(new InputMsg_SetFocus(routing_id(), focused)); | 690 Send(new InputMsg_SetFocus(routing_id(), focused)); |
| 710 if (!focused && mouse_locked_) | 691 if (!focused && mouse_locked_) |
| 711 OnUnlockMouse(); | 692 OnUnlockMouse(); |
| 712 | 693 |
| 713 // Restore the last seen state of text input to the view. | 694 // Restore the last seen state of text input to the view. |
| 714 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>( | 695 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>( |
| 715 web_contents()->GetRenderWidgetHostView()); | 696 web_contents()->GetRenderWidgetHostView()); |
| 716 if (rwhv) { | 697 if (rwhv) { |
| 717 ViewHostMsg_TextInputState_Params params; | 698 ViewHostMsg_TextInputState_Params params; |
| 718 params.type = last_text_input_type_; | 699 params.type = last_text_input_type_; |
| 719 params.mode = last_input_mode_; | 700 params.mode = last_input_mode_; |
| 720 params.can_compose_inline = last_can_compose_inline_; | 701 params.can_compose_inline = last_can_compose_inline_; |
| 721 rwhv->TextInputStateChanged(params); | 702 rwhv->TextInputStateChanged(params); |
| 722 } | 703 } |
| 723 } | 704 } |
| 724 | 705 |
| 725 void BrowserPluginGuest::OnSetAutoSize( | |
| 726 int instance_id, | |
| 727 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, | |
| 728 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params) { | |
| 729 bool old_auto_size_enabled = auto_size_enabled_; | |
| 730 gfx::Size old_max_size = max_auto_size_; | |
| 731 gfx::Size old_min_size = min_auto_size_; | |
| 732 auto_size_enabled_ = auto_size_params.enable; | |
| 733 max_auto_size_ = auto_size_params.max_size; | |
| 734 min_auto_size_ = auto_size_params.min_size; | |
| 735 if (auto_size_enabled_ && (!old_auto_size_enabled || | |
| 736 (old_max_size != max_auto_size_) || | |
| 737 (old_min_size != min_auto_size_))) { | |
| 738 RecordAction( | |
| 739 base::UserMetricsAction("BrowserPlugin.Guest.EnableAutoResize")); | |
| 740 GetWebContents()->GetRenderViewHost()->EnableAutoResize( | |
| 741 min_auto_size_, max_auto_size_); | |
| 742 // TODO(fsamuel): If we're changing autosize parameters, then we force | |
| 743 // the guest to completely repaint itself. | |
| 744 // Ideally, we shouldn't need to do this unless |max_auto_size_| has | |
| 745 // changed. | |
| 746 // However, even in that case, layout may not change and so we may | |
| 747 // not get a full frame worth of pixels. | |
| 748 Send(new ViewMsg_Repaint(routing_id(), max_auto_size_)); | |
| 749 } else if (!auto_size_enabled_ && old_auto_size_enabled) { | |
| 750 GetWebContents()->GetRenderViewHost()->DisableAutoResize( | |
| 751 resize_guest_params.view_size); | |
| 752 } | |
| 753 OnResizeGuest(instance_id_, resize_guest_params); | |
| 754 } | |
| 755 | |
| 756 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( | 706 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( |
| 757 int instance_id, | 707 int instance_id, |
| 758 const std::vector<EditCommand>& edit_commands) { | 708 const std::vector<EditCommand>& edit_commands) { |
| 759 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), | 709 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), |
| 760 edit_commands)); | 710 edit_commands)); |
| 761 } | 711 } |
| 762 | 712 |
| 763 void BrowserPluginGuest::OnSetContentsOpaque(int instance_id, bool opaque) { | 713 void BrowserPluginGuest::OnSetContentsOpaque(int instance_id, bool opaque) { |
| 764 guest_opaque_ = opaque; | 714 guest_opaque_ = opaque; |
| 765 Send(new ViewMsg_SetBackgroundOpaque(routing_id(), guest_opaque_)); | 715 Send(new ViewMsg_SetBackgroundOpaque(routing_id(), guest_opaque_)); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 } | 798 } |
| 849 | 799 |
| 850 void BrowserPluginGuest::OnUpdateRect( | 800 void BrowserPluginGuest::OnUpdateRect( |
| 851 const ViewHostMsg_UpdateRect_Params& params) { | 801 const ViewHostMsg_UpdateRect_Params& params) { |
| 852 BrowserPluginMsg_UpdateRect_Params relay_params; | 802 BrowserPluginMsg_UpdateRect_Params relay_params; |
| 853 relay_params.view_size = params.view_size; | 803 relay_params.view_size = params.view_size; |
| 854 relay_params.scale_factor = params.scale_factor; | 804 relay_params.scale_factor = params.scale_factor; |
| 855 relay_params.is_resize_ack = ViewHostMsg_UpdateRect_Flags::is_resize_ack( | 805 relay_params.is_resize_ack = ViewHostMsg_UpdateRect_Flags::is_resize_ack( |
| 856 params.flags); | 806 params.flags); |
| 857 | 807 |
| 858 bool size_changed = last_seen_view_size_ != params.view_size; | 808 if (last_seen_view_size_ != params.view_size) { |
| 859 gfx::Size old_size = last_seen_view_size_; | 809 delegate_->GuestSizeChanged(last_seen_view_size_, params.view_size); |
| 860 last_seen_view_size_ = params.view_size; | 810 last_seen_view_size_ = params.view_size; |
| 861 | |
| 862 if ((auto_size_enabled_ || last_seen_auto_size_enabled_) && | |
| 863 size_changed) { | |
| 864 delegate_->SizeChanged(old_size, last_seen_view_size_); | |
| 865 } | 811 } |
| 866 last_seen_auto_size_enabled_ = auto_size_enabled_; | |
| 867 | 812 |
| 868 SendMessageToEmbedder( | 813 SendMessageToEmbedder( |
| 869 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); | 814 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); |
| 870 } | 815 } |
| 871 | 816 |
| 872 void BrowserPluginGuest::OnTextInputStateChanged( | 817 void BrowserPluginGuest::OnTextInputStateChanged( |
| 873 const ViewHostMsg_TextInputState_Params& params) { | 818 const ViewHostMsg_TextInputState_Params& params) { |
| 874 // Save the state of text input so we can restore it on focus. | 819 // Save the state of text input so we can restore it on focus. |
| 875 last_text_input_type_ = params.type; | 820 last_text_input_type_ = params.type; |
| 876 last_input_mode_ = params.mode; | 821 last_input_mode_ = params.mode; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 889 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 834 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
| 890 const gfx::Range& range, | 835 const gfx::Range& range, |
| 891 const std::vector<gfx::Rect>& character_bounds) { | 836 const std::vector<gfx::Rect>& character_bounds) { |
| 892 static_cast<RenderWidgetHostViewBase*>( | 837 static_cast<RenderWidgetHostViewBase*>( |
| 893 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 838 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
| 894 range, character_bounds); | 839 range, character_bounds); |
| 895 } | 840 } |
| 896 #endif | 841 #endif |
| 897 | 842 |
| 898 } // namespace content | 843 } // namespace content |
| OLD | NEW |