| 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/pickle.h" | 10 #include "base/pickle.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 static_cast<RenderViewHostImpl*>(RenderViewHost::From(rwh))-> | 172 static_cast<RenderViewHostImpl*>(RenderViewHost::From(rwh))-> |
| 173 SetInitialFocus(focus_type == blink::WebFocusTypeBackward); | 173 SetInitialFocus(focus_type == blink::WebFocusTypeBackward); |
| 174 } | 174 } |
| 175 rwh->Send(new InputMsg_SetFocus(rwh->GetRoutingID(), focused)); | 175 rwh->Send(new InputMsg_SetFocus(rwh->GetRoutingID(), focused)); |
| 176 if (!focused && mouse_locked_) | 176 if (!focused && mouse_locked_) |
| 177 OnUnlockMouse(); | 177 OnUnlockMouse(); |
| 178 | 178 |
| 179 // Restore the last seen state of text input to the view. | 179 // Restore the last seen state of text input to the view. |
| 180 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>( | 180 RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>( |
| 181 rwh->GetView()); | 181 rwh->GetView()); |
| 182 if (rwhv) { | 182 SendTextInputTypeChangedToView(rwhv); |
| 183 rwhv->TextInputTypeChanged(last_text_input_type_, last_input_mode_, | |
| 184 last_can_compose_inline_, last_input_flags_); | |
| 185 } | |
| 186 } | 183 } |
| 187 | 184 |
| 188 void BrowserPluginGuest::SetTooltipText(const base::string16& tooltip_text) { | 185 void BrowserPluginGuest::SetTooltipText(const base::string16& tooltip_text) { |
| 189 if (tooltip_text == current_tooltip_text_) | 186 if (tooltip_text == current_tooltip_text_) |
| 190 return; | 187 return; |
| 191 current_tooltip_text_ = tooltip_text; | 188 current_tooltip_text_ = tooltip_text; |
| 192 | 189 |
| 193 SendMessageToEmbedder(new BrowserPluginMsg_SetTooltipText( | 190 SendMessageToEmbedder(new BrowserPluginMsg_SetTooltipText( |
| 194 browser_plugin_instance_id_, tooltip_text)); | 191 browser_plugin_instance_id_, tooltip_text)); |
| 195 } | 192 } |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 if (!attached()) | 484 if (!attached()) |
| 488 return; | 485 return; |
| 489 | 486 |
| 490 while (!pending_messages_.empty()) { | 487 while (!pending_messages_.empty()) { |
| 491 linked_ptr<IPC::Message> message_ptr = pending_messages_.front(); | 488 linked_ptr<IPC::Message> message_ptr = pending_messages_.front(); |
| 492 pending_messages_.pop_front(); | 489 pending_messages_.pop_front(); |
| 493 SendMessageToEmbedder(message_ptr.release()); | 490 SendMessageToEmbedder(message_ptr.release()); |
| 494 } | 491 } |
| 495 } | 492 } |
| 496 | 493 |
| 494 void BrowserPluginGuest::SendTextInputTypeChangedToView( |
| 495 RenderWidgetHostViewBase* guest_rwhv) { |
| 496 if (!guest_rwhv) |
| 497 return; |
| 498 |
| 499 guest_rwhv->TextInputTypeChanged(last_text_input_type_, last_input_mode_, |
| 500 last_can_compose_inline_, last_input_flags_); |
| 501 // Enable input method for guest if it's enabled for the embedder. |
| 502 if (!static_cast<RenderViewHostImpl*>( |
| 503 owner_web_contents_->GetRenderViewHost())->input_method_active()) { |
| 504 return; |
| 505 } |
| 506 RenderViewHostImpl* guest_rvh = |
| 507 static_cast<RenderViewHostImpl*>(GetWebContents()->GetRenderViewHost()); |
| 508 guest_rvh->SetInputMethodActive(true); |
| 509 } |
| 510 |
| 497 void BrowserPluginGuest::DidCommitProvisionalLoadForFrame( | 511 void BrowserPluginGuest::DidCommitProvisionalLoadForFrame( |
| 498 RenderFrameHost* render_frame_host, | 512 RenderFrameHost* render_frame_host, |
| 499 const GURL& url, | 513 const GURL& url, |
| 500 ui::PageTransition transition_type) { | 514 ui::PageTransition transition_type) { |
| 501 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate")); | 515 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.DidNavigate")); |
| 502 } | 516 } |
| 503 | 517 |
| 504 void BrowserPluginGuest::RenderViewReady() { | 518 void BrowserPluginGuest::RenderViewReady() { |
| 505 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); | 519 RenderViewHost* rvh = GetWebContents()->GetRenderViewHost(); |
| 506 // TODO(fsamuel): Investigate whether it's possible to update state earlier | 520 // TODO(fsamuel): Investigate whether it's possible to update state earlier |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 void BrowserPluginGuest::OnTextInputTypeChanged(ui::TextInputType type, | 895 void BrowserPluginGuest::OnTextInputTypeChanged(ui::TextInputType type, |
| 882 ui::TextInputMode input_mode, | 896 ui::TextInputMode input_mode, |
| 883 bool can_compose_inline, | 897 bool can_compose_inline, |
| 884 int flags) { | 898 int flags) { |
| 885 // Save the state of text input so we can restore it on focus. | 899 // Save the state of text input so we can restore it on focus. |
| 886 last_text_input_type_ = type; | 900 last_text_input_type_ = type; |
| 887 last_input_mode_ = input_mode; | 901 last_input_mode_ = input_mode; |
| 888 last_input_flags_ = flags; | 902 last_input_flags_ = flags; |
| 889 last_can_compose_inline_ = can_compose_inline; | 903 last_can_compose_inline_ = can_compose_inline; |
| 890 | 904 |
| 891 static_cast<RenderWidgetHostViewBase*>( | 905 SendTextInputTypeChangedToView( |
| 892 web_contents()->GetRenderWidgetHostView())->TextInputTypeChanged( | 906 static_cast<RenderWidgetHostViewBase*>( |
| 893 type, input_mode, can_compose_inline, flags); | 907 web_contents()->GetRenderWidgetHostView())); |
| 894 } | 908 } |
| 895 | 909 |
| 896 void BrowserPluginGuest::OnImeCancelComposition() { | 910 void BrowserPluginGuest::OnImeCancelComposition() { |
| 897 static_cast<RenderWidgetHostViewBase*>( | 911 static_cast<RenderWidgetHostViewBase*>( |
| 898 web_contents()->GetRenderWidgetHostView())->ImeCancelComposition(); | 912 web_contents()->GetRenderWidgetHostView())->ImeCancelComposition(); |
| 899 } | 913 } |
| 900 | 914 |
| 901 #if defined(OS_MACOSX) || defined(USE_AURA) | 915 #if defined(OS_MACOSX) || defined(USE_AURA) |
| 902 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 916 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
| 903 const gfx::Range& range, | 917 const gfx::Range& range, |
| 904 const std::vector<gfx::Rect>& character_bounds) { | 918 const std::vector<gfx::Rect>& character_bounds) { |
| 905 static_cast<RenderWidgetHostViewBase*>( | 919 static_cast<RenderWidgetHostViewBase*>( |
| 906 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 920 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
| 907 range, character_bounds); | 921 range, character_bounds); |
| 908 } | 922 } |
| 909 #endif | 923 #endif |
| 910 | 924 |
| 911 } // namespace content | 925 } // namespace content |
| OLD | NEW |