| 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 "ui/base/ime/remote_input_method_win.h" | 5 #include "ui/base/ime/remote_input_method_win.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/win/metro.h" | 10 #include "base/win/metro.h" |
| 10 #include "base/win/scoped_handle.h" | 11 #include "base/win/scoped_handle.h" |
| 11 #include "ui/base/ime/input_method.h" | 12 #include "ui/base/ime/input_method.h" |
| 12 #include "ui/base/ime/input_method_delegate.h" | 13 #include "ui/base/ime/input_method_delegate.h" |
| 13 #include "ui/base/ime/input_method_observer.h" | 14 #include "ui/base/ime/input_method_observer.h" |
| 14 #include "ui/base/ime/remote_input_method_delegate_win.h" | 15 #include "ui/base/ime/remote_input_method_delegate_win.h" |
| 15 #include "ui/base/ime/text_input_client.h" | 16 #include "ui/base/ime/text_input_client.h" |
| 16 #include "ui/base/ime/win/tsf_input_scope.h" | 17 #include "ui/base/ime/win/tsf_input_scope.h" |
| 18 #include "ui/base/ui_base_switches.h" |
| 17 #include "ui/events/event.h" | 19 #include "ui/events/event.h" |
| 18 #include "ui/events/event_utils.h" | 20 #include "ui/events/event_utils.h" |
| 19 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
| 20 | 22 |
| 21 namespace ui { | 23 namespace ui { |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 const LANGID kFallbackLangID = | 26 const LANGID kFallbackLangID = |
| 25 MAKELANGID(LANG_NEUTRAL, SUBLANG_UI_CUSTOM_DEFAULT); | 27 MAKELANGID(LANG_NEUTRAL, SUBLANG_UI_CUSTOM_DEFAULT); |
| 26 | 28 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 bool is_candidate_popup_open_; | 359 bool is_candidate_popup_open_; |
| 358 bool is_ime_; | 360 bool is_ime_; |
| 359 LANGID langid_; | 361 LANGID langid_; |
| 360 | 362 |
| 361 DISALLOW_COPY_AND_ASSIGN(RemoteInputMethodWin); | 363 DISALLOW_COPY_AND_ASSIGN(RemoteInputMethodWin); |
| 362 }; | 364 }; |
| 363 | 365 |
| 364 } // namespace | 366 } // namespace |
| 365 | 367 |
| 366 bool IsRemoteInputMethodWinRequired(gfx::AcceleratedWidget widget) { | 368 bool IsRemoteInputMethodWinRequired(gfx::AcceleratedWidget widget) { |
| 369 // If the remote input method is already registered then don't do it again. |
| 370 if (ui::g_public_interface_ && ui::g_private_interface_) |
| 371 return false; |
| 372 |
| 367 DWORD process_id = 0; | 373 DWORD process_id = 0; |
| 368 if (GetWindowThreadProcessId(widget, &process_id) == 0) | 374 if (GetWindowThreadProcessId(widget, &process_id) == 0) |
| 369 return false; | 375 return false; |
| 370 base::win::ScopedHandle process_handle(::OpenProcess( | 376 base::win::ScopedHandle process_handle(::OpenProcess( |
| 371 PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id)); | 377 PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id)); |
| 372 if (!process_handle.IsValid()) | 378 if (!process_handle.IsValid()) |
| 373 return false; | 379 return false; |
| 374 return base::win::IsProcessImmersive(process_handle.Get()); | 380 return base::win::IsProcessImmersive(process_handle.Get()) || |
| 381 CommandLine::ForCurrentProcess()->HasSwitch( |
| 382 switches::kViewerConnect); |
| 375 } | 383 } |
| 376 | 384 |
| 377 RemoteInputMethodPrivateWin::RemoteInputMethodPrivateWin() {} | 385 RemoteInputMethodPrivateWin::RemoteInputMethodPrivateWin() {} |
| 378 | 386 |
| 379 scoped_ptr<InputMethod> CreateRemoteInputMethodWin( | 387 scoped_ptr<InputMethod> CreateRemoteInputMethodWin( |
| 380 internal::InputMethodDelegate* delegate) { | 388 internal::InputMethodDelegate* delegate) { |
| 381 return scoped_ptr<InputMethod>(new RemoteInputMethodWin(delegate)); | 389 return scoped_ptr<InputMethod>(new RemoteInputMethodWin(delegate)); |
| 382 } | 390 } |
| 383 | 391 |
| 384 // static | 392 // static |
| 385 RemoteInputMethodPrivateWin* RemoteInputMethodPrivateWin::Get( | 393 RemoteInputMethodPrivateWin* RemoteInputMethodPrivateWin::Get( |
| 386 InputMethod* input_method) { | 394 InputMethod* input_method) { |
| 387 return GetPrivate(input_method); | 395 return GetPrivate(input_method); |
| 388 } | 396 } |
| 389 | 397 |
| 390 } // namespace ui | 398 } // namespace ui |
| OLD | NEW |