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

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

Issue 853333002: Browser Plugin: Make aware of focus direction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 11 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/pickle.h" 10 #include "base/pickle.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 void BrowserPluginGuest::WillDestroy() { 125 void BrowserPluginGuest::WillDestroy() {
126 is_in_destruction_ = true; 126 is_in_destruction_ = true;
127 owner_web_contents_ = NULL; 127 owner_web_contents_ = NULL;
128 attached_ = false; 128 attached_ = false;
129 } 129 }
130 130
131 base::WeakPtr<BrowserPluginGuest> BrowserPluginGuest::AsWeakPtr() { 131 base::WeakPtr<BrowserPluginGuest> BrowserPluginGuest::AsWeakPtr() {
132 return weak_ptr_factory_.GetWeakPtr(); 132 return weak_ptr_factory_.GetWeakPtr();
133 } 133 }
134 134
135 void BrowserPluginGuest::SetFocus(RenderWidgetHost* rwh, bool focused) { 135 void BrowserPluginGuest::SetFocus(RenderWidgetHost* rwh,
136 bool focused,
137 blink::WebFocusType focus_type) {
136 focused_ = focused; 138 focused_ = focused;
137 if (!rwh) 139 if (!rwh)
138 return; 140 return;
139 141
142 if ((focus_type == blink::WebFocusTypeForward) ||
143 (focus_type == blink::WebFocusTypeBackward)) {
144 static_cast<RenderViewHostImpl*>(RenderViewHost::From(rwh))->
145 SetInitialFocus(focus_type == blink::WebFocusTypeBackward);
146 }
140 rwh->Send(new InputMsg_SetFocus(rwh->GetRoutingID(), focused)); 147 rwh->Send(new InputMsg_SetFocus(rwh->GetRoutingID(), focused));
141 if (!focused && mouse_locked_) 148 if (!focused && mouse_locked_)
142 OnUnlockMouse(); 149 OnUnlockMouse();
143 150
144 // Restore the last seen state of text input to the view. 151 // Restore the last seen state of text input to the view.
145 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>( 152 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>(
146 rwh->GetView()); 153 rwh->GetView());
147 if (rwhv) { 154 if (rwhv) {
148 rwhv->TextInputTypeChanged(last_text_input_type_, last_input_mode_, 155 rwhv->TextInputTypeChanged(last_text_input_type_, last_input_mode_,
149 last_can_compose_inline_, last_input_flags_); 156 last_can_compose_inline_, last_input_flags_);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry) 220 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry)
214 IPC_MESSAGE_UNHANDLED(handled = false) 221 IPC_MESSAGE_UNHANDLED(handled = false)
215 IPC_END_MESSAGE_MAP() 222 IPC_END_MESSAGE_MAP()
216 return handled; 223 return handled;
217 } 224 }
218 225
219 void BrowserPluginGuest::InitInternal( 226 void BrowserPluginGuest::InitInternal(
220 const BrowserPluginHostMsg_Attach_Params& params, 227 const BrowserPluginHostMsg_Attach_Params& params,
221 WebContentsImpl* owner_web_contents) { 228 WebContentsImpl* owner_web_contents) {
222 focused_ = params.focused; 229 focused_ = params.focused;
223 OnSetFocus(browser_plugin::kInstanceIDNone, focused_); 230 OnSetFocus(browser_plugin::kInstanceIDNone,
231 focused_,
232 blink::WebFocusTypeNone);
224 233
225 guest_visible_ = params.visible; 234 guest_visible_ = params.visible;
226 UpdateVisibility(); 235 UpdateVisibility();
227 236
228 is_full_page_plugin_ = params.is_full_page_plugin; 237 is_full_page_plugin_ = params.is_full_page_plugin;
229 guest_window_rect_ = gfx::Rect(params.origin, 238 guest_window_rect_ = gfx::Rect(params.origin,
230 params.resize_guest_params.view_size); 239 params.resize_guest_params.view_size);
231 240
232 if (owner_web_contents_ != owner_web_contents) { 241 if (owner_web_contents_ != owner_web_contents) {
233 WebContentsViewGuest* new_view = 242 WebContentsViewGuest* new_view =
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 delegate_->ElementSizeChanged(params.view_size); 750 delegate_->ElementSizeChanged(params.view_size);
742 last_seen_browser_plugin_size_ = params.view_size; 751 last_seen_browser_plugin_size_ = params.view_size;
743 } 752 }
744 753
745 // Just repaint the WebContents if needed. 754 // Just repaint the WebContents if needed.
746 if (params.repaint) 755 if (params.repaint)
747 Send(new ViewMsg_Repaint(routing_id(), params.view_size)); 756 Send(new ViewMsg_Repaint(routing_id(), params.view_size));
748 } 757 }
749 758
750 void BrowserPluginGuest::OnSetFocus(int browser_plugin_instance_id, 759 void BrowserPluginGuest::OnSetFocus(int browser_plugin_instance_id,
751 bool focused) { 760 bool focused,
761 blink::WebFocusType focus_type) {
752 RenderWidgetHostView* rwhv = web_contents()->GetRenderWidgetHostView(); 762 RenderWidgetHostView* rwhv = web_contents()->GetRenderWidgetHostView();
753 RenderWidgetHost* rwh = rwhv ? rwhv->GetRenderWidgetHost() : NULL; 763 RenderWidgetHost* rwh = rwhv ? rwhv->GetRenderWidgetHost() : NULL;
754 SetFocus(rwh, focused); 764 SetFocus(rwh, focused, focus_type);
755 } 765 }
756 766
757 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent( 767 void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent(
758 int browser_plugin_instance_id, 768 int browser_plugin_instance_id,
759 const std::vector<EditCommand>& edit_commands) { 769 const std::vector<EditCommand>& edit_commands) {
760 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(), 770 Send(new InputMsg_SetEditCommandsForNextKeyEvent(routing_id(),
761 edit_commands)); 771 edit_commands));
762 } 772 }
763 773
764 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id, 774 void BrowserPluginGuest::OnSetVisibility(int browser_plugin_instance_id,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 void BrowserPluginGuest::OnImeCompositionRangeChanged( 863 void BrowserPluginGuest::OnImeCompositionRangeChanged(
854 const gfx::Range& range, 864 const gfx::Range& range,
855 const std::vector<gfx::Rect>& character_bounds) { 865 const std::vector<gfx::Rect>& character_bounds) {
856 static_cast<RenderWidgetHostViewBase*>( 866 static_cast<RenderWidgetHostViewBase*>(
857 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 867 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
858 range, character_bounds); 868 range, character_bounds);
859 } 869 }
860 #endif 870 #endif
861 871
862 } // namespace content 872 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/browser/frame_host/render_widget_host_view_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698