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

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

Issue 427883002: <webview>: Move autosize from content to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_frame_url
Patch Set: Works 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
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),
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
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
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 gfx::Point screen_pos(relative_position); 317 gfx::Point screen_pos(relative_position);
326 screen_pos += guest_window_rect_.OffsetFromOrigin(); 318 screen_pos += guest_window_rect_.OffsetFromOrigin();
327 if (embedder_web_contents()->GetBrowserPluginGuest()) { 319 if (embedder_web_contents()->GetBrowserPluginGuest()) {
328 BrowserPluginGuest* embedder_guest = 320 BrowserPluginGuest* embedder_guest =
329 embedder_web_contents()->GetBrowserPluginGuest(); 321 embedder_web_contents()->GetBrowserPluginGuest();
330 screen_pos += embedder_guest->guest_window_rect_.OffsetFromOrigin(); 322 screen_pos += embedder_guest->guest_window_rect_.OffsetFromOrigin();
331 } 323 }
332 return screen_pos; 324 return screen_pos;
333 } 325 }
334 326
335 bool BrowserPluginGuest::InAutoSizeBounds(const gfx::Size& size) const {
336 return size.width() <= max_auto_size_.width() &&
337 size.height() <= max_auto_size_.height();
338 }
339
340 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { 327 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) {
341 if (!attached()) { 328 if (!attached()) {
342 // Some pages such as data URLs, javascript URLs, and about:blank 329 // Some pages such as data URLs, javascript URLs, and about:blank
343 // do not load external resources and so they load prior to attachment. 330 // do not load external resources and so they load prior to attachment.
344 // As a result, we must save all these IPCs until attachment and then 331 // As a result, we must save all these IPCs until attachment and then
345 // forward them so that the embedder gets a chance to see and process 332 // forward them so that the embedder gets a chance to see and process
346 // the load events. 333 // the load events.
347 pending_messages_.push_back(linked_ptr<IPC::Message>(msg)); 334 pending_messages_.push_back(linked_ptr<IPC::Message>(msg));
348 return; 335 return;
349 } 336 }
(...skipping 30 matching lines...) Expand all
380 PageTransition transition_type) { 367 PageTransition transition_type) {
381 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate")); 368 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate"));
382 } 369 }
383 370
384 void BrowserPluginGuest::RenderViewReady() { 371 void BrowserPluginGuest::RenderViewReady() {
385 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); 372 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost();
386 // TODO(fsamuel): Investigate whether it's possible to update state earlier 373 // TODO(fsamuel): Investigate whether it's possible to update state earlier
387 // here (see http://crbug.com/158151). 374 // here (see http://crbug.com/158151).
388 Send(new InputMsg_SetFocus(routing_id(), focused_)); 375 Send(new InputMsg_SetFocus(routing_id(), focused_));
389 UpdateVisibility(); 376 UpdateVisibility();
390 if (auto_size_enabled_)
391 rvh->EnableAutoResize(min_auto_size_, max_auto_size_);
392 else
393 rvh->DisableAutoResize(full_size_);
394 377
395 OnSetContentsOpaque(instance_id_, guest_opaque_); 378 OnSetContentsOpaque(instance_id_, guest_opaque_);
396 379
397 RenderWidgetHostImpl::From(rvh)->set_hung_renderer_delay_ms( 380 RenderWidgetHostImpl::From(rvh)->set_hung_renderer_delay_ms(
398 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)); 381 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs));
399 } 382 }
400 383
401 void BrowserPluginGuest::RenderProcessGone(base::TerminationStatus status) { 384 void BrowserPluginGuest::RenderProcessGone(base::TerminationStatus status) {
402 SendMessageToEmbedder(new BrowserPluginMsg_GuestGone(instance_id())); 385 SendMessageToEmbedder(new BrowserPluginMsg_GuestGone(instance_id()));
403 switch (status) { 386 switch (status) {
(...skipping 21 matching lines...) Expand all
425 case BrowserPluginHostMsg_DragStatusUpdate::ID: 408 case BrowserPluginHostMsg_DragStatusUpdate::ID:
426 case BrowserPluginHostMsg_ExecuteEditCommand::ID: 409 case BrowserPluginHostMsg_ExecuteEditCommand::ID:
427 case BrowserPluginHostMsg_ExtendSelectionAndDelete::ID: 410 case BrowserPluginHostMsg_ExtendSelectionAndDelete::ID:
428 case BrowserPluginHostMsg_HandleInputEvent::ID: 411 case BrowserPluginHostMsg_HandleInputEvent::ID:
429 case BrowserPluginHostMsg_ImeConfirmComposition::ID: 412 case BrowserPluginHostMsg_ImeConfirmComposition::ID:
430 case BrowserPluginHostMsg_ImeSetComposition::ID: 413 case BrowserPluginHostMsg_ImeSetComposition::ID:
431 case BrowserPluginHostMsg_LockMouse_ACK::ID: 414 case BrowserPluginHostMsg_LockMouse_ACK::ID:
432 case BrowserPluginHostMsg_PluginDestroyed::ID: 415 case BrowserPluginHostMsg_PluginDestroyed::ID:
433 case BrowserPluginHostMsg_ReclaimCompositorResources::ID: 416 case BrowserPluginHostMsg_ReclaimCompositorResources::ID:
434 case BrowserPluginHostMsg_ResizeGuest::ID: 417 case BrowserPluginHostMsg_ResizeGuest::ID:
435 case BrowserPluginHostMsg_SetAutoSize::ID:
436 case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID: 418 case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID:
437 case BrowserPluginHostMsg_SetFocus::ID: 419 case BrowserPluginHostMsg_SetFocus::ID:
438 case BrowserPluginHostMsg_SetContentsOpaque::ID: 420 case BrowserPluginHostMsg_SetContentsOpaque::ID:
439 case BrowserPluginHostMsg_SetVisibility::ID: 421 case BrowserPluginHostMsg_SetVisibility::ID:
440 case BrowserPluginHostMsg_UnlockMouse_ACK::ID: 422 case BrowserPluginHostMsg_UnlockMouse_ACK::ID:
441 case BrowserPluginHostMsg_UpdateGeometry::ID: 423 case BrowserPluginHostMsg_UpdateGeometry::ID:
442 return true; 424 return true;
443 default: 425 default:
444 return false; 426 return false;
445 } 427 }
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 if (GetWebContents()->GetRenderViewHost()) { 667 if (GetWebContents()->GetRenderViewHost()) {
686 RenderWidgetHostImpl* render_widget_host = 668 RenderWidgetHostImpl* render_widget_host =
687 RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost()); 669 RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost());
688 render_widget_host->ResetSizeAndRepaintPendingFlags(); 670 render_widget_host->ResetSizeAndRepaintPendingFlags();
689 671
690 if (guest_device_scale_factor_ != params.scale_factor) { 672 if (guest_device_scale_factor_ != params.scale_factor) {
691 guest_device_scale_factor_ = params.scale_factor; 673 guest_device_scale_factor_ = params.scale_factor;
692 render_widget_host->NotifyScreenInfoChanged(); 674 render_widget_host->NotifyScreenInfoChanged();
693 } 675 }
694 } 676 }
695 // When autosize is turned off and as a result there is a layout change, we 677
696 // send a sizechanged event. 678 if (last_seen_browser_plugin_size_ != params.view_size) {
697 if (!auto_size_enabled_ && last_seen_auto_size_enabled_ && 679 delegate_->ElementSizeChanged(last_seen_browser_plugin_size_,
698 !params.view_size.IsEmpty()) { 680 params.view_size);
699 delegate_->SizeChanged(last_seen_view_size_, params.view_size); 681 last_seen_browser_plugin_size_ = params.view_size;
700 last_seen_auto_size_enabled_ = false;
701 } 682 }
683
702 // Just resize the WebContents and repaint if needed. 684 // Just resize the WebContents and repaint if needed.
703 full_size_ = params.view_size;
704 if (!params.view_size.IsEmpty()) 685 if (!params.view_size.IsEmpty())
705 GetWebContents()->GetView()->SizeContents(params.view_size); 686 GetWebContents()->GetView()->SizeContents(params.view_size);
706 if (params.repaint) 687 if (params.repaint)
707 Send(new ViewMsg_Repaint(routing_id(), params.view_size)); 688 Send(new ViewMsg_Repaint(routing_id(), params.view_size));
708 } 689 }
709 690
710 void BrowserPluginGuest::OnSetFocus(int instance_id, bool focused) { 691 void BrowserPluginGuest::OnSetFocus(int instance_id, bool focused) {
711 focused_ = focused; 692 focused_ = focused;
712 Send(new InputMsg_SetFocus(routing_id(), focused)); 693 Send(new InputMsg_SetFocus(routing_id(), focused));
713 if (!focused && mouse_locked_) 694 if (!focused && mouse_locked_)
714 OnUnlockMouse(); 695 OnUnlockMouse();
715 696
716 // Restore the last seen state of text input to the view. 697 // Restore the last seen state of text input to the view.
717 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>( 698 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>(
718 web_contents()->GetRenderWidgetHostView()); 699 web_contents()->GetRenderWidgetHostView());
719 if (rwhv) { 700 if (rwhv) {
720 ViewHostMsg_TextInputState_Params params; 701 ViewHostMsg_TextInputState_Params params;
721 params.type = last_text_input_type_; 702 params.type = last_text_input_type_;
722 params.mode = last_input_mode_; 703 params.mode = last_input_mode_;
723 params.can_compose_inline = last_can_compose_inline_; 704 params.can_compose_inline = last_can_compose_inline_;
724 rwhv->TextInputStateChanged(params); 705 rwhv->TextInputStateChanged(params);
725 } 706 }
726 } 707 }
727 708
728 void BrowserPluginGuest::OnSetAutoSize(
729 int instance_id,
730 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params,
731 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params) {
732 bool old_auto_size_enabled = auto_size_enabled_;
733 gfx::Size old_max_size = max_auto_size_;
734 gfx::Size old_min_size = min_auto_size_;
735 auto_size_enabled_ = auto_size_params.enable;
736 max_auto_size_ = auto_size_params.max_size;
737 min_auto_size_ = auto_size_params.min_size;
738 if (auto_size_enabled_ && (!old_auto_size_enabled ||
739 (old_max_size != max_auto_size_) ||
740 (old_min_size != min_auto_size_))) {
741 RecordAction(
742 base::UserMetricsAction("BrowserPlugin.Guest.EnableAutoResize"));
743 GetWebContents()->GetRenderViewHost()->EnableAutoResize(
744 min_auto_size_, max_auto_size_);
745 // TODO(fsamuel): If we're changing autosize parameters, then we force
746 // the guest to completely repaint itself.
747 // Ideally, we shouldn't need to do this unless |max_auto_size_| has
748 // changed.
749 // However, even in that case, layout may not change and so we may
750 // not get a full frame worth of pixels.
751 Send(new ViewMsg_Repaint(routing_id(), max_auto_size_));
752 } else if (!auto_size_enabled_ && old_auto_size_enabled) {
753 GetWebContents()->GetRenderViewHost()->DisableAutoResize(
754 resize_guest_params.view_size);
755 }
756 OnResizeGuest(instance_id_, resize_guest_params);
757 }
758
759 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( 709 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent(
760 int instance_id, 710 int instance_id,
761 const std::vector<EditCommand>& edit_commands) { 711 const std::vector<EditCommand>& edit_commands) {
762 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), 712 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(),
763 edit_commands)); 713 edit_commands));
764 } 714 }
765 715
766 void BrowserPluginGuest::OnSetContentsOpaque(int instance_id, bool opaque) { 716 void BrowserPluginGuest::OnSetContentsOpaque(int instance_id, bool opaque) {
767 guest_opaque_ = opaque; 717 guest_opaque_ = opaque;
768 Send(new ViewMsg_SetBackgroundOpaque(routing_id(), guest_opaque_)); 718 Send(new ViewMsg_SetBackgroundOpaque(routing_id(), guest_opaque_));
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 } 801 }
852 802
853 void BrowserPluginGuest::OnUpdateRect( 803 void BrowserPluginGuest::OnUpdateRect(
854 const ViewHostMsg_UpdateRect_Params& params) { 804 const ViewHostMsg_UpdateRect_Params& params) {
855 BrowserPluginMsg_UpdateRect_Params relay_params; 805 BrowserPluginMsg_UpdateRect_Params relay_params;
856 relay_params.view_size = params.view_size; 806 relay_params.view_size = params.view_size;
857 relay_params.scale_factor = params.scale_factor; 807 relay_params.scale_factor = params.scale_factor;
858 relay_params.is_resize_ack = ViewHostMsg_UpdateRect_Flags::is_resize_ack( 808 relay_params.is_resize_ack = ViewHostMsg_UpdateRect_Flags::is_resize_ack(
859 params.flags); 809 params.flags);
860 810
861 bool size_changed = last_seen_view_size_ != params.view_size; 811 if (last_seen_view_size_ != params.view_size) {
862 gfx::Size old_size = last_seen_view_size_; 812 delegate_->GuestSizeChanged(last_seen_view_size_, params.view_size);
863 last_seen_view_size_ = params.view_size; 813 last_seen_view_size_ = params.view_size;
864
865 if ((auto_size_enabled_ || last_seen_auto_size_enabled_) &&
866 size_changed) {
867 delegate_->SizeChanged(old_size, last_seen_view_size_);
868 } 814 }
869 last_seen_auto_size_enabled_ = auto_size_enabled_;
870 815
871 SendMessageToEmbedder( 816 SendMessageToEmbedder(
872 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params)); 817 new BrowserPluginMsg_UpdateRect(instance_id(), relay_params));
873 } 818 }
874 819
875 void BrowserPluginGuest::OnTextInputStateChanged( 820 void BrowserPluginGuest::OnTextInputStateChanged(
876 const ViewHostMsg_TextInputState_Params& params) { 821 const ViewHostMsg_TextInputState_Params& params) {
877 // Save the state of text input so we can restore it on focus. 822 // Save the state of text input so we can restore it on focus.
878 last_text_input_type_ = params.type; 823 last_text_input_type_ = params.type;
879 last_input_mode_ = params.mode; 824 last_input_mode_ = params.mode;
(...skipping 12 matching lines...) Expand all
892 void BrowserPluginGuest::OnImeCompositionRangeChanged( 837 void BrowserPluginGuest::OnImeCompositionRangeChanged(
893 const gfx::Range& range, 838 const gfx::Range& range,
894 const std::vector<gfx::Rect>& character_bounds) { 839 const std::vector<gfx::Rect>& character_bounds) {
895 static_cast<RenderWidgetHostViewBase*>( 840 static_cast<RenderWidgetHostViewBase*>(
896 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 841 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
897 range, character_bounds); 842 range, character_bounds);
898 } 843 }
899 #endif 844 #endif
900 845
901 } // namespace content 846 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698