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

Side by Side Diff: ui/base/ime/mock_input_method.cc

Issue 23478020: Makes sure that an input method doesn't reference to a destroyed object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Worked on nits. Created 7 years, 3 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
« no previous file with comments | « ui/base/ime/mock_input_method.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base/ime/mock_input_method.h" 5 #include "ui/base/ime/mock_input_method.h"
6 6
7 namespace ui { 7 namespace ui {
8 8
9 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate) 9 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate)
10 : text_input_client_(NULL) { 10 : text_input_client_(NULL) {
11 } 11 }
12 12
13 MockInputMethod::~MockInputMethod() { 13 MockInputMethod::~MockInputMethod() {
14 } 14 }
15 15
16 void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) { 16 void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) {
17 } 17 }
18 18
19 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) { 19 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) {
20 if (text_input_client_ == client) 20 if (text_input_client_ == client)
21 return; 21 return;
22 text_input_client_ = client; 22 text_input_client_ = client;
23 if (client) 23 if (client)
24 OnTextInputTypeChanged(client); 24 OnTextInputTypeChanged(client);
25 } 25 }
26 26
27 void MockInputMethod::DetachTextInputClient(TextInputClient* client) {
28 if (text_input_client_ == client)
29 text_input_client_ = NULL;
30 }
31
27 TextInputClient* MockInputMethod::GetTextInputClient() const { 32 TextInputClient* MockInputMethod::GetTextInputClient() const {
28 return text_input_client_; 33 return text_input_client_;
29 } 34 }
30 35
31 bool MockInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) { 36 bool MockInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) {
32 return false; 37 return false;
33 } 38 }
34 39
35 bool MockInputMethod::DispatchFabricatedKeyEvent(const ui::KeyEvent& event) { 40 bool MockInputMethod::DispatchFabricatedKeyEvent(const ui::KeyEvent& event) {
36 return false; 41 return false;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 106
102 void MockInputMethod::AddObserver(InputMethodObserver* observer) { 107 void MockInputMethod::AddObserver(InputMethodObserver* observer) {
103 observer_list_.AddObserver(static_cast<Observer*>(observer)); 108 observer_list_.AddObserver(static_cast<Observer*>(observer));
104 } 109 }
105 110
106 void MockInputMethod::RemoveObserver(InputMethodObserver* observer) { 111 void MockInputMethod::RemoveObserver(InputMethodObserver* observer) {
107 observer_list_.RemoveObserver(static_cast<Observer*>(observer)); 112 observer_list_.RemoveObserver(static_cast<Observer*>(observer));
108 } 113 }
109 114
110 } // namespace ui 115 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/mock_input_method.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698