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

Unified Diff: win8/metro_driver/ime/input_scope.cc

Issue 53553003: WIP: Ash IME support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « win8/metro_driver/ime/input_scope.h ('k') | win8/metro_driver/ime/keyevent_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: win8/metro_driver/ime/input_scope.cc
diff --git a/win8/metro_driver/ime/input_scope.cc b/win8/metro_driver/ime/input_scope.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bbe9cd3d06035a438f4e9736cccc58f851eae6dc
--- /dev/null
+++ b/win8/metro_driver/ime/input_scope.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "win8/metro_driver/ime/input_scope.h"
+
+namespace metro_driver {
+namespace {
+
+class InputScopeImpl : public ITfInputScope {
+ public:
+ explicit InputScopeImpl(const std::vector<InputScope>& input_scopes)
+ : ref_count_(0),
+ input_scopes_(input_scopes) {}
+
+ // ITfInputScope overrides:
+ STDMETHOD_(ULONG, AddRef)() OVERRIDE {
+ return InterlockedIncrement(&ref_count_);
+ }
+ STDMETHOD_(ULONG, Release)() OVERRIDE {
+ const LONG count = InterlockedDecrement(&ref_count_);
+ if (!count) {
+ delete this;
+ return 0;
+ }
+ return static_cast<ULONG>(count);
+ }
+ STDMETHOD(QueryInterface)(REFIID iid, void** result) OVERRIDE {
+ if (!result)
+ return E_INVALIDARG;
+ if (iid == IID_IUnknown || iid == IID_ITfInputScope) {
+ *result = static_cast<ITfInputScope*>(this);
+ } else {
+ *result = NULL;
+ return E_NOINTERFACE;
+ }
+ AddRef();
+ return S_OK;
+ }
+ STDMETHOD(GetInputScopes)(InputScope** input_scopes, UINT* count) OVERRIDE {
+ if (!count || !input_scopes)
+ return E_INVALIDARG;
+ *input_scopes = static_cast<InputScope*>(
+ CoTaskMemAlloc(sizeof(InputScope) * input_scopes_.size()));
+ if (!input_scopes) {
+ *count = 0;
+ return E_OUTOFMEMORY;
+ }
+ std::copy(input_scopes_.begin(), input_scopes_.end(), *input_scopes);
+ *count = input_scopes_.size();
+ return S_OK;
+ }
+ STDMETHOD(GetPhrase)(BSTR** phrases, UINT* count) OVERRIDE {
+ return E_NOTIMPL;
+ }
+ STDMETHOD(GetRegularExpression)(BSTR* regexp) OVERRIDE {
+ return E_NOTIMPL;
+ }
+ STDMETHOD(GetSRGS)(BSTR* srgs) OVERRIDE {
+ return E_NOTIMPL;
+ }
+ STDMETHOD(GetXML)(BSTR* xml) OVERRIDE {
+ return E_NOTIMPL;
+ }
+
+ private:
+ // The refrence count of this instance.
+ volatile LONG ref_count_;
+ // The corresponding text input types.
+ const std::vector<InputScope> input_scopes_;
+
+ DISALLOW_COPY_AND_ASSIGN(InputScopeImpl);
+};
+
+} // namespace
+
+base::win::ScopedComPtr<IUnknown>
+CreteInputScope(const std::vector<InputScope>& input_scopes) {
+ return base::win::ScopedComPtr<IUnknown>(new InputScopeImpl(input_scopes));
+}
+
+} // namespace metro_driver
« no previous file with comments | « win8/metro_driver/ime/input_scope.h ('k') | win8/metro_driver/ime/keyevent_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698