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

Side by Side Diff: content/public/test/text_input_test_utils.cc

Issue 2045363002: Routing IME Result Calls to the Correct RenderWidgetHost (Aura Only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing a comment Created 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/public/test/text_input_test_utils.h" 5 #include "content/public/test/text_input_test_utils.h"
6 6
7 #include "content/browser/renderer_host/render_widget_host_impl.h"
7 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 8 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
8 #include "content/browser/renderer_host/render_widget_host_view_base.h" 9 #include "content/browser/renderer_host/render_widget_host_view_base.h"
9 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" 10 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h"
10 #include "content/browser/renderer_host/text_input_manager.h" 11 #include "content/browser/renderer_host/text_input_manager.h"
11 #include "content/browser/web_contents/web_contents_impl.h" 12 #include "content/browser/web_contents/web_contents_impl.h"
12 #include "content/common/text_input_state.h" 13 #include "content/common/text_input_state.h"
13 #include "content/public/browser/render_widget_host_view.h" 14 #include "content/public/browser/render_widget_host_view.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
16 #include "content/public/test/test_utils.h" 17 #include "content/public/test/test_utils.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 RenderWidgetHostViewBase* view_base = 194 RenderWidgetHostViewBase* view_base =
194 static_cast<RenderWidgetHostViewBase*>(view); 195 static_cast<RenderWidgetHostViewBase*>(view);
195 if (!manager || !manager->IsRegistered(view_base)) 196 if (!manager || !manager->IsRegistered(view_base))
196 return false; 197 return false;
197 198
198 *type = manager->text_input_state_map_[view_base].type; 199 *type = manager->text_input_state_map_[view_base].type;
199 return true; 200 return true;
200 } 201 }
201 202
202 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents) { 203 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents) {
203 return static_cast<WebContentsImpl*>(web_contents) 204 RenderWidgetHostImpl* host = static_cast<WebContentsImpl*>(web_contents)
204 ->GetTextInputManager() 205 ->GetTextInputManager()
205 ->GetActiveView(); 206 ->GetActiveWidget();
207 return !!host ? host->GetView() : nullptr;
206 } 208 }
207 209
208 TextInputManagerTester::TextInputManagerTester(WebContents* web_contents) 210 TextInputManagerTester::TextInputManagerTester(WebContents* web_contents)
209 : observer_(new InternalObserver(web_contents, this)) {} 211 : observer_(new InternalObserver(web_contents, this)) {}
210 212
211 TextInputManagerTester::~TextInputManagerTester() {} 213 TextInputManagerTester::~TextInputManagerTester() {}
212 214
213 void TextInputManagerTester::SetUpdateTextInputStateCalledCallback( 215 void TextInputManagerTester::SetUpdateTextInputStateCalledCallback(
214 const Callback& callback) { 216 const Callback& callback) {
215 observer_->set_update_text_input_state_called_callback(callback); 217 observer_->set_update_text_input_state_called_callback(callback);
(...skipping 14 matching lines...) Expand all
230 const TextInputState* state = 232 const TextInputState* state =
231 observer_->text_input_manager()->GetTextInputState(); 233 observer_->text_input_manager()->GetTextInputState();
232 if (!state) 234 if (!state)
233 return false; 235 return false;
234 *value = state->value; 236 *value = state->value;
235 return true; 237 return true;
236 } 238 }
237 239
238 const RenderWidgetHostView* TextInputManagerTester::GetActiveView() { 240 const RenderWidgetHostView* TextInputManagerTester::GetActiveView() {
239 DCHECK(observer_->text_input_manager()); 241 DCHECK(observer_->text_input_manager());
240 return observer_->text_input_manager()->GetActiveView(); 242 RenderWidgetHostImpl* host =
243 observer_->text_input_manager()->GetActiveWidget();
244 return !!host ? host->GetView() : nullptr;
241 } 245 }
242 246
243 const RenderWidgetHostView* TextInputManagerTester::GetUpdatedView() { 247 const RenderWidgetHostView* TextInputManagerTester::GetUpdatedView() {
244 return observer_->GetUpdatedView(); 248 return observer_->GetUpdatedView();
245 } 249 }
246 250
247 bool TextInputManagerTester::IsTextInputStateChanged() { 251 bool TextInputManagerTester::IsTextInputStateChanged() {
248 return observer_->text_input_state_changed(); 252 return observer_->text_input_state_changed();
249 } 253 }
250 254
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 320
317 #ifdef USE_AURA 321 #ifdef USE_AURA
318 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>( 322 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>(
319 web_contents->GetRenderWidgetHostView()); 323 web_contents->GetRenderWidgetHostView());
320 observer.reset(new InputMethodObserverAura(view->GetInputMethod())); 324 observer.reset(new InputMethodObserverAura(view->GetInputMethod()));
321 #endif 325 #endif
322 return observer; 326 return observer;
323 } 327 }
324 328
325 } // namespace content 329 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698