+ui::TextInputClient* WebView::GetTextInputClient() {
+ // This function delegates the text input handling to the underlying
+ // content::RenderWidgetHostView. So when the underlying RWHV is destroyed or
+ // replaced with another one, we have to notify the FocusManager through
+ // FocusManager::OnTextInputClientChanged() that the focused TextInputClient
+ // needs to be updated.
+ if (switches::IsTextInputFocusManagerEnabled() &&
+ web_contents() && !web_contents()->IsBeingDestroyed()) {
+ content::RenderWidgetHostView* host_view =
+ is_embedding_fullscreen_widget_ ?
+ web_contents()->GetFullscreenRenderWidgetHostView() :
+ web_contents()->GetRenderWidgetHostView();
+ if (host_view)
+ return host_view->GetTextInputClient();
+ }
+ return NULL;
+}
+