OLD | NEW |
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/win/tsf_input_scope.h" | 5 #include "ui/base/ime/win/tsf_input_scope.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 if (input_scope == IS_DEFAULT) | 22 if (input_scope == IS_DEFAULT) |
23 return; | 23 return; |
24 | 24 |
25 if (std::find(input_scopes->begin(), input_scopes->end(), input_scope) != | 25 if (std::find(input_scopes->begin(), input_scopes->end(), input_scope) != |
26 input_scopes->end()) | 26 input_scopes->end()) |
27 return; | 27 return; |
28 | 28 |
29 input_scopes->push_back(input_scope); | 29 input_scopes->push_back(input_scope); |
30 } | 30 } |
31 | 31 |
32 class TSFInputScope FINAL : public ITfInputScope { | 32 class TSFInputScope final : public ITfInputScope { |
33 public: | 33 public: |
34 explicit TSFInputScope(const std::vector<InputScope>& input_scopes) | 34 explicit TSFInputScope(const std::vector<InputScope>& input_scopes) |
35 : input_scopes_(input_scopes), | 35 : input_scopes_(input_scopes), |
36 ref_count_(0) {} | 36 ref_count_(0) {} |
37 | 37 |
38 // ITfInputScope: | 38 // ITfInputScope: |
39 STDMETHOD_(ULONG, AddRef)() OVERRIDE { | 39 STDMETHOD_(ULONG, AddRef)() override { |
40 return InterlockedIncrement(&ref_count_); | 40 return InterlockedIncrement(&ref_count_); |
41 } | 41 } |
42 | 42 |
43 STDMETHOD_(ULONG, Release)() OVERRIDE { | 43 STDMETHOD_(ULONG, Release)() override { |
44 const LONG count = InterlockedDecrement(&ref_count_); | 44 const LONG count = InterlockedDecrement(&ref_count_); |
45 if (!count) { | 45 if (!count) { |
46 delete this; | 46 delete this; |
47 return 0; | 47 return 0; |
48 } | 48 } |
49 return static_cast<ULONG>(count); | 49 return static_cast<ULONG>(count); |
50 } | 50 } |
51 | 51 |
52 STDMETHOD(QueryInterface)(REFIID iid, void** result) OVERRIDE { | 52 STDMETHOD(QueryInterface)(REFIID iid, void** result) override { |
53 if (!result) | 53 if (!result) |
54 return E_INVALIDARG; | 54 return E_INVALIDARG; |
55 if (iid == IID_IUnknown || iid == IID_ITfInputScope) { | 55 if (iid == IID_IUnknown || iid == IID_ITfInputScope) { |
56 *result = static_cast<ITfInputScope*>(this); | 56 *result = static_cast<ITfInputScope*>(this); |
57 } else { | 57 } else { |
58 *result = NULL; | 58 *result = NULL; |
59 return E_NOINTERFACE; | 59 return E_NOINTERFACE; |
60 } | 60 } |
61 AddRef(); | 61 AddRef(); |
62 return S_OK; | 62 return S_OK; |
63 } | 63 } |
64 | 64 |
65 STDMETHOD(GetInputScopes)(InputScope** input_scopes, UINT* count) OVERRIDE { | 65 STDMETHOD(GetInputScopes)(InputScope** input_scopes, UINT* count) override { |
66 if (!count || !input_scopes) | 66 if (!count || !input_scopes) |
67 return E_INVALIDARG; | 67 return E_INVALIDARG; |
68 *input_scopes = static_cast<InputScope*>(CoTaskMemAlloc( | 68 *input_scopes = static_cast<InputScope*>(CoTaskMemAlloc( |
69 sizeof(InputScope) * input_scopes_.size())); | 69 sizeof(InputScope) * input_scopes_.size())); |
70 if (!input_scopes) { | 70 if (!input_scopes) { |
71 *count = 0; | 71 *count = 0; |
72 return E_OUTOFMEMORY; | 72 return E_OUTOFMEMORY; |
73 } | 73 } |
74 | 74 |
75 for (size_t i = 0; i < input_scopes_.size(); ++i) | 75 for (size_t i = 0; i < input_scopes_.size(); ++i) |
76 (*input_scopes)[i] = input_scopes_[i]; | 76 (*input_scopes)[i] = input_scopes_[i]; |
77 *count = input_scopes_.size(); | 77 *count = input_scopes_.size(); |
78 return S_OK; | 78 return S_OK; |
79 } | 79 } |
80 | 80 |
81 STDMETHOD(GetPhrase)(BSTR** phrases, UINT* count) OVERRIDE { | 81 STDMETHOD(GetPhrase)(BSTR** phrases, UINT* count) override { |
82 return E_NOTIMPL; | 82 return E_NOTIMPL; |
83 } | 83 } |
84 | 84 |
85 STDMETHOD(GetRegularExpression)(BSTR* regexp) OVERRIDE { | 85 STDMETHOD(GetRegularExpression)(BSTR* regexp) override { |
86 return E_NOTIMPL; | 86 return E_NOTIMPL; |
87 } | 87 } |
88 | 88 |
89 STDMETHOD(GetSRGS)(BSTR* srgs) OVERRIDE { | 89 STDMETHOD(GetSRGS)(BSTR* srgs) override { |
90 return E_NOTIMPL; | 90 return E_NOTIMPL; |
91 } | 91 } |
92 | 92 |
93 STDMETHOD(GetXML)(BSTR* xml) OVERRIDE { | 93 STDMETHOD(GetXML)(BSTR* xml) override { |
94 return E_NOTIMPL; | 94 return E_NOTIMPL; |
95 } | 95 } |
96 | 96 |
97 private: | 97 private: |
98 // The corresponding text input types. | 98 // The corresponding text input types. |
99 std::vector<InputScope> input_scopes_; | 99 std::vector<InputScope> input_scopes_; |
100 | 100 |
101 // The refrence count of this instance. | 101 // The refrence count of this instance. |
102 volatile LONG ref_count_; | 102 volatile LONG ref_count_; |
103 | 103 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 return; | 208 return; |
209 | 209 |
210 std::vector<InputScope> input_scopes = GetInputScopes(text_input_type, | 210 std::vector<InputScope> input_scopes = GetInputScopes(text_input_type, |
211 text_input_mode); | 211 text_input_mode); |
212 set_input_scopes(window_handle, &input_scopes[0], input_scopes.size(), NULL, | 212 set_input_scopes(window_handle, &input_scopes[0], input_scopes.size(), NULL, |
213 0, NULL, NULL); | 213 0, NULL, NULL); |
214 } | 214 } |
215 | 215 |
216 } // namespace tsf_inputscope | 216 } // namespace tsf_inputscope |
217 } // namespace ui | 217 } // namespace ui |
OLD | NEW |