Chromium Code Reviews| 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 "ui/views/controls/webview/webview.h" | 5 #include "ui/views/controls/webview/webview.h" |
| 6 | 6 |
| 7 #include "content/public/browser/browser_accessibility_state.h" | 7 #include "content/public/browser/browser_accessibility_state.h" |
| 8 #include "content/public/browser/browser_context.h" | 8 #include "content/public/browser/browser_context.h" |
| 9 #include "content/public/browser/navigation_controller.h" | 9 #include "content/public/browser/navigation_controller.h" |
| 10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| 11 #include "content/public/browser/render_widget_host_view.h" | 11 #include "content/public/browser/render_widget_host_view.h" |
| 12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/browser/web_contents_view.h" | 13 #include "content/public/browser/web_contents_view.h" |
| 14 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
| 15 #include "ui/accessibility/ax_enums.h" | 15 #include "ui/accessibility/ax_enums.h" |
| 16 #include "ui/accessibility/ax_view_state.h" | 16 #include "ui/accessibility/ax_view_state.h" |
| 17 #include "ui/base/ui_base_switches_util.h" | |
| 17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
| 18 #include "ui/views/accessibility/native_view_accessibility.h" | 19 #include "ui/views/accessibility/native_view_accessibility.h" |
| 19 #include "ui/views/controls/native/native_view_host.h" | 20 #include "ui/views/controls/native/native_view_host.h" |
| 20 #include "ui/views/focus/focus_manager.h" | 21 #include "ui/views/focus/focus_manager.h" |
| 21 #include "ui/views/views_delegate.h" | 22 #include "ui/views/views_delegate.h" |
| 22 | 23 |
| 23 namespace views { | 24 namespace views { |
| 24 | 25 |
| 25 // static | 26 // static |
| 26 const char WebView::kViewClassName[] = "WebView"; | 27 const char WebView::kViewClassName[] = "WebView"; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 } else { | 150 } else { |
| 150 web_contents()->GetView()->Focus(); | 151 web_contents()->GetView()->Focus(); |
| 151 } | 152 } |
| 152 } | 153 } |
| 153 | 154 |
| 154 void WebView::AboutToRequestFocusFromTabTraversal(bool reverse) { | 155 void WebView::AboutToRequestFocusFromTabTraversal(bool reverse) { |
| 155 if (web_contents()) | 156 if (web_contents()) |
| 156 web_contents()->FocusThroughTabTraversal(reverse); | 157 web_contents()->FocusThroughTabTraversal(reverse); |
| 157 } | 158 } |
| 158 | 159 |
| 160 ui::TextInputClient* WebView::GetTextInputClient() { | |
| 161 if (!switches::IsNewTextInputFocusEnabled()) | |
|
msw
2014/03/11 00:58:50
nit: just make this condition part of the if state
Yuki
2014/03/11 15:27:37
Done.
| |
| 162 return NULL; | |
| 163 | |
| 164 if (web_contents() && !web_contents()->IsBeingDestroyed()) { | |
| 165 content::RenderWidgetHostView* host_view = | |
| 166 web_contents()->GetRenderWidgetHostView(); | |
| 167 if (host_view) | |
| 168 return host_view->GetTextInputClient(); | |
| 169 } | |
| 170 return NULL; | |
| 171 } | |
| 172 | |
| 159 void WebView::GetAccessibleState(ui::AXViewState* state) { | 173 void WebView::GetAccessibleState(ui::AXViewState* state) { |
| 160 state->role = ui::AX_ROLE_GROUP; | 174 state->role = ui::AX_ROLE_GROUP; |
| 161 } | 175 } |
| 162 | 176 |
| 163 gfx::NativeViewAccessible WebView::GetNativeViewAccessible() { | 177 gfx::NativeViewAccessible WebView::GetNativeViewAccessible() { |
| 164 if (web_contents()) { | 178 if (web_contents()) { |
| 165 content::RenderWidgetHostView* host_view = | 179 content::RenderWidgetHostView* host_view = |
| 166 web_contents()->GetRenderWidgetHostView(); | 180 web_contents()->GetRenderWidgetHostView(); |
| 167 if (host_view) | 181 if (host_view) |
| 168 return host_view->GetNativeViewAccessible(); | 182 return host_view->GetNativeViewAccessible(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 187 } | 201 } |
| 188 | 202 |
| 189 bool WebView::EmbedsFullscreenWidget() const { | 203 bool WebView::EmbedsFullscreenWidget() const { |
| 190 DCHECK(wc_owner_.get()); | 204 DCHECK(wc_owner_.get()); |
| 191 return embed_fullscreen_widget_mode_enabled_; | 205 return embed_fullscreen_widget_mode_enabled_; |
| 192 } | 206 } |
| 193 | 207 |
| 194 //////////////////////////////////////////////////////////////////////////////// | 208 //////////////////////////////////////////////////////////////////////////////// |
| 195 // WebView, content::WebContentsObserver implementation: | 209 // WebView, content::WebContentsObserver implementation: |
| 196 | 210 |
| 211 void WebView::RenderViewDeleted(content::RenderViewHost* render_view_host) { | |
| 212 // WebView::GetTextInputClient() delegates the text input handling to the | |
|
msw
2014/03/11 00:58:50
This comment doesn't explain why you'd want to set
Yuki
2014/03/11 15:27:37
I've updated the comment trying to make it clearer
msw
2014/03/11 23:24:37
That makes sense, thanks for the explanation and c
| |
| 213 // underlying content::RenderWidgetHostView. So when it's destroyed, we have | |
| 214 // to change the focused text input client. | |
| 215 FocusManager* const focus_manager = GetFocusManager(); | |
| 216 if (focus_manager) | |
| 217 focus_manager->OnTextInputClientChanged(this); | |
| 218 } | |
| 219 | |
| 197 void WebView::RenderViewHostChanged(content::RenderViewHost* old_host, | 220 void WebView::RenderViewHostChanged(content::RenderViewHost* old_host, |
| 198 content::RenderViewHost* new_host) { | 221 content::RenderViewHost* new_host) { |
| 199 FocusManager* const focus_manager = GetFocusManager(); | 222 FocusManager* const focus_manager = GetFocusManager(); |
| 200 if (focus_manager && focus_manager->GetFocusedView() == this) | 223 if (focus_manager && focus_manager->GetFocusedView() == this) |
| 201 OnFocus(); | 224 OnFocus(); |
| 202 } | 225 } |
| 203 | 226 |
| 204 void WebView::WebContentsDestroyed(content::WebContents* web_contents) { | 227 void WebView::WebContentsDestroyed(content::WebContents* web_contents) { |
| 205 // We watch for destruction of WebContents that we host but do not own. If we | 228 // We watch for destruction of WebContents that we host but do not own. If we |
| 206 // own a WebContents that is being destroyed, we're doing the destroying, so | 229 // own a WebContents that is being destroyed, we're doing the destroying, so |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 if (!contents) { | 313 if (!contents) { |
| 291 content::WebContents::CreateParams create_params( | 314 content::WebContents::CreateParams create_params( |
| 292 browser_context, NULL); | 315 browser_context, NULL); |
| 293 return content::WebContents::Create(create_params); | 316 return content::WebContents::Create(create_params); |
| 294 } | 317 } |
| 295 | 318 |
| 296 return contents; | 319 return contents; |
| 297 } | 320 } |
| 298 | 321 |
| 299 } // namespace views | 322 } // namespace views |
| OLD | NEW |