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

Side by Side Diff: ui/views/controls/webview/webview.cc

Issue 1182523003: Removes TextInputFocusManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit per comment. Created 5 years, 6 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 "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_process_host.h" 10 #include "content/public/browser/render_process_host.h"
11 #include "content/public/browser/render_view_host.h" 11 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/render_widget_host_view.h" 12 #include "content/public/browser/render_widget_host_view.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.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"
18 #include "ui/events/event.h" 17 #include "ui/events/event.h"
19 #include "ui/views/controls/native/native_view_host.h" 18 #include "ui/views/controls/native/native_view_host.h"
20 #include "ui/views/focus/focus_manager.h" 19 #include "ui/views/focus/focus_manager.h"
21 #include "ui/views/views_delegate.h" 20 #include "ui/views/views_delegate.h"
22 21
23 namespace views { 22 namespace views {
24 23
25 // static 24 // static
26 const char WebView::kViewClassName[] = "WebView"; 25 const char WebView::kViewClassName[] = "WebView";
27 26
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 103 }
105 104
106 //////////////////////////////////////////////////////////////////////////////// 105 ////////////////////////////////////////////////////////////////////////////////
107 // WebView, View overrides: 106 // WebView, View overrides:
108 107
109 const char* WebView::GetClassName() const { 108 const char* WebView::GetClassName() const {
110 return kViewClassName; 109 return kViewClassName;
111 } 110 }
112 111
113 ui::TextInputClient* WebView::GetTextInputClient() { 112 ui::TextInputClient* WebView::GetTextInputClient() {
114 // This function delegates the text input handling to the underlying
115 // content::RenderWidgetHostView. So when the underlying RWHV is destroyed or
116 // replaced with another one, we have to notify the FocusManager through
117 // FocusManager::OnTextInputClientChanged() that the focused TextInputClient
118 // needs to be updated.
119 if (switches::IsTextInputFocusManagerEnabled() &&
120 web_contents() && !web_contents()->IsBeingDestroyed()) {
121 const content::RenderViewHost* host = web_contents()->GetRenderViewHost();
122 content::RenderWidgetHostView* host_view =
123 is_embedding_fullscreen_widget_ ?
124 web_contents()->GetFullscreenRenderWidgetHostView() :
125 web_contents()->GetRenderWidgetHostView();
126 if (host && host->IsRenderViewLive() && host_view)
127 return host_view->GetTextInputClient();
128 }
129 return NULL; 113 return NULL;
130 } 114 }
131 115
132 scoped_ptr<content::WebContents> WebView::SwapWebContents( 116 scoped_ptr<content::WebContents> WebView::SwapWebContents(
133 scoped_ptr<content::WebContents> new_web_contents) { 117 scoped_ptr<content::WebContents> new_web_contents) {
134 if (wc_owner_) 118 if (wc_owner_)
135 wc_owner_->SetDelegate(NULL); 119 wc_owner_->SetDelegate(NULL);
136 scoped_ptr<content::WebContents> old_web_contents(wc_owner_.Pass()); 120 scoped_ptr<content::WebContents> old_web_contents(wc_owner_.Pass());
137 wc_owner_ = new_web_contents.Pass(); 121 wc_owner_ = new_web_contents.Pass();
138 if (wc_owner_) 122 if (wc_owner_)
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 AttachWebContents(); 370 AttachWebContents();
387 } else { 371 } else {
388 // Entering or exiting "non-Flash" fullscreen mode, where the native view is 372 // Entering or exiting "non-Flash" fullscreen mode, where the native view is
389 // the same. So, do not change attachment. 373 // the same. So, do not change attachment.
390 OnBoundsChanged(bounds()); 374 OnBoundsChanged(bounds());
391 } 375 }
392 NotifyMaybeTextInputClientAndAccessibilityChanged(); 376 NotifyMaybeTextInputClientAndAccessibilityChanged();
393 } 377 }
394 378
395 void WebView::NotifyMaybeTextInputClientAndAccessibilityChanged() { 379 void WebView::NotifyMaybeTextInputClientAndAccessibilityChanged() {
396 // Update the TextInputClient as needed; see GetTextInputClient().
397 FocusManager* const focus_manager = GetFocusManager();
398 if (focus_manager)
399 focus_manager->OnTextInputClientChanged(this);
400
401 #if defined(OS_CHROMEOS) 380 #if defined(OS_CHROMEOS)
402 if (web_contents()) 381 if (web_contents())
403 NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, false); 382 NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, false);
404 #endif // defined OS_CHROMEOS 383 #endif // defined OS_CHROMEOS
405 } 384 }
406 385
407 content::WebContents* WebView::CreateWebContents( 386 content::WebContents* WebView::CreateWebContents(
408 content::BrowserContext* browser_context) { 387 content::BrowserContext* browser_context) {
409 content::WebContents* contents = NULL; 388 content::WebContents* contents = NULL;
410 if (ViewsDelegate::GetInstance()) { 389 if (ViewsDelegate::GetInstance()) {
411 contents = 390 contents =
412 ViewsDelegate::GetInstance()->CreateWebContents(browser_context, NULL); 391 ViewsDelegate::GetInstance()->CreateWebContents(browser_context, NULL);
413 } 392 }
414 393
415 if (!contents) { 394 if (!contents) {
416 content::WebContents::CreateParams create_params( 395 content::WebContents::CreateParams create_params(
417 browser_context, NULL); 396 browser_context, NULL);
418 return content::WebContents::Create(create_params); 397 return content::WebContents::Create(create_params);
419 } 398 }
420 399
421 return contents; 400 return contents;
422 } 401 }
423 402
424 } // namespace views 403 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.mm ('k') | ui/views/controls/webview/webview_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698