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

Side by Side Diff: trunk/src/content/browser/browser_plugin/browser_plugin_guest.cc

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

Powered by Google App Engine
This is Rietveld 408576698