| 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 "base/win/metro.h" | 5 #include "base/win/metro.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/win/scoped_comptr.h" | 9 #include "base/win/scoped_comptr.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 namespace win { | 13 namespace win { |
| 14 | 14 |
| 15 namespace { | |
| 16 bool g_should_tsf_aware_required = false; | |
| 17 } | |
| 18 | |
| 19 HMODULE GetMetroModule() { | 15 HMODULE GetMetroModule() { |
| 20 const HMODULE kUninitialized = reinterpret_cast<HMODULE>(1); | 16 const HMODULE kUninitialized = reinterpret_cast<HMODULE>(1); |
| 21 static HMODULE metro_module = kUninitialized; | 17 static HMODULE metro_module = kUninitialized; |
| 22 | 18 |
| 23 if (metro_module == kUninitialized) { | 19 if (metro_module == kUninitialized) { |
| 24 // Initialize the cache, note that the initialization is idempotent | 20 // Initialize the cache, note that the initialization is idempotent |
| 25 // under the assumption that metro_driver is never unloaded, so the | 21 // under the assumption that metro_driver is never unloaded, so the |
| 26 // race to this assignment is safe. | 22 // race to this assignment is safe. |
| 27 metro_module = GetModuleHandleA("metro_driver.dll"); | 23 metro_module = GetModuleHandleA("metro_driver.dll"); |
| 28 if (metro_module != NULL) { | 24 if (metro_module != NULL) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 ::GetProcAddress(user32, "IsImmersiveProcess")); | 62 ::GetProcAddress(user32, "IsImmersiveProcess")); |
| 67 | 63 |
| 68 if (is_immersive_process) | 64 if (is_immersive_process) |
| 69 return is_immersive_process(process) ? true: false; | 65 return is_immersive_process(process) ? true: false; |
| 70 return false; | 66 return false; |
| 71 } | 67 } |
| 72 | 68 |
| 73 bool IsTSFAwareRequired() { | 69 bool IsTSFAwareRequired() { |
| 74 // Although this function is equal to IsMetroProcess at this moment, | 70 // Although this function is equal to IsMetroProcess at this moment, |
| 75 // Chrome for Win7 and Vista may support TSF in the future. | 71 // Chrome for Win7 and Vista may support TSF in the future. |
| 76 return g_should_tsf_aware_required || IsMetroProcess(); | 72 return IsMetroProcess(); |
| 77 } | |
| 78 | |
| 79 void SetForceToUseTSF() { | |
| 80 g_should_tsf_aware_required = true; | |
| 81 | |
| 82 // Since Windows 8 Metro mode disables CUAS (Cicero Unaware Application | |
| 83 // Support) via ImmDisableLegacyIME API, Chrome must be fully TSF-aware on | |
| 84 // Metro mode. For debugging purposes, explicitly call ImmDisableLegacyIME so | |
| 85 // that one can test TSF functionality even on Windows 8 desktop mode. Note | |
| 86 // that CUAS cannot be disabled on Windows Vista/7 where ImmDisableLegacyIME | |
| 87 // is not available. | |
| 88 typedef BOOL (* ImmDisableLegacyIMEFunc)(); | |
| 89 HMODULE imm32 = ::GetModuleHandleA("imm32.dll"); | |
| 90 if (imm32 == NULL) | |
| 91 return; | |
| 92 | |
| 93 ImmDisableLegacyIMEFunc imm_disable_legacy_ime = | |
| 94 reinterpret_cast<ImmDisableLegacyIMEFunc>( | |
| 95 ::GetProcAddress(imm32, "ImmDisableLegacyIME")); | |
| 96 | |
| 97 if (imm_disable_legacy_ime == NULL) { | |
| 98 // Unsupported API, just do nothing. | |
| 99 return; | |
| 100 } | |
| 101 | |
| 102 if (!imm_disable_legacy_ime()) { | |
| 103 DVLOG(1) << "Failed to disable legacy IME."; | |
| 104 } | |
| 105 } | 73 } |
| 106 | 74 |
| 107 wchar_t* LocalAllocAndCopyString(const string16& src) { | 75 wchar_t* LocalAllocAndCopyString(const string16& src) { |
| 108 size_t dest_size = (src.length() + 1) * sizeof(wchar_t); | 76 size_t dest_size = (src.length() + 1) * sizeof(wchar_t); |
| 109 wchar_t* dest = reinterpret_cast<wchar_t*>(LocalAlloc(LPTR, dest_size)); | 77 wchar_t* dest = reinterpret_cast<wchar_t*>(LocalAlloc(LPTR, dest_size)); |
| 110 base::wcslcpy(dest, src.c_str(), dest_size); | 78 base::wcslcpy(dest, src.c_str(), dest_size); |
| 111 return dest; | 79 return dest; |
| 112 } | 80 } |
| 113 | 81 |
| 114 bool IsParentalControlActivityLoggingOn() { | 82 bool IsParentalControlActivityLoggingOn() { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 reinterpret_cast<GetInitialSearchString>( | 142 reinterpret_cast<GetInitialSearchString>( |
| 175 ::GetProcAddress(metro, "GetInitialSearchString")); | 143 ::GetProcAddress(metro, "GetInitialSearchString")); |
| 176 DCHECK(initial_search_string); | 144 DCHECK(initial_search_string); |
| 177 *params = initial_search_string(); | 145 *params = initial_search_string(); |
| 178 } | 146 } |
| 179 return launch_type; | 147 return launch_type; |
| 180 } | 148 } |
| 181 | 149 |
| 182 } // namespace win | 150 } // namespace win |
| 183 } // namespace base | 151 } // namespace base |
| OLD | NEW |