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

Side by Side Diff: ui/base/ime/input_method_base.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/input_method_base.h ('k') | ui/base/ime/mock_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/input_method_base.h" 5 #include "ui/base/ime/input_method_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/ime/input_method_delegate.h" 8 #include "ui/base/ime/input_method_delegate.h"
9 #include "ui/base/ime/input_method_observer.h" 9 #include "ui/base/ime/input_method_observer.h"
10 #include "ui/base/ime/text_input_client.h" 10 #include "ui/base/ime/text_input_client.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 void InputMethodBase::SetFocusedTextInputClient(TextInputClient* client) { 45 void InputMethodBase::SetFocusedTextInputClient(TextInputClient* client) {
46 TextInputClient* old = text_input_client_; 46 TextInputClient* old = text_input_client_;
47 OnWillChangeFocusedClient(old, client); 47 OnWillChangeFocusedClient(old, client);
48 text_input_client_ = client; // NULL allowed. 48 text_input_client_ = client; // NULL allowed.
49 OnDidChangeFocusedClient(old, client); 49 OnDidChangeFocusedClient(old, client);
50 50
51 if (old != text_input_client_) 51 if (old != text_input_client_)
52 NotifyTextInputStateChanged(text_input_client_); 52 NotifyTextInputStateChanged(text_input_client_);
53 } 53 }
54 54
55 void InputMethodBase::DetachTextInputClient(TextInputClient* client) {
56 if (text_input_client_ == client) {
57 OnWillChangeFocusedClient(client, NULL);
58 text_input_client_ = NULL;
59 OnDidChangeFocusedClient(client, NULL);
60 NotifyTextInputStateChanged(text_input_client_);
61 }
62 }
63
55 TextInputClient* InputMethodBase::GetTextInputClient() const { 64 TextInputClient* InputMethodBase::GetTextInputClient() const {
56 return system_toplevel_window_focused_ ? text_input_client_ : NULL; 65 return system_toplevel_window_focused_ ? text_input_client_ : NULL;
57 } 66 }
58 67
59 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { 68 void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) {
60 if (!IsTextInputClientFocused(client)) 69 if (!IsTextInputClientFocused(client))
61 return; 70 return;
62 NotifyTextInputStateChanged(client); 71 NotifyTextInputStateChanged(client);
63 } 72 }
64 73
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 121 }
113 122
114 void InputMethodBase::NotifyTextInputStateChanged( 123 void InputMethodBase::NotifyTextInputStateChanged(
115 const TextInputClient* client) { 124 const TextInputClient* client) {
116 FOR_EACH_OBSERVER(InputMethodObserver, 125 FOR_EACH_OBSERVER(InputMethodObserver,
117 observer_list_, 126 observer_list_,
118 OnTextInputStateChanged(client)); 127 OnTextInputStateChanged(client));
119 } 128 }
120 129
121 } // namespace ui 130 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_base.h ('k') | ui/base/ime/mock_input_method.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698