| 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_source.h" | 5 #include "win8/metro_driver/ime/input_source.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlcom.h> | 8 #include <atlcom.h> |
| 9 #include <msctf.h> | 9 #include <msctf.h> |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 cookie_ = cookie; | 46 cookie_ = cookie; |
| 47 source_ = source; | 47 source_ = source; |
| 48 return true; | 48 return true; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void SetCallback(base::Closure on_language_chanaged) { | 51 void SetCallback(base::Closure on_language_chanaged) { |
| 52 on_language_chanaged_ = on_language_chanaged; | 52 on_language_chanaged_ = on_language_chanaged; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void Unadvise() { | 55 void Unadvise() { |
| 56 if (cookie_ == TF_INVALID_COOKIE || !source_) | 56 if (cookie_ == TF_INVALID_COOKIE || !source_.get()) |
| 57 return; | 57 return; |
| 58 if (FAILED(source_->UnadviseSink(cookie_))) | 58 if (FAILED(source_->UnadviseSink(cookie_))) |
| 59 return; | 59 return; |
| 60 cookie_ = TF_INVALID_COOKIE; | 60 cookie_ = TF_INVALID_COOKIE; |
| 61 source_.Release(); | 61 source_.Release(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 // ITfLanguageProfileNotifySink overrides: | 65 // ITfLanguageProfileNotifySink overrides: |
| 66 STDMETHOD(OnLanguageChange)(LANGID langid, BOOL *accept) override { | 66 STDMETHOD(OnLanguageChange)(LANGID langid, BOOL *accept) override { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 ui::win::CreateATLModuleIfNeeded(); | 138 ui::win::CreateATLModuleIfNeeded(); |
| 139 | 139 |
| 140 base::win::ScopedComPtr<ITfInputProcessorProfileMgr> profile_manager; | 140 base::win::ScopedComPtr<ITfInputProcessorProfileMgr> profile_manager; |
| 141 HRESULT hr = profile_manager.CreateInstance(CLSID_TF_InputProcessorProfiles); | 141 HRESULT hr = profile_manager.CreateInstance(CLSID_TF_InputProcessorProfiles); |
| 142 if (FAILED(hr)) { | 142 if (FAILED(hr)) { |
| 143 LOG(ERROR) << "Failed to instantiate CLSID_TF_InputProcessorProfiles." | 143 LOG(ERROR) << "Failed to instantiate CLSID_TF_InputProcessorProfiles." |
| 144 << " hr = " << hr; | 144 << " hr = " << hr; |
| 145 return scoped_ptr<InputSource>(); | 145 return scoped_ptr<InputSource>(); |
| 146 } | 146 } |
| 147 base::win::ScopedComPtr<ITfSource> profiles_source; | 147 base::win::ScopedComPtr<ITfSource> profiles_source; |
| 148 hr = profiles_source.QueryFrom(profile_manager); | 148 hr = profiles_source.QueryFrom(profile_manager.get()); |
| 149 if (FAILED(hr)) { | 149 if (FAILED(hr)) { |
| 150 LOG(ERROR) << "QueryFrom to ITfSource failed. hr = " << hr; | 150 LOG(ERROR) << "QueryFrom to ITfSource failed. hr = " << hr; |
| 151 return scoped_ptr<InputSource>(); | 151 return scoped_ptr<InputSource>(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 CComObject<InputSourceMonitor>* monitor = NULL; | 154 CComObject<InputSourceMonitor>* monitor = NULL; |
| 155 hr = CComObject<InputSourceMonitor>::CreateInstance(&monitor); | 155 hr = CComObject<InputSourceMonitor>::CreateInstance(&monitor); |
| 156 if (FAILED(hr)) { | 156 if (FAILED(hr)) { |
| 157 LOG(ERROR) << "CComObject<InputSourceMonitor>::CreateInstance failed." | 157 LOG(ERROR) << "CComObject<InputSourceMonitor>::CreateInstance failed." |
| 158 << " hr = " << hr; | 158 << " hr = " << hr; |
| 159 return scoped_ptr<InputSource>(); | 159 return scoped_ptr<InputSource>(); |
| 160 } | 160 } |
| 161 if (!monitor->Initialize(profiles_source)) { | 161 if (!monitor->Initialize(profiles_source.get())) { |
| 162 LOG(ERROR) << "Failed to initialize the monitor."; | 162 LOG(ERROR) << "Failed to initialize the monitor."; |
| 163 return scoped_ptr<InputSource>(); | 163 return scoped_ptr<InputSource>(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Transfer the ownership. | 166 // Transfer the ownership. |
| 167 return scoped_ptr<InputSource>(new InputSourceImpl(profile_manager, monitor)); | 167 return scoped_ptr<InputSource>( |
| 168 new InputSourceImpl(profile_manager.get(), monitor)); |
| 168 } | 169 } |
| 169 | 170 |
| 170 } // namespace metro_driver | 171 } // namespace metro_driver |
| OLD | NEW |