| 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 |
| 359 bool TextInputManagerTester::IsTextInputStateChanged() { | 374 bool TextInputManagerTester::IsTextInputStateChanged() { |
| 360 return observer_->text_input_state_changed(); | 375 return observer_->text_input_state_changed(); |
| 361 } | 376 } |
| 362 | 377 |
| 363 TestRenderWidgetHostViewDestructionObserver:: | 378 TestRenderWidgetHostViewDestructionObserver:: |
| 364 TestRenderWidgetHostViewDestructionObserver(RenderWidgetHostView* view) | 379 TestRenderWidgetHostViewDestructionObserver(RenderWidgetHostView* view) |
| 365 : observer_( | 380 : observer_( |
| 366 new InternalObserver(static_cast<RenderWidgetHostViewBase*>(view))) {} | 381 new InternalObserver(static_cast<RenderWidgetHostViewBase*>(view))) {} |
| 367 | 382 |
| 368 TestRenderWidgetHostViewDestructionObserver:: | 383 TestRenderWidgetHostViewDestructionObserver:: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 439 |
| 425 #ifdef USE_AURA | 440 #ifdef USE_AURA |
| 426 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>( | 441 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>( |
| 427 web_contents->GetRenderWidgetHostView()); | 442 web_contents->GetRenderWidgetHostView()); |
| 428 observer.reset(new InputMethodObserverAura(view->GetInputMethod())); | 443 observer.reset(new InputMethodObserverAura(view->GetInputMethod())); |
| 429 #endif | 444 #endif |
| 430 return observer; | 445 return observer; |
| 431 } | 446 } |
| 432 | 447 |
| 433 } // namespace content | 448 } // namespace content |
| OLD | NEW |