Chromium Code Reviews| Index: ui/views/controls/webview/webview.cc |
| diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc |
| index 8da7e22ae11d704d44e81b4eb733fab4abcaa963..e04a5d0997743219cfbed88256d41dc39c73a453 100644 |
| --- a/ui/views/controls/webview/webview.cc |
| +++ b/ui/views/controls/webview/webview.cc |
| @@ -14,6 +14,7 @@ |
| #include "ipc/ipc_message.h" |
| #include "ui/accessibility/ax_enums.h" |
| #include "ui/accessibility/ax_view_state.h" |
| +#include "ui/base/ui_base_switches_util.h" |
| #include "ui/events/event.h" |
| #include "ui/views/accessibility/native_view_accessibility.h" |
| #include "ui/views/controls/native/native_view_host.h" |
| @@ -67,6 +68,7 @@ void WebView::SetWebContents(content::WebContents* replacement) { |
| DCHECK(!is_embedding_fullscreen_widget_); |
| } |
| AttachWebContents(); |
| + NotifyMaybeTextInputClientChanged(); |
| } |
| void WebView::SetEmbedFullscreenWidgetMode(bool enable) { |
| @@ -103,6 +105,25 @@ const char* WebView::GetClassName() const { |
| return kViewClassName; |
| } |
| +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. |
| + |
|
msw
2014/04/18 19:57:57
nit: remove blank line
Yuki
2014/04/22 09:09:02
Done.
|
| + 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; |
| +} |
| + |
| void WebView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| // In most cases, the holder is simply sized to fill this WebView's bounds. |
| // Only WebContentses that are in fullscreen mode and being screen-captured |
| @@ -229,11 +250,16 @@ bool WebView::EmbedsFullscreenWidget() const { |
| //////////////////////////////////////////////////////////////////////////////// |
| // WebView, content::WebContentsObserver implementation: |
| +void WebView::RenderViewDeleted(content::RenderViewHost* render_view_host) { |
| + NotifyMaybeTextInputClientChanged(); |
| +} |
| + |
| void WebView::RenderViewHostChanged(content::RenderViewHost* old_host, |
| content::RenderViewHost* new_host) { |
| FocusManager* const focus_manager = GetFocusManager(); |
| if (focus_manager && focus_manager->GetFocusedView() == this) |
| OnFocus(); |
| + NotifyMaybeTextInputClientChanged(); |
| } |
| void WebView::DidShowFullscreenWidget(int routing_id) { |
| @@ -309,6 +335,14 @@ void WebView::ReattachForFullscreenChange(bool enter_fullscreen) { |
| // the same. So, do not change attachment. |
| OnBoundsChanged(bounds()); |
| } |
| + NotifyMaybeTextInputClientChanged(); |
| +} |
| + |
| +void WebView::NotifyMaybeTextInputClientChanged() { |
| + // Update the TextInputClient as needed; see GetTextInputClient(). |
| + FocusManager* const focus_manager = GetFocusManager(); |
|
msw
2014/04/18 19:57:57
nit: remove const.
Yuki
2014/04/22 09:09:02
I'm okay to remove this const, but this is the sty
msw
2014/04/22 17:12:56
Okay, the style guide says encourages putting cons
Yuki
2014/04/23 03:53:40
Thanks.
Just FYI, const T* and T* const have diff
msw
2014/04/23 04:50:12
Right, I'm aware of the significance, but I believ
|
| + if (focus_manager) |
| + focus_manager->OnTextInputClientChanged(this); |
| } |
| content::WebContents* WebView::CreateWebContents( |