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

Side by Side Diff: ui/base/ime/fake_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/fake_input_method.h ('k') | ui/base/ime/input_method.h » ('j') | 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/fake_input_method.h" 5 #include "ui/base/ime/fake_input_method.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "ui/base/events/event.h" 9 #include "ui/base/events/event.h"
10 #include "ui/base/events/event_constants.h" 10 #include "ui/base/events/event_constants.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 void FakeInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) { 48 void FakeInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) {
49 delegate_ = delegate; 49 delegate_ = delegate;
50 } 50 }
51 51
52 void FakeInputMethod::SetFocusedTextInputClient(TextInputClient* client) { 52 void FakeInputMethod::SetFocusedTextInputClient(TextInputClient* client) {
53 text_input_client_ = client; 53 text_input_client_ = client;
54 FOR_EACH_OBSERVER(InputMethodObserver, observers_, 54 FOR_EACH_OBSERVER(InputMethodObserver, observers_,
55 OnTextInputStateChanged(client)); 55 OnTextInputStateChanged(client));
56 } 56 }
57 57
58 void FakeInputMethod::DetachTextInputClient(TextInputClient* client) {
59 if (text_input_client_ == client) {
60 text_input_client_ = NULL;
61 FOR_EACH_OBSERVER(InputMethodObserver, observers_,
62 OnTextInputStateChanged(client));
63 }
64 }
65
58 TextInputClient* FakeInputMethod::GetTextInputClient() const { 66 TextInputClient* FakeInputMethod::GetTextInputClient() const {
59 return text_input_client_; 67 return text_input_client_;
60 } 68 }
61 69
62 bool FakeInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) { 70 bool FakeInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) {
63 bool handled = false; 71 bool handled = false;
64 #if defined(OS_WIN) 72 #if defined(OS_WIN)
65 if (native_event.message == WM_CHAR) { 73 if (native_event.message == WM_CHAR) {
66 if (text_input_client_) { 74 if (text_input_client_) {
67 text_input_client_->InsertChar(ui::KeyboardCodeFromNative(native_event), 75 text_input_client_->InsertChar(ui::KeyboardCodeFromNative(native_event),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 163
156 void FakeInputMethod::AddObserver(InputMethodObserver* observer) { 164 void FakeInputMethod::AddObserver(InputMethodObserver* observer) {
157 observers_.AddObserver(observer); 165 observers_.AddObserver(observer);
158 } 166 }
159 167
160 void FakeInputMethod::RemoveObserver(InputMethodObserver* observer) { 168 void FakeInputMethod::RemoveObserver(InputMethodObserver* observer) {
161 observers_.RemoveObserver(observer); 169 observers_.RemoveObserver(observer);
162 } 170 }
163 171
164 } // namespace ui 172 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/fake_input_method.h ('k') | ui/base/ime/input_method.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698