OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "win8/metro_driver/ime/input_scope.h" | 5 #include "win8/metro_driver/ime/input_scope.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlcom.h> | 8 #include <atlcom.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 BEGIN_COM_MAP(InputScopeImpl) | 29 BEGIN_COM_MAP(InputScopeImpl) |
30 COM_INTERFACE_ENTRY(ITfInputScope) | 30 COM_INTERFACE_ENTRY(ITfInputScope) |
31 END_COM_MAP() | 31 END_COM_MAP() |
32 | 32 |
33 void Initialize(const std::vector<InputScope>& input_scopes) { | 33 void Initialize(const std::vector<InputScope>& input_scopes) { |
34 input_scopes_ = input_scopes; | 34 input_scopes_ = input_scopes; |
35 } | 35 } |
36 | 36 |
37 private: | 37 private: |
38 // ITfInputScope overrides: | 38 // ITfInputScope overrides: |
39 STDMETHOD(GetInputScopes)(InputScope** input_scopes, UINT* count) OVERRIDE { | 39 STDMETHOD(GetInputScopes)(InputScope** input_scopes, UINT* count) override { |
40 if (!count || !input_scopes) | 40 if (!count || !input_scopes) |
41 return E_INVALIDARG; | 41 return E_INVALIDARG; |
42 *input_scopes = static_cast<InputScope*>( | 42 *input_scopes = static_cast<InputScope*>( |
43 CoTaskMemAlloc(sizeof(InputScope) * input_scopes_.size())); | 43 CoTaskMemAlloc(sizeof(InputScope) * input_scopes_.size())); |
44 if (!input_scopes) { | 44 if (!input_scopes) { |
45 *count = 0; | 45 *count = 0; |
46 return E_OUTOFMEMORY; | 46 return E_OUTOFMEMORY; |
47 } | 47 } |
48 std::copy(input_scopes_.begin(), input_scopes_.end(), *input_scopes); | 48 std::copy(input_scopes_.begin(), input_scopes_.end(), *input_scopes); |
49 *count = static_cast<UINT>(input_scopes_.size()); | 49 *count = static_cast<UINT>(input_scopes_.size()); |
50 return S_OK; | 50 return S_OK; |
51 } | 51 } |
52 STDMETHOD(GetPhrase)(BSTR** phrases, UINT* count) OVERRIDE { | 52 STDMETHOD(GetPhrase)(BSTR** phrases, UINT* count) override { |
53 return E_NOTIMPL; | 53 return E_NOTIMPL; |
54 } | 54 } |
55 STDMETHOD(GetRegularExpression)(BSTR* regexp) OVERRIDE { | 55 STDMETHOD(GetRegularExpression)(BSTR* regexp) override { |
56 return E_NOTIMPL; | 56 return E_NOTIMPL; |
57 } | 57 } |
58 STDMETHOD(GetSRGS)(BSTR* srgs) OVERRIDE { | 58 STDMETHOD(GetSRGS)(BSTR* srgs) override { |
59 return E_NOTIMPL; | 59 return E_NOTIMPL; |
60 } | 60 } |
61 STDMETHOD(GetXML)(BSTR* xml) OVERRIDE { | 61 STDMETHOD(GetXML)(BSTR* xml) override { |
62 return E_NOTIMPL; | 62 return E_NOTIMPL; |
63 } | 63 } |
64 | 64 |
65 // Data which ITfInputScope::GetInputScopes should return. | 65 // Data which ITfInputScope::GetInputScopes should return. |
66 std::vector<InputScope> input_scopes_; | 66 std::vector<InputScope> input_scopes_; |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(InputScopeImpl); | 68 DISALLOW_COPY_AND_ASSIGN(InputScopeImpl); |
69 }; | 69 }; |
70 | 70 |
71 } // namespace | 71 } // namespace |
72 | 72 |
73 base::win::ScopedComPtr<ITfInputScope> | 73 base::win::ScopedComPtr<ITfInputScope> |
74 CreteInputScope(const std::vector<InputScope>& input_scopes) { | 74 CreteInputScope(const std::vector<InputScope>& input_scopes) { |
75 ui::win::CreateATLModuleIfNeeded(); | 75 ui::win::CreateATLModuleIfNeeded(); |
76 CComObject<InputScopeImpl>* object = NULL; | 76 CComObject<InputScopeImpl>* object = NULL; |
77 HRESULT hr = CComObject<InputScopeImpl>::CreateInstance(&object); | 77 HRESULT hr = CComObject<InputScopeImpl>::CreateInstance(&object); |
78 if (FAILED(hr)) { | 78 if (FAILED(hr)) { |
79 LOG(ERROR) << "CComObject<InputScopeImpl>::CreateInstance failed. hr = " | 79 LOG(ERROR) << "CComObject<InputScopeImpl>::CreateInstance failed. hr = " |
80 << hr; | 80 << hr; |
81 return base::win::ScopedComPtr<ITfInputScope>(); | 81 return base::win::ScopedComPtr<ITfInputScope>(); |
82 } | 82 } |
83 object->Initialize(input_scopes); | 83 object->Initialize(input_scopes); |
84 return base::win::ScopedComPtr<ITfInputScope>(object); | 84 return base::win::ScopedComPtr<ITfInputScope>(object); |
85 } | 85 } |
86 | 86 |
87 } // namespace metro_driver | 87 } // namespace metro_driver |
OLD | NEW |