OLD | NEW |
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 <unordered_set> | 7 #include <unordered_set> |
8 | 8 |
9 #include "content/browser/frame_host/render_frame_host_impl.h" | 9 #include "content/browser/frame_host/render_frame_host_impl.h" |
10 #include "content/browser/renderer_host/render_widget_host_impl.h" | 10 #include "content/browser/renderer_host/render_widget_host_impl.h" |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 bool TextInputManagerTester::GetCurrentTextSelectionLength(size_t* length) { | 349 bool TextInputManagerTester::GetCurrentTextSelectionLength(size_t* length) { |
350 DCHECK(observer_->text_input_manager()); | 350 DCHECK(observer_->text_input_manager()); |
351 | 351 |
352 if (!observer_->text_input_manager()->GetActiveWidget()) | 352 if (!observer_->text_input_manager()->GetActiveWidget()) |
353 return false; | 353 return false; |
354 | 354 |
355 *length = observer_->text_input_manager()->GetTextSelection()->text().size(); | 355 *length = observer_->text_input_manager()->GetTextSelection()->text().size(); |
356 return true; | 356 return true; |
357 } | 357 } |
358 | 358 |
359 bool TextInputManagerTester::GetTextSelectionUserInitiatedForView( | |
360 RenderWidgetHostView* view, | |
361 bool* user_initiated) { | |
362 TextInputManager* manager = observer_->text_input_manager(); | |
363 DCHECK(manager); | |
364 | |
365 RenderWidgetHostViewBase* view_base = | |
366 static_cast<RenderWidgetHostViewBase*>(view); | |
367 if (!manager->IsRegistered(view_base)) | |
368 return false; | |
369 | |
370 *user_initiated = manager->GetTextSelection(view_base)->user_initiated(); | |
371 return true; | |
372 } | |
373 | |
374 bool TextInputManagerTester::IsTextInputStateChanged() { | 359 bool TextInputManagerTester::IsTextInputStateChanged() { |
375 return observer_->text_input_state_changed(); | 360 return observer_->text_input_state_changed(); |
376 } | 361 } |
377 | 362 |
378 TestRenderWidgetHostViewDestructionObserver:: | 363 TestRenderWidgetHostViewDestructionObserver:: |
379 TestRenderWidgetHostViewDestructionObserver(RenderWidgetHostView* view) | 364 TestRenderWidgetHostViewDestructionObserver(RenderWidgetHostView* view) |
380 : observer_( | 365 : observer_( |
381 new InternalObserver(static_cast<RenderWidgetHostViewBase*>(view))) {} | 366 new InternalObserver(static_cast<RenderWidgetHostViewBase*>(view))) {} |
382 | 367 |
383 TestRenderWidgetHostViewDestructionObserver:: | 368 TestRenderWidgetHostViewDestructionObserver:: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 424 |
440 #ifdef USE_AURA | 425 #ifdef USE_AURA |
441 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>( | 426 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>( |
442 web_contents->GetRenderWidgetHostView()); | 427 web_contents->GetRenderWidgetHostView()); |
443 observer.reset(new InputMethodObserverAura(view->GetInputMethod())); | 428 observer.reset(new InputMethodObserverAura(view->GetInputMethod())); |
444 #endif | 429 #endif |
445 return observer; | 430 return observer; |
446 } | 431 } |
447 | 432 |
448 } // namespace content | 433 } // namespace content |
OLD | NEW |