Demove dead code that is never used in Windows Vista or later
Now that Mozc for Windows does not support Windows XP, we can safely get rid of SystemUtil::IsVistaOrLater() as well as the dead code conditionally used behind that.
This is just dead-code removal. No behavior change is intended.
BUG=none
TEST=unittest
git-svn-id: https://mozc.googlecode.com/svn/trunk@523 a6090854-d499-a067-5803-1114d4e51264
diff --git a/src/base/base.gyp b/src/base/base.gyp
index 96d792a..3ad72bf 100644
--- a/src/base/base.gyp
+++ b/src/base/base.gyp
@@ -144,6 +144,7 @@
'aux_ulib.lib', # used in 'win_util.cc'
'propsys.lib', # used in 'win_util.cc'
'version.lib', # used in 'util.cc'
+ 'KtmW32.lib', # used in 'file_util.cc'
],
},
},
diff --git a/src/base/file_util.cc b/src/base/file_util.cc
index 1ea862b..bc0c6f6 100644
--- a/src/base/file_util.cc
+++ b/src/base/file_util.cc
@@ -31,6 +31,7 @@
#ifdef OS_WIN
#include <Windows.h>
+#include <KtmW32.h>
#else
#include <sys/stat.h>
#include <sys/types.h>
@@ -45,7 +46,6 @@
#include "base/pepper_file_util.h"
#endif // MOZC_USE_PEPPER_FILE_IO
#include "base/scoped_handle.h"
-#include "base/system_util.h"
#include "base/util.h"
#include "base/win_util.h"
@@ -168,97 +168,10 @@
#ifdef OS_WIN
namespace {
-typedef HANDLE (WINAPI *FPCreateTransaction)(LPSECURITY_ATTRIBUTES,
- LPGUID,
- DWORD,
- DWORD,
- DWORD,
- DWORD,
- LPWSTR);
-typedef BOOL (WINAPI *FPMoveFileTransactedW)(LPCTSTR,
- LPCTSTR,
- LPPROGRESS_ROUTINE,
- LPVOID,
- DWORD,
- HANDLE);
-typedef BOOL (WINAPI *FPGetFileAttributesTransactedW)(LPCTSTR,
- GET_FILEEX_INFO_LEVELS,
- LPVOID,
- HANDLE);
-typedef BOOL (WINAPI *FPSetFileAttributesTransactedW)(LPCTSTR,
- DWORD,
- HANDLE);
-typedef BOOL (WINAPI *FPCommitTransaction)(HANDLE);
-
-FPCreateTransaction g_create_transaction = nullptr;
-FPMoveFileTransactedW g_move_file_transactedw = nullptr;
-FPGetFileAttributesTransactedW g_get_file_attributes_transactedw = nullptr;
-FPSetFileAttributesTransactedW g_set_file_attributes_transactedw = nullptr;
-FPCommitTransaction g_commit_transaction = nullptr;
-
-static once_t g_init_tx_move_file_once = MOZC_ONCE_INIT;
-
-void InitTxMoveFile() {
- if (!SystemUtil::IsVistaOrLater()) {
- return;
- }
-
- const HMODULE lib_ktmw = WinUtil::LoadSystemLibrary(L"ktmw32.dll");
- if (lib_ktmw == nullptr) {
- LOG(ERROR) << "LoadSystemLibrary for ktmw32.dll failed.";
- return;
- }
-
- const HMODULE lib_kernel = WinUtil::GetSystemModuleHandle(L"kernel32.dll");
- if (lib_kernel == nullptr) {
- LOG(ERROR) << "LoadSystemLibrary for kernel32.dll failed.";
- return;
- }
-
- g_create_transaction =
- reinterpret_cast<FPCreateTransaction>
- (::GetProcAddress(lib_ktmw, "CreateTransaction"));
-
- g_move_file_transactedw =
- reinterpret_cast<FPMoveFileTransactedW>
- (::GetProcAddress(lib_kernel, "MoveFileTransactedW"));
-
- g_get_file_attributes_transactedw =
- reinterpret_cast<FPGetFileAttributesTransactedW>
- (::GetProcAddress(lib_kernel, "GetFileAttributesTransactedW"));
-
- g_set_file_attributes_transactedw =
- reinterpret_cast<FPSetFileAttributesTransactedW>
- (::GetProcAddress(lib_kernel, "SetFileAttributesTransactedW"));
-
- g_commit_transaction =
- reinterpret_cast<FPCommitTransaction>
- (::GetProcAddress(lib_ktmw, "CommitTransaction"));
-
- LOG_IF(ERROR, g_create_transaction == nullptr)
- << "CreateTransaction init failed";
- LOG_IF(ERROR, g_move_file_transactedw == nullptr)
- << "MoveFileTransactedW init failed";
- LOG_IF(ERROR, g_get_file_attributes_transactedw == nullptr)
- << "GetFileAttributesTransactedW init failed";
- LOG_IF(ERROR, g_set_file_attributes_transactedw == nullptr)
- << "SetFileAttributesTransactedW init failed";
- LOG_IF(ERROR, g_commit_transaction == nullptr)
- << "CommitTransaction init failed";
-}
bool TransactionalMoveFile(const wstring &from, const wstring &to) {
- CallOnce(&g_init_tx_move_file_once, &InitTxMoveFile);
-
- if (g_commit_transaction == nullptr || g_move_file_transactedw == nullptr ||
- g_set_file_attributes_transactedw == nullptr ||
- g_create_transaction == nullptr) {
- // Transactional NTFS is not available.
- return false;
- }
-
const DWORD kTimeout = 5000; // 5 sec.
- ScopedHandle handle((*g_create_transaction)(
+ ScopedHandle handle(::CreateTransaction(
nullptr, 0, 0, 0, 0, kTimeout, nullptr));
const DWORD create_transaction_error = ::GetLastError();
if (handle.get() == 0) {
@@ -267,37 +180,32 @@
}
WIN32_FILE_ATTRIBUTE_DATA file_attribute_data = {};
- if (!(*g_get_file_attributes_transactedw)(from.c_str(), GetFileExInfoStandard,
- &file_attribute_data,
- handle.get())) {
+ if (!::GetFileAttributesTransactedW(from.c_str(), GetFileExInfoStandard,
+ &file_attribute_data, handle.get())) {
const DWORD get_file_attributes_error = ::GetLastError();
LOG(ERROR) << "GetFileAttributesTransactedW failed: "
<< get_file_attributes_error;
return false;
}
- if (!(*g_move_file_transactedw)(from.c_str(), to.c_str(),
- nullptr, nullptr,
- MOVEFILE_COPY_ALLOWED |
- MOVEFILE_REPLACE_EXISTING,
- handle.get())) {
+ if (!::MoveFileTransactedW(from.c_str(), to.c_str(), nullptr, nullptr,
+ MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING,
+ handle.get())) {
const DWORD move_file_transacted_error = ::GetLastError();
LOG(ERROR) << "MoveFileTransactedW failed: "
<< move_file_transacted_error;
return false;
}
- if (!(*g_set_file_attributes_transactedw)(
- to.c_str(),
- file_attribute_data.dwFileAttributes,
- handle.get())) {
+ if (!::SetFileAttributesTransactedW(
+ to.c_str(), file_attribute_data.dwFileAttributes, handle.get())) {
const DWORD set_file_attributes_error = ::GetLastError();
LOG(ERROR) << "SetFileAttributesTransactedW failed: "
<< set_file_attributes_error;
return false;
}
- if (!(*g_commit_transaction)(handle.get())) {
+ if (!::CommitTransaction(handle.get())) {
const DWORD commit_transaction_error = ::GetLastError();
LOG(ERROR) << "CommitTransaction failed: " << commit_transaction_error;
return false;
@@ -307,9 +215,7 @@
}
} // namespace
-#endif // OS_WIN
-#ifdef OS_WIN
bool FileUtil::HideFile(const string &filename) {
return HideFileWithExtraAttributes(filename, 0);
}
diff --git a/src/base/run_level.cc b/src/base/run_level.cc
index 1009bc2..3ec4b31 100644
--- a/src/base/run_level.cc
+++ b/src/base/run_level.cc
@@ -85,12 +85,6 @@
// SourceName is not always null-terminated.
// We're looking for the cases marked '->'.
- // XP SP2 (Normal): "User32 "
- // XP SP2 (Scheduler while logon): "User32 "
- // XP SP2 (Scheduler while logoff): "advapi "
- // -> XP SP2 (RunAs): "seclogon"
- // Server 2003 SP2 (Normal): "User32 "
- // -> Server 2003 SP2 (RunAs): "seclogon"
// Vista SP1 (Normal) "User32 \0"
// -> Vista SP1 (RunAs): "seclogo\0"
// -> Vista SP1 (Over-the-shoulder UAC): "CredPro\0"
@@ -109,11 +103,6 @@
// or if failed to determine.
// This code is written by thatanaka
bool IsElevatedByUAC(const HANDLE hToken) {
- // UAC is supported only on Vista or later.
- if (!SystemUtil::IsVistaOrLater()) {
- return false;
- }
-
// Get TokenElevationType.
DWORD dwSize;
TOKEN_ELEVATION_TYPE ElevationType;
@@ -342,10 +331,6 @@
bool RunLevel::IsElevatedByUAC() {
#ifdef OS_WIN
- if (!SystemUtil::IsVistaOrLater()) {
- return false;
- }
-
// Get process token
HANDLE hProcessToken = NULL;
if (!::OpenProcessToken(::GetCurrentProcess(),
diff --git a/src/base/system_util.cc b/src/base/system_util.cc
index 2654bfb..eefe82f 100644
--- a/src/base/system_util.cc
+++ b/src/base/system_util.cc
@@ -147,29 +147,7 @@
if (in_app_container) {
return TryGetLocalAppDataForAppContainer(dir);
}
- if (SystemUtil::IsVistaOrLater()) {
- return TryGetLocalAppDataLow(dir);
- }
-
- // Windows XP: use "%USERPROFILE%\Local Settings\Application Data"
-
- // Retrieve the directory "%USERPROFILE%\Local Settings\Application Data",
- // which is a user directory which serves a data repository for local
- // applications, to avoid user profiles from being roamed by indexers.
- wchar_t config[MAX_PATH] = {};
- const HRESULT result = ::SHGetFolderPathW(
- nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, &config[0]);
- if (FAILED(result)) {
- return result;
- }
-
- string buffer;
- if (Util::WideToUTF8(&config[0], &buffer) == 0) {
- return E_FAIL;
- }
-
- *dir = buffer;
- return S_OK;
+ return TryGetLocalAppDataLow(dir);
}
static HRESULT TryGetLocalAppDataForAppContainer(string *dir) {
@@ -205,42 +183,17 @@
}
dir->clear();
- if (!SystemUtil::IsVistaOrLater()) {
- return E_NOTIMPL;
- }
-
- // Windows Vista: use LocalLow
- // Call SHGetKnownFolderPath dynamically.
- // http://msdn.microsoft.com/en-us/library/bb762188(VS.85).aspx
- // http://msdn.microsoft.com/en-us/library/bb762584(VS.85).aspx
- // GUID: {A520A1A4-1780-4FF6-BD18-167343C5AF16}
- const HMODULE hLib = WinUtil::LoadSystemLibrary(L"shell32.dll");
- if (hLib == nullptr) {
- return E_NOTIMPL;
- }
-
- typedef HRESULT (WINAPI *FPSHGetKnownFolderPath)(
- const GUID &, DWORD, HANDLE, PWSTR *);
- FPSHGetKnownFolderPath func = reinterpret_cast<FPSHGetKnownFolderPath>
- (::GetProcAddress(hLib, "SHGetKnownFolderPath"));
- if (func == nullptr) {
- ::FreeLibrary(hLib);
- return E_NOTIMPL;
- }
-
wchar_t *task_mem_buffer = nullptr;
- const HRESULT result =
- (*func)(FOLDERID_LocalAppDataLow, 0, nullptr, &task_mem_buffer);
+ const HRESULT result = ::SHGetKnownFolderPath(
+ FOLDERID_LocalAppDataLow, 0, nullptr, &task_mem_buffer);
if (FAILED(result)) {
if (task_mem_buffer != nullptr) {
::CoTaskMemFree(task_mem_buffer);
}
- ::FreeLibrary(hLib);
return result;
}
if (task_mem_buffer == nullptr) {
- ::FreeLibrary(hLib);
return E_UNEXPECTED;
}
@@ -249,13 +202,10 @@
string path;
if (Util::WideToUTF8(wpath, &path) == 0) {
- ::FreeLibrary(hLib);
return E_UNEXPECTED;
}
*dir = path;
-
- ::FreeLibrary(hLib);
return S_OK;
}
@@ -853,15 +803,6 @@
#endif // OS_LINUX, OS_MACOSX, OS_WIN
}
-bool SystemUtil::IsVistaOrLater() {
-#ifdef OS_WIN
- static const bool result = ::IsWindowsVistaOrGreater();
- return result;
-#else
- return false;
-#endif // OS_WIN
-}
-
bool SystemUtil::IsWindows7OrLater() {
#ifdef OS_WIN
static const bool result = ::IsWindows7OrGreater();
diff --git a/src/base/system_util.h b/src/base/system_util.h
index 2460981..25c54d5 100644
--- a/src/base/system_util.h
+++ b/src/base/system_util.h
@@ -46,8 +46,6 @@
class SystemUtil {
public:
// return "~/.mozc" for Unix/Mac
- // return "%USERPROFILE%\\Local Settings\\Application\\"
- // "Google\\Google Japanese Input" for Windows XP.
// return "%USERPROFILE%\\AppData\\LocalLow\\"
// "Google\\Google Japanese Input" for Windows Vista and later.
static string GetUserProfileDirectory();
@@ -114,7 +112,6 @@
// EnsureVitalImmutableDataIsAvailable is a simple fail-fast mechanism to
// this situation. This function simply returns false instead of making
// the process crash if any of following functions cannot work as expected.
- // - IsVistaOrLaterCache
// - SystemDirectoryCache
// - ProgramFilesX86Cache
// - LocalAppDataDirectoryCache
@@ -146,9 +143,6 @@
// TODO(yukawa): support Mac and Linux.
static bool IsPlatformSupported();
- // returns true if the version of Windows is Vista or later.
- static bool IsVistaOrLater();
-
// returns true if the version of Windows is 6.1 or later.
static bool IsWindows7OrLater();
diff --git a/src/base/win_sandbox.cc b/src/base/win_sandbox.cc
index bdabe28..b1a6b9a 100644
--- a/src/base/win_sandbox.cc
+++ b/src/base/win_sandbox.cc
@@ -259,7 +259,6 @@
wstring WinSandbox::GetSDDL(ObjectSecurityType shareble_object_type,
const wstring &token_user_sid,
const wstring &token_primary_group_sid,
- bool is_windows_vista_or_later,
bool is_windows_8_or_later) {
// See http://social.msdn.microsoft.com/Forums/en-US/windowssecurity/thread/e92502b1-0b9f-4e02-9d72-e4e47e924a8f/
// for how to acess named objects from an AppContainer.
@@ -270,9 +269,7 @@
case WinSandbox::kSharablePipe:
// Strip implicit owner rights
// http://technet.microsoft.com/en-us/library/dd125370.aspx
- if (is_windows_vista_or_later) {
- dacl += Allow(L"", SDDL_OWNER_RIGHTS);
- }
+ dacl += Allow(L"", SDDL_OWNER_RIGHTS);
// Deny remote acccess
dacl += Deny(SDDL_GENERIC_ALL, SDDL_NETWORK);
// Allow general access to LocalSystem
@@ -285,17 +282,13 @@
}
// Allow general access to the current user
dacl += Allow(SDDL_GENERIC_ALL, token_user_sid);
- if (is_windows_vista_or_later) {
- // Allow read/write access to low integrity
- sacl += MandatoryLevel(SDDL_NO_EXECUTE_UP, SDDL_ML_LOW);
- }
+ // Allow read/write access to low integrity
+ sacl += MandatoryLevel(SDDL_NO_EXECUTE_UP, SDDL_ML_LOW);
break;
case WinSandbox::kLooseSharablePipe:
// Strip implicit owner rights
// http://technet.microsoft.com/en-us/library/dd125370.aspx
- if (is_windows_vista_or_later) {
- dacl += Allow(L"", SDDL_OWNER_RIGHTS);
- }
+ dacl += Allow(L"", SDDL_OWNER_RIGHTS);
// Deny remote acccess
dacl += Deny(SDDL_GENERIC_ALL, SDDL_NETWORK);
// Allow general access to LocalSystem
@@ -310,17 +303,13 @@
dacl += Allow(SDDL_GENERIC_ALL, token_user_sid);
// Skip 2nd-phase ACL validation against restricted tokens.
dacl += Allow(SDDL_GENERIC_ALL, SDDL_RESTRICTED_CODE);
- if (is_windows_vista_or_later) {
- // Allow read/write access to low integrity
- sacl += MandatoryLevel(SDDL_NO_EXECUTE_UP, SDDL_ML_LOW);
- }
+ // Allow read/write access to low integrity
+ sacl += MandatoryLevel(SDDL_NO_EXECUTE_UP, SDDL_ML_LOW);
break;
case WinSandbox::kSharableEvent:
// Strip implicit owner rights
// http://technet.microsoft.com/en-us/library/dd125370.aspx
- if (is_windows_vista_or_later) {
- dacl += Allow(L"", SDDL_OWNER_RIGHTS);
- }
+ dacl += Allow(L"", SDDL_OWNER_RIGHTS);
// Allow general access to LocalSystem
dacl += Allow(SDDL_GENERIC_ALL, SDDL_LOCAL_SYSTEM);
// Allow general access to Built-in Administorators
@@ -334,17 +323,13 @@
// Skip 2nd-phase ACL validation against restricted tokens regarding
// change/synchronize.
dacl += Allow(SDDL_GENERIC_EXECUTE, SDDL_RESTRICTED_CODE);
- if (is_windows_vista_or_later) {
- // Allow read/write access to low integrity
- sacl += MandatoryLevel(SDDL_NO_EXECUTE_UP, SDDL_ML_LOW);
- }
+ // Allow read/write access to low integrity
+ sacl += MandatoryLevel(SDDL_NO_EXECUTE_UP, SDDL_ML_LOW);
break;
case WinSandbox::kSharableMutex:
// Strip implicit owner rights
// http://technet.microsoft.com/en-us/library/dd125370.aspx
- if (is_windows_vista_or_later) {
- dacl += Allow(L"", SDDL_OWNER_RIGHTS);
- }
+ dacl += Allow(L"", SDDL_OWNER_RIGHTS);
// Allow general access to LocalSystem
dacl += Allow(SDDL_GENERIC_ALL, SDDL_LOCAL_SYSTEM);
// Allow general access to Built-in Administorators
@@ -358,17 +343,13 @@
// Skip 2nd-phase ACL validation against restricted tokens regarding
// change/synchronize.
dacl += Allow(SDDL_GENERIC_EXECUTE, SDDL_RESTRICTED_CODE);
- if (is_windows_vista_or_later) {
- // Allow read/write access to low integrity
- sacl += MandatoryLevel(SDDL_NO_EXECUTE_UP, SDDL_ML_LOW);
- }
+ // Allow read/write access to low integrity
+ sacl += MandatoryLevel(SDDL_NO_EXECUTE_UP, SDDL_ML_LOW);
break;
case WinSandbox::kSharableFileForRead:
// Strip implicit owner rights
// http://technet.microsoft.com/en-us/library/dd125370.aspx
- if (is_windows_vista_or_later) {
- dacl += Allow(L"", SDDL_OWNER_RIGHTS);
- }
+ dacl += Allow(L"", SDDL_OWNER_RIGHTS);
// Allow general access to LocalSystem
dacl += Allow(SDDL_GENERIC_ALL, SDDL_LOCAL_SYSTEM);
// Allow general access to Built-in Administorators
@@ -383,18 +364,14 @@
// Skip 2nd-phase ACL validation against restricted tokens regarding
// general read access.
dacl += Allow(SDDL_GENERIC_READ, SDDL_RESTRICTED_CODE);
- if (is_windows_vista_or_later) {
- // Allow read access to low integrity
- sacl += MandatoryLevel(
- SDDL_NO_WRITE_UP SDDL_NO_EXECUTE_UP, SDDL_ML_LOW);
- }
+ // Allow read access to low integrity
+ sacl += MandatoryLevel(
+ SDDL_NO_WRITE_UP SDDL_NO_EXECUTE_UP, SDDL_ML_LOW);
break;
case WinSandbox::kIPCServerProcess:
// Strip implicit owner rights
// http://technet.microsoft.com/en-us/library/dd125370.aspx
- if (is_windows_vista_or_later) {
- dacl += Allow(L"", SDDL_OWNER_RIGHTS);
- }
+ dacl += Allow(L"", SDDL_OWNER_RIGHTS);
// Allow general access to LocalSystem
dacl += Allow(SDDL_GENERIC_ALL, SDDL_LOCAL_SYSTEM);
// Allow general access to Built-in Administorators
@@ -406,22 +383,15 @@
}
// Allow general access to the current user
dacl += Allow(SDDL_GENERIC_ALL, token_user_sid);
- if (is_windows_vista_or_later) {
- // Allow PROCESS_QUERY_LIMITED_INFORMATION to restricted tokens
- dacl += Allow(SDDL_PROCESS_QUERY_LIMITED_INFORMATION,
- SDDL_RESTRICTED_CODE);
- } else {
- // Allow PROCESS_QUERY_INFORMATION to restricted tokens
- dacl += Allow(SDDL_PROCESS_QUERY_INFORMATION, SDDL_RESTRICTED_CODE);
- }
+ // Allow PROCESS_QUERY_LIMITED_INFORMATION to restricted tokens
+ dacl += Allow(SDDL_PROCESS_QUERY_LIMITED_INFORMATION,
+ SDDL_RESTRICTED_CODE);
break;
case WinSandbox::kPrivateObject:
default:
// Strip implicit owner rights
// http://technet.microsoft.com/en-us/library/dd125370.aspx
- if (is_windows_vista_or_later) {
- dacl += Allow(L"", SDDL_OWNER_RIGHTS);
- }
+ dacl += Allow(L"", SDDL_OWNER_RIGHTS);
// Allow general access to LocalSystem
dacl += Allow(SDDL_GENERIC_ALL, SDDL_LOCAL_SYSTEM);
// Allow general access to Built-in Administorators
@@ -513,7 +483,7 @@
const wstring &sddl = GetSDDL(
shareble_object_type, token_user_sid, token_primary_group_sid,
- SystemUtil::IsVistaOrLater(), SystemUtil::IsWindows8OrLater());
+ SystemUtil::IsWindows8OrLater());
// Create self-relative SD
PSECURITY_DESCRIPTOR self_relative_desc = nullptr;
@@ -1209,10 +1179,6 @@
bool SetTokenIntegrityLevel(HANDLE token,
WinSandbox::IntegrityLevel integrity_level) {
- if (!SystemUtil::IsVistaOrLater()) {
- return true;
- }
-
const wchar_t* sid_string = GetPredefinedSidString(integrity_level);
if (sid_string == nullptr) {
// do not change the integrity level.
@@ -1368,10 +1334,8 @@
// On Windows Vista, the following token (current logon sid) is required
// to create objects in BNO. Consider to use low integrity level
// so that it cannot access object created by other processes.
- if (SystemUtil::IsVistaOrLater()) {
- for (size_t i = 0; i < token_logon_session.size(); ++i) {
- sids_to_restrict.push_back(token_logon_session[i].sid());
- }
+ for (size_t i = 0; i < token_logon_session.size(); ++i) {
+ sids_to_restrict.push_back(token_logon_session[i].sid());
}
break;
case USER_RESTRICTED:
diff --git a/src/base/win_sandbox.h b/src/base/win_sandbox.h
index 57e5ead..a4875de 100644
--- a/src/base/win_sandbox.h
+++ b/src/base/win_sandbox.h
@@ -190,7 +190,6 @@
static wstring GetSDDL(ObjectSecurityType shareble_object_type,
const wstring &token_user_sid,
const wstring &token_primary_group_sid,
- bool is_windows_vista_or_later,
bool is_windows_8_or_later);
private:
diff --git a/src/base/win_sandbox_test.cc b/src/base/win_sandbox_test.cc
index 8bbaab0..2bfa9f7 100644
--- a/src/base/win_sandbox_test.cc
+++ b/src/base/win_sandbox_test.cc
@@ -149,30 +149,20 @@
const wchar_t kDummyUserSID[] = L"S-8";
const wchar_t kDummyGroupSID[] = L"S-9";
-wstring GetSDDLForXP(WinSandbox::ObjectSecurityType type) {
- return TestableWinSandbox::GetSDDL(
- type, kDummyUserSID, kDummyGroupSID, false, false);
-}
-
wstring GetSDDLForVista(WinSandbox::ObjectSecurityType type) {
return TestableWinSandbox::GetSDDL(
- type, kDummyUserSID, kDummyGroupSID, true, false);
+ type, kDummyUserSID, kDummyGroupSID, false);
}
wstring GetSDDLForWin8(WinSandbox::ObjectSecurityType type) {
return TestableWinSandbox::GetSDDL(
- type, kDummyUserSID, kDummyGroupSID, true, true);
+ type, kDummyUserSID, kDummyGroupSID, true);
}
TEST(WinSandboxTest, GetSDDLForSharablePipe) {
EXPECT_EQ(
L"O:S-8"
L"G:S-9"
- L"D:(D;;GA;;;NU)(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)",
- GetSDDLForXP(WinSandbox::kSharablePipe));
- EXPECT_EQ(
- L"O:S-8"
- L"G:S-9"
L"D:(A;;;;;OW)(D;;GA;;;NU)(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)"
L"S:(ML;;NX;;;LW)",
GetSDDLForVista(WinSandbox::kSharablePipe));
@@ -189,11 +179,6 @@
EXPECT_EQ(
L"O:S-8"
L"G:S-9"
- L"D:(D;;GA;;;NU)(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)(A;;GA;;;RC)",
- GetSDDLForXP(WinSandbox::kLooseSharablePipe));
- EXPECT_EQ(
- L"O:S-8"
- L"G:S-9"
L"D:(A;;;;;OW)(D;;GA;;;NU)(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)"
L"(A;;GA;;;RC)"
L"S:(ML;;NX;;;LW)",
@@ -211,11 +196,6 @@
EXPECT_EQ(
L"O:S-8"
L"G:S-9"
- L"D:(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)(A;;GX;;;RC)",
- GetSDDLForXP(WinSandbox::kSharableEvent));
- EXPECT_EQ(
- L"O:S-8"
- L"G:S-9"
L"D:(A;;;;;OW)(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)(A;;GX;;;RC)"
L"S:(ML;;NX;;;LW)",
GetSDDLForVista(WinSandbox::kSharableEvent));
@@ -232,11 +212,6 @@
EXPECT_EQ(
L"O:S-8"
L"G:S-9"
- L"D:(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)(A;;GX;;;RC)",
- GetSDDLForXP(WinSandbox::kSharableMutex));
- EXPECT_EQ(
- L"O:S-8"
- L"G:S-9"
L"D:(A;;;;;OW)(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)(A;;GX;;;RC)"
L"S:(ML;;NX;;;LW)",
GetSDDLForVista(WinSandbox::kSharableMutex));
@@ -253,11 +228,6 @@
EXPECT_EQ(
L"O:S-8"
L"G:S-9"
- L"D:(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)(A;;GR;;;RC)",
- GetSDDLForXP(WinSandbox::kSharableFileForRead));
- EXPECT_EQ(
- L"O:S-8"
- L"G:S-9"
L"D:(A;;;;;OW)(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)(A;;GR;;;RC)"
L"S:(ML;;NWNX;;;LW)",
GetSDDLForVista(WinSandbox::kSharableFileForRead));
@@ -274,11 +244,6 @@
EXPECT_EQ(
L"O:S-8"
L"G:S-9"
- L"D:(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)(A;;0x0400;;;RC)",
- GetSDDLForXP(WinSandbox::kIPCServerProcess));
- EXPECT_EQ(
- L"O:S-8"
- L"G:S-9"
L"D:(A;;;;;OW)(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)(A;;0x1000;;;RC)",
GetSDDLForVista(WinSandbox::kIPCServerProcess));
EXPECT_EQ(
@@ -293,11 +258,6 @@
EXPECT_EQ(
L"O:S-8"
L"G:S-9"
- L"D:(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)",
- GetSDDLForXP(WinSandbox::kPrivateObject));
- EXPECT_EQ(
- L"O:S-8"
- L"G:S-9"
L"D:(A;;;;;OW)(A;;GA;;;SY)(A;;GA;;;BA)(A;;GA;;;S-8)",
GetSDDLForVista(WinSandbox::kPrivateObject));
EXPECT_EQ(
diff --git a/src/base/win_util.cc b/src/base/win_util.cc
index 40f1228..bfe243e 100644
--- a/src/base/win_util.cc
+++ b/src/base/win_util.cc
@@ -34,6 +34,7 @@
#include <Aux_ulib.h>
#include <Psapi.h>
+#include <Stringapiset.h>
#include <Winternl.h>
#define _ATL_NO_AUTOMATIC_NAMESPACE
@@ -98,36 +99,6 @@
return (L1.LowPart == L2.LowPart && L1.HighPart == L2.HighPart);
}
-
-// The registry key for the CUAS setting.
-// Note: We have the same values in win32/base/imm_util.cc
-// TODO(yukawa): Define these constants at the same place.
-const wchar_t kCUASKey[] = L"Software\\Microsoft\\CTF\\SystemShared";
-const wchar_t kCUASValueName[] = L"CUAS";
-
-// Reads CUAS value in the registry keys and returns true if the value is set
-// to 1.
-// The CUAS value is read from 64 bit registry keys if KEY_WOW64_64KEY is
-// specified as |additional_regsam| and read from 32 bit registry keys if
-// KEY_WOW64_32KEY is specified.
-bool IsCuasEnabledInternal(REGSAM additional_regsam) {
- const REGSAM sam_desired = KEY_QUERY_VALUE | additional_regsam;
- ATL::CRegKey key;
- LONG result = key.Open(HKEY_LOCAL_MACHINE, kCUASKey, sam_desired);
- if (ERROR_SUCCESS != result) {
- LOG(ERROR) << "Cannot open HKEY_LOCAL_MACHINE\\Software\\Microsoft\\CTF\\"
- "SystemShared: "
- << result;
- return false;
- }
- DWORD cuas;
- result = key.QueryDWORDValue(kCUASValueName, cuas);
- if (ERROR_SUCCESS != result) {
- LOG(ERROR) << "Failed to query CUAS value:" << result;
- }
- return (cuas == 1);
-}
-
} // namespace
HMODULE WinUtil::LoadSystemLibrary(const wstring &base_filename) {
@@ -226,27 +197,7 @@
bool WinUtil::Win32EqualString(const wstring &lhs, const wstring &rhs,
bool ignore_case, bool *are_equal) {
- // http://msdn.microsoft.com/en-us/library/dd317762.aspx
- typedef int (WINAPI *FPCompareStringOrdinal)(
- __in LPCWSTR lpString1,
- __in int cchCount1,
- __in LPCWSTR lpString2,
- __in int cchCount2,
- __in BOOL bIgnoreCase);
-
- const HMODULE kernel = WinUtil::GetSystemModuleHandle(L"kernel32.dll");
- if (kernel == nullptr) {
- LOG(ERROR) << "GetSystemModuleHandle failed";
- return false;
- }
-
- const FPCompareStringOrdinal compare_string_ordinal =
- reinterpret_cast<FPCompareStringOrdinal>(
- ::GetProcAddress(kernel, "CompareStringOrdinal"));
- if (compare_string_ordinal == nullptr) {
- return false;
- }
- const int compare_result = compare_string_ordinal(
+ const int compare_result = ::CompareStringOrdinal(
lhs.c_str(), lhs.size(), rhs.c_str(), rhs.size(),
(ignore_case ? TRUE : FALSE));
@@ -384,14 +335,12 @@
return false;
}
- if (SystemUtil::IsVistaOrLater()) {
- // Session 0 is dedicated to services
- DWORD dwSessionId = 0;
- if (!::ProcessIdToSessionId(::GetCurrentProcessId(), &dwSessionId) ||
- (dwSessionId == 0)) {
- *is_service = true;
- return true;
- }
+ // Session 0 is dedicated to services
+ DWORD dwSessionId = 0;
+ if (!::ProcessIdToSessionId(::GetCurrentProcessId(), &dwSessionId) ||
+ (dwSessionId == 0)) {
+ *is_service = true;
+ return true;
}
// Get process token
@@ -566,18 +515,8 @@
}
bool WinUtil::IsCuasEnabled() {
- if (SystemUtil::IsVistaOrLater()) {
- // CUAS is always enabled on Vista or later.
- return true;
- }
-
- if (SystemUtil::IsWindowsX64()) {
- // see both 64 bit and 32 bit registry keys
- return IsCuasEnabledInternal(KEY_WOW64_64KEY) &&
- IsCuasEnabledInternal(KEY_WOW64_32KEY);
- } else {
- return IsCuasEnabledInternal(0);
- }
+ // CUAS is always enabled on Vista or later.
+ return true;
}
bool WinUtil::GetFileSystemInfoFromPath(
@@ -666,10 +605,8 @@
}
nt_path->clear();
- const DWORD required_access =
- SystemUtil::IsVistaOrLater() ? PROCESS_QUERY_LIMITED_INFORMATION
- : PROCESS_QUERY_INFORMATION;
- ScopedHandle process_handle(::OpenProcess(required_access, FALSE, pid));
+ ScopedHandle process_handle(::OpenProcess(
+ PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid));
if (process_handle.get() == nullptr) {
VLOG(1) << "OpenProcess() failed: " << ::GetLastError();
diff --git a/src/base/win_util_test.cc b/src/base/win_util_test.cc
index fe10f87..9a0054c 100644
--- a/src/base/win_util_test.cc
+++ b/src/base/win_util_test.cc
@@ -97,68 +97,66 @@
}
TEST(WinUtilTest, Win32EqualStringTest) {
- if (SystemUtil::IsVistaOrLater()) {
- bool result = false;
+ bool result = false;
- result = false;
- EXPECT_TRUE(WinUtil::Win32EqualString(
- L"abc",
- L"AbC",
- true,
- &result));
- EXPECT_TRUE(result);
+ result = false;
+ EXPECT_TRUE(WinUtil::Win32EqualString(
+ L"abc",
+ L"AbC",
+ true,
+ &result));
+ EXPECT_TRUE(result);
- // case-sensitive
- EXPECT_TRUE(WinUtil::Win32EqualString(
- L"abc",
- L"AbC",
- false,
- &result));
+ // case-sensitive
+ EXPECT_TRUE(WinUtil::Win32EqualString(
+ L"abc",
+ L"AbC",
+ false,
+ &result));
+ EXPECT_FALSE(result);
+
+ // Test case in http://b/2977223
+ result = false;
+ EXPECT_TRUE(WinUtil::Win32EqualString(
+ L"abc",
+ L"a" L"\x202c" L"bc", // U+202C: POP DIRECTIONAL FORMATTING
+ true,
+ &result));
+ EXPECT_FALSE(result);
+
+ // Test case in http://b/2977235
+ result = false;
+ EXPECT_TRUE(WinUtil::Win32EqualString(
+ L"\x01bf", // U+01BF: LATIN LETTER WYNN
+ L"\x01f7", // U+01F7: LATIN CAPITAL LETTER WYNN
+ true,
+ &result));
+ EXPECT_TRUE(result);
+
+ // http://blogs.msdn.com/b/michkap/archive/2005/05/26/421987.aspx
+ result = false;
+ EXPECT_TRUE(WinUtil::Win32EqualString(
+ L"\x03c2", // U+03C2: GREEK SMALL LETTER FINAL SIGMA
+ L"\x03a3", // U+03A3: GREEK CAPITAL LETTER SIGMA
+ true,
+ &result));
+ // Windows XP En/Ja: U+03C2 and U+03A3 are the same caracter.
+ // Windows Vista En/Ja: U+03C2 and U+03A3 are the same caracter.
+ // Windows 7 En/Ja: U+03C2 and U+03A3 are different from each other.
+ if (SystemUtil::IsWindows7OrLater()) {
EXPECT_FALSE(result);
-
- // Test case in http://b/2977223
- result = false;
- EXPECT_TRUE(WinUtil::Win32EqualString(
- L"abc",
- L"a" L"\x202c" L"bc", // U+202C: POP DIRECTIONAL FORMATTING
- true,
- &result));
- EXPECT_FALSE(result);
-
- // Test case in http://b/2977235
- result = false;
- EXPECT_TRUE(WinUtil::Win32EqualString(
- L"\x01bf", // U+01BF: LATIN LETTER WYNN
- L"\x01f7", // U+01F7: LATIN CAPITAL LETTER WYNN
- true,
- &result));
- EXPECT_TRUE(result);
-
- // http://blogs.msdn.com/b/michkap/archive/2005/05/26/421987.aspx
- result = false;
- EXPECT_TRUE(WinUtil::Win32EqualString(
- L"\x03c2", // U+03C2: GREEK SMALL LETTER FINAL SIGMA
- L"\x03a3", // U+03A3: GREEK CAPITAL LETTER SIGMA
- true,
- &result));
- // Windows XP En/Ja: U+03C2 and U+03A3 are the same caracter.
- // Windows Vista En/Ja: U+03C2 and U+03A3 are the same caracter.
- // Windows 7 En/Ja: U+03C2 and U+03A3 are different from each other.
- if (SystemUtil::IsWindows7OrLater()) {
- EXPECT_FALSE(result);
- } else {
- EXPECT_TRUE(result);
- }
-
- // http://blogs.msdn.com/b/michkap/archive/2005/05/26/421987.aspx
- result = false;
- EXPECT_TRUE(WinUtil::Win32EqualString(
- L"\x03c3", // U+03C3: GREEK SMALL LETTER SIGMA
- L"\x03a3", // U+03A3: GREEK CAPITAL LETTER SIGMA
- true,
- &result));
+ } else {
EXPECT_TRUE(result);
}
+
+ // http://blogs.msdn.com/b/michkap/archive/2005/05/26/421987.aspx
+ result = false;
+ EXPECT_TRUE(WinUtil::Win32EqualString(
+ L"\x03c3", // U+03C3: GREEK SMALL LETTER SIGMA
+ L"\x03a3", // U+03A3: GREEK CAPITAL LETTER SIGMA
+ true,
+ &result));
+ EXPECT_TRUE(result);
}
TEST(WinUtilTest, NativeEqualStringTest) {
@@ -257,13 +255,7 @@
L"\x01f7", // U+01F7: LATIN CAPITAL LETTER WYNN
true,
&result);
- if (SystemUtil::IsVistaOrLater()) {
- EXPECT_TRUE(result);
- } else {
- // Unfortunately, this result seems not to be compatible with
- // Win32EqualString/NativeEqualString on Windows XP.
- EXPECT_FALSE(result);
- }
+ EXPECT_TRUE(result);
// http://blogs.msdn.com/b/michkap/archive/2005/05/26/421987.aspx
result = false;
@@ -339,10 +331,6 @@
}
TEST(WinUtilTest, GetNtPath) {
- if (!SystemUtil::IsVistaOrLater()) {
- return;
- }
-
const wstring system_dir = SystemUtil::GetSystemDir();
const wstring notepad = system_dir + L"\\notepad.exe";
const wchar_t kThisFileNeverExists[] = L"/this/file/never/exists";
diff --git a/src/client/client.cc b/src/client/client.cc
index 8753619..c4ae4e4 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -873,8 +873,7 @@
// http://b/2415191
const int result =
reinterpret_cast<int>(::ShellExecute(0,
- SystemUtil::IsVistaOrLater() ?
- L"runas" : L"open",
+ L"runas",
wpath.c_str(),
L"--mode=administration_dialog",
SystemUtil::GetSystemDir(),
diff --git a/src/gui/about_dialog/about_dialog.cc b/src/gui/about_dialog/about_dialog.cc
index b86357f..32681dd 100644
--- a/src/gui/about_dialog/about_dialog.cc
+++ b/src/gui/about_dialog/about_dialog.cc
@@ -161,12 +161,10 @@
switch (message->wParam) {
case UpdateChecker::UPGRADE_IS_AVAILABLE:
version_info += tr("New version is available");
- if (SystemUtil::IsVistaOrLater()) {
- if (!RunLevel::IsElevatedByUAC()) {
- QWindowsStyle style;
- QIcon vista_icon(style.standardIcon(QStyle::SP_VistaShield));
- updateButton->setIcon(vista_icon);
- }
+ if (!RunLevel::IsElevatedByUAC()) {
+ QWindowsStyle style;
+ QIcon vista_icon(style.standardIcon(QStyle::SP_VistaShield));
+ updateButton->setIcon(vista_icon);
}
updateButton->show();
break;
diff --git a/src/gui/administration_dialog/administration_dialog.cc b/src/gui/administration_dialog/administration_dialog.cc
index 8666fd5..2bcc510 100644
--- a/src/gui/administration_dialog/administration_dialog.cc
+++ b/src/gui/administration_dialog/administration_dialog.cc
@@ -31,7 +31,6 @@
#include <QtGui/QMessageBox>
#include "base/run_level.h"
-#include "base/system_util.h"
#include "config/stats_config_util.h"
#include "server/cache_service_manager.h"
@@ -67,12 +66,8 @@
usageStatsCheckBox->setChecked(StatsConfigUtil::IsEnabled());
- if (SystemUtil::IsVistaOrLater()) {
- ElevatedProcessDisabledcheckBox->setChecked
- (RunLevel::GetElevatedProcessDisabled());
- } else {
- ElevatedProcessDisabledcheckBox->setVisible(false);
- }
+ ElevatedProcessDisabledcheckBox->setChecked(
+ RunLevel::GetElevatedProcessDisabled());
CacheServiceEnabledcheckBox->setChecked(
CacheServiceManager::IsEnabled() || CacheServiceManager::IsRunning());
diff --git a/src/gui/character_pad/character_pad_libmain.cc b/src/gui/character_pad/character_pad_libmain.cc
index eba51cb..cf27dcd 100644
--- a/src/gui/character_pad/character_pad_libmain.cc
+++ b/src/gui/character_pad/character_pad_libmain.cc
@@ -98,17 +98,15 @@
::SetWindowLong(window->winId(), GWL_EXSTYLE, style);
// Aero
- if (mozc::SystemUtil::IsVistaOrLater()) {
- window->setContentsMargins(0, 0, 0, 0);
- mozc::gui::WinUtil::InstallStyleSheetsFiles(
- ":character_pad_win_aero_style.qss",
- ":character_pad_win_style.qss");
- if (mozc::gui::WinUtil::IsCompositionEnabled()) {
- mozc::gui::WinUtil::ExtendFrameIntoClientArea(window.get());
- InstallStyleSheet(":character_pad_win_aero_style.qss");
- } else {
- InstallStyleSheet(":character_pad_win_style.qss");
- }
+ window->setContentsMargins(0, 0, 0, 0);
+ mozc::gui::WinUtil::InstallStyleSheetsFiles(
+ ":character_pad_win_aero_style.qss",
+ ":character_pad_win_style.qss");
+ if (mozc::gui::WinUtil::IsCompositionEnabled()) {
+ mozc::gui::WinUtil::ExtendFrameIntoClientArea(window.get());
+ InstallStyleSheet(":character_pad_win_aero_style.qss");
+ } else {
+ InstallStyleSheet(":character_pad_win_style.qss");
}
#endif
diff --git a/src/gui/config_dialog/config_dialog.cc b/src/gui/config_dialog/config_dialog.cc
index 788b074..6738b31 100644
--- a/src/gui/config_dialog/config_dialog.cc
+++ b/src/gui/config_dialog/config_dialog.cc
@@ -44,7 +44,6 @@
#include "base/logging.h"
#include "base/mac_util.h"
#include "base/run_level.h"
-#include "base/system_util.h"
#include "base/util.h"
#include "client/client.h"
#include "config/config.pb.h"
@@ -297,16 +296,11 @@
launchAdministrationDialogButton->setEnabled(true);
// if the current application is not elevated by UAC,
// add a shield icon
- if (mozc::SystemUtil::IsVistaOrLater()) {
- if (!mozc::RunLevel::IsElevatedByUAC()) {
- QWindowsStyle style;
- QIcon vista_icon(style.standardIcon(QStyle::SP_VistaShield));
- launchAdministrationDialogButton->setIcon(vista_icon);
- launchAdministrationDialogButtonForUsageStats->setIcon(vista_icon);
- }
- } else {
- dictionaryPreloadingAndUACLabel->setText(
- tr("Dictionary preloading"));
+ if (!mozc::RunLevel::IsElevatedByUAC()) {
+ QWindowsStyle style;
+ QIcon vista_icon(style.standardIcon(QStyle::SP_VistaShield));
+ launchAdministrationDialogButton->setIcon(vista_icon);
+ launchAdministrationDialogButtonForUsageStats->setIcon(vista_icon);
}
usageStatsCheckBox->setDisabled(true);
diff --git a/src/gui/dictionary_tool/dictionary_tool.cc b/src/gui/dictionary_tool/dictionary_tool.cc
index 7049f60..1fc5975 100644
--- a/src/gui/dictionary_tool/dictionary_tool.cc
+++ b/src/gui/dictionary_tool/dictionary_tool.cc
@@ -45,7 +45,6 @@
#include "base/file_stream.h"
#include "base/logging.h"
#include "base/run_level.h"
-#include "base/system_util.h"
#include "base/util.h"
#include "client/client.h"
#include "data_manager/user_pos_manager.h"
@@ -531,16 +530,14 @@
// for Window Aero Glass support
#ifdef OS_WIN
- if (SystemUtil::IsVistaOrLater()) {
- setContentsMargins(0, 0, 0, 0);
- WinUtil::InstallStyleSheetsFiles(":win_aero_style.qss",
- ":win_style.qss");
- if (gui::WinUtil::IsCompositionEnabled()) {
- WinUtil::ExtendFrameIntoClientArea(this);
- InstallStyleSheet(":win_aero_style.qss");
- } else {
- InstallStyleSheet(":win_style.qss");
- }
+ setContentsMargins(0, 0, 0, 0);
+ WinUtil::InstallStyleSheetsFiles(":win_aero_style.qss",
+ ":win_style.qss");
+ if (gui::WinUtil::IsCompositionEnabled()) {
+ WinUtil::ExtendFrameIntoClientArea(this);
+ InstallStyleSheet(":win_aero_style.qss");
+ } else {
+ InstallStyleSheet(":win_style.qss");
}
#endif
diff --git a/src/ipc/ipc_path_manager.cc b/src/ipc/ipc_path_manager.cc
index ce767a0..e0ad260 100644
--- a/src/ipc/ipc_path_manager.cc
+++ b/src/ipc/ipc_path_manager.cc
@@ -329,9 +329,6 @@
#ifdef OS_WIN
{
- DCHECK(SystemUtil::IsVistaOrLater())
- << "This verification is functional on Vista and later.";
-
wstring expected_server_ntpath;
const map<string, wstring>::const_iterator it =
expected_server_ntpath_cache_.find(server_path);
diff --git a/src/ipc/win32_ipc.cc b/src/ipc/win32_ipc.cc
index b6c3528..a820ae3 100644
--- a/src/ipc/win32_ipc.cc
+++ b/src/ipc/win32_ipc.cc
@@ -40,7 +40,6 @@
#include "base/const.h"
#include "base/cpu_stats.h"
#include "base/logging.h"
-#include "base/mutex.h"
#include "base/scoped_handle.h"
#include "base/singleton.h"
#include "base/system_util.h"
@@ -58,44 +57,6 @@
const bool kSendTypeData = false;
const int kMaxSuccessiveConnectionFailureCount = 5;
-typedef BOOL (WINAPI *FPGetNamedPipeServerProcessId)(HANDLE, PULONG);
-FPGetNamedPipeServerProcessId g_get_named_pipe_server_process_id = nullptr;
-
-typedef BOOL (WINAPI *FPSetFileCompletionNotificationModes)(HANDLE, UCHAR);
-FPSetFileCompletionNotificationModes
- g_set_file_completion_notification_modes = nullptr;
-
-// Defined when _WIN32_WINNT >= 0x600
-#ifndef FILE_SKIP_SET_EVENT_ON_HANDLE
-#define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2
-#endif // FILE_SKIP_SET_EVENT_ON_HANDLE
-
-once_t g_once = MOZC_ONCE_INIT;
-
-void InitAPIsForVistaAndLater() {
- // We have to load the function pointer dynamically
- // as GetNamedPipeServerProcessId() is only available on Windows Vista.
- if (!SystemUtil::IsVistaOrLater()) {
- return;
- }
-
- VLOG(1) << "Initializing GetNamedPipeServerProcessId";
- // kernel32.dll must be loaded in client.
- const HMODULE lib = WinUtil::GetSystemModuleHandle(L"kernel32.dll");
- if (lib == nullptr) {
- LOG(ERROR) << "GetSystemModuleHandle for kernel32.dll failed.";
- return;
- }
-
- g_get_named_pipe_server_process_id =
- reinterpret_cast<FPGetNamedPipeServerProcessId>
- (::GetProcAddress(lib, "GetNamedPipeServerProcessId"));
-
- g_set_file_completion_notification_modes =
- reinterpret_cast<FPSetFileCompletionNotificationModes>
- (::GetProcAddress(lib, "SetFileCompletionNotificationModes"));
-}
-
size_t GetNumberOfProcessors() {
// thread-safety is not required.
static size_t num = CPUStats().GetNumberOfProcessors();
@@ -256,14 +217,8 @@
};
uint32 GetServerProcessIdImpl(HANDLE handle) {
- CallOnce(&g_once, &InitAPIsForVistaAndLater);
-
- if (g_get_named_pipe_server_process_id == nullptr) {
- return static_cast<uint32>(0); // must be Windows XP
- }
-
ULONG pid = 0;
- if ((*g_get_named_pipe_server_process_id)(handle, &pid) == 0) {
+ if (::GetNamedPipeServerProcessId(handle, &pid) == 0) {
const DWORD get_named_pipe_server_process_id_error = ::GetLastError();
LOG(ERROR) << "GetNamedPipeServerProcessId failed: "
<< get_named_pipe_server_process_id_error;
@@ -492,12 +447,9 @@
// This slightly improves the performance.
// See http://msdn.microsoft.com/en-us/library/windows/desktop/aa365538.aspx
void MaybeDisableFileCompletionNotification(HANDLE device_handle) {
- CallOnce(&g_once, &InitAPIsForVistaAndLater);
- if (g_set_file_completion_notification_modes != nullptr) {
- // This is not a mandatory task. Just ignore the actual error (if any).
- g_set_file_completion_notification_modes(device_handle,
- FILE_SKIP_SET_EVENT_ON_HANDLE);
- }
+ // This is not a mandatory task. Just ignore the actual error (if any).
+ ::SetFileCompletionNotificationModes(device_handle,
+ FILE_SKIP_SET_EVENT_ON_HANDLE);
}
} // namespace
diff --git a/src/mozc_version_template.txt b/src/mozc_version_template.txt
index 3a98503..09cb1d1 100644
--- a/src/mozc_version_template.txt
+++ b/src/mozc_version_template.txt
@@ -1,6 +1,6 @@
MAJOR=2
MINOR=16
-BUILD=2039
+BUILD=2040
REVISION=102
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
# downloaded by NaCl Mozc.
diff --git a/src/server/cache_service_manager.cc b/src/server/cache_service_manager.cc
index b096a43..5ea2a98 100644
--- a/src/server/cache_service_manager.cc
+++ b/src/server/cache_service_manager.cc
@@ -79,11 +79,10 @@
SC_HANDLE handle_;
};
-// Returns a redirector for the specified string resource in Vista or later.
-// Returns a redirected string for the specified string resource in XP.
+// Returns a redirector for the specified string resource for Vista or later.
// Returns an empty string if any error occurs.
// See http://msdn.microsoft.com/en-us/library/dd374120.aspx for details.
-wstring GetRegistryStringRedirectorOrRedirectedString(int resource_id) {
+wstring GetRegistryStringRedirector(int resource_id) {
const wchar_t kRegistryStringRedirectionPattern[] = L"@%s,-%d";
const wstring &service_path = CacheServiceManager::GetUnquotedServicePath();
wchar_t buffer[MAX_PATH] = { L'\0' };
@@ -95,30 +94,17 @@
return L"";
}
const wstring redirector(buffer);
- if (SystemUtil::IsVistaOrLater()) {
- // If this program is running on Windows Vista or later,
- // just returns the redirector.
- return redirector;
- }
-
- // If this program is running on Windows XP,
- // explicitly calls SHLoadIndirectString and returns the retrieved string
- // resource.
- wchar_t redirected_string[4096] = { L'\0' };
- hr = ::SHLoadIndirectString(redirector.c_str(), redirected_string,
- sizeof(redirected_string), NULL);
- if (hr != S_OK) {
- return L"";
- }
- return redirected_string;
+ // If this program is running on Windows Vista or later,
+ // just returns the redirector.
+ return redirector;
}
wstring GetDisplayName() {
- return GetRegistryStringRedirectorOrRedirectedString(IDS_DISPLAYNAME);
+ return GetRegistryStringRedirector(IDS_DISPLAYNAME);
}
wstring GetDescription() {
- return GetRegistryStringRedirectorOrRedirectedString(IDS_DESCRIPTION);
+ return GetRegistryStringRedirector(IDS_DESCRIPTION);
}
// This function serializes a given message (any type of protobuf message)
@@ -298,11 +284,6 @@
// We do not care about any failure because it is not critical for the
// functionality of the cache service itself.
void SetAdvancedConfig(const ScopedSCHandle &service_handle) {
- // On Windows XP, we have nothing to do.
- if (!SystemUtil::IsVistaOrLater()) {
- return;
- }
-
// Windows Vista or later has some nice features as described in the
// following documents.
// http://msdn.microsoft.com/en-us/magazine/cc164252.aspx
diff --git a/src/server/mozc_cache_service.cc b/src/server/mozc_cache_service.cc
index 1c68e91..9749eb9 100644
--- a/src/server/mozc_cache_service.cc
+++ b/src/server/mozc_cache_service.cc
@@ -190,10 +190,6 @@
return true;
}
- if (!mozc::SystemUtil::IsVistaOrLater()) {
- return true;
- }
-
const string temp_path =
mozc::FileUtil::JoinPath(mozc::SystemUtil::GetServerDirectory(),
"delete_me.txt");
diff --git a/src/win32/base/imm_util.cc b/src/win32/base/imm_util.cc
index 293ea5f..b903073 100644
--- a/src/win32/base/imm_util.cc
+++ b/src/win32/base/imm_util.cc
@@ -294,21 +294,6 @@
return true;
}
-bool ImeUtil::SetCuasEnabled(bool enable) {
- if (SystemUtil::IsVistaOrLater()) {
- // No need to enable CUAS since it is always enabled on Vista or later.
- return true;
- }
-
- if (SystemUtil::IsWindowsX64()) {
- // see both 64 bit and 32 bit registry keys
- return SetCuasEnabledInternal(enable, KEY_WOW64_64KEY) &&
- SetCuasEnabledInternal(enable, KEY_WOW64_32KEY);
- } else {
- return SetCuasEnabledInternal(enable, 0);
- }
-}
-
// TF_IsCtfmonRunning looks for ctfmon.exe's mutex.
// Ctfmon.exe is running if TSF is enabled.
// Most of the implementation and comments are based on a code by
diff --git a/src/win32/base/imm_util.h b/src/win32/base/imm_util.h
index 9ad63ef..647fcc2 100644
--- a/src/win32/base/imm_util.h
+++ b/src/win32/base/imm_util.h
@@ -53,10 +53,6 @@
// in some special situations like CustomAction.
static bool SetDefault();
- // Enables or disables CUAS (Cicero Unaware Application Support).
- // Returns true if the operation completed successfully.
- static bool SetCuasEnabled(bool enable);
-
// Returns true if cfmon.exe is running.
// ctfmon.exe is running if TSF (Text Service Framework) is enabled.
static bool IsCtfmonRunning();
diff --git a/src/win32/base/input_dll_test.cc b/src/win32/base/input_dll_test.cc
index c380f51..0507c9c 100644
--- a/src/win32/base/input_dll_test.cc
+++ b/src/win32/base/input_dll_test.cc
@@ -29,7 +29,6 @@
#include <string>
-#include "base/system_util.h"
#include "testing/base/public/googletest.h"
#include "testing/base/public/gunit.h"
#include "win32/base/input_dll.h"
@@ -74,20 +73,12 @@
// Actually input.dll exists on Windows XP. However, it does not always
// mean that input.dll exports the functions in which we are interested.
- if (SystemUtil::IsVistaOrLater()) {
- // Assume that the following funcsions are available on Vista and later.
- EXPECT_NE(nullptr, InputDll::enum_enabled_layout_or_tip());
- EXPECT_NE(nullptr, InputDll::enum_layout_or_tip_for_setup());
- EXPECT_NE(nullptr, InputDll::install_layout_or_tip());
- EXPECT_NE(nullptr, InputDll::install_layout_or_tip_user_reg());
- EXPECT_NE(nullptr, InputDll::set_default_layout_or_tip());
- } else {
- // Assume that the following funcsions are not available on XP and prior.
- EXPECT_EQ(nullptr, InputDll::enum_enabled_layout_or_tip());
- EXPECT_EQ(nullptr, InputDll::enum_layout_or_tip_for_setup());
- EXPECT_EQ(nullptr, InputDll::install_layout_or_tip_user_reg());
- EXPECT_EQ(nullptr, InputDll::set_default_layout_or_tip());
- }
+ // Assume that the following funcsions are available on Vista and later.
+ EXPECT_NE(nullptr, InputDll::enum_enabled_layout_or_tip());
+ EXPECT_NE(nullptr, InputDll::enum_layout_or_tip_for_setup());
+ EXPECT_NE(nullptr, InputDll::install_layout_or_tip());
+ EXPECT_NE(nullptr, InputDll::install_layout_or_tip_user_reg());
+ EXPECT_NE(nullptr, InputDll::set_default_layout_or_tip());
// Check the consistency of the retuls of second call.
EXPECT_TRUE(InputDll::EnsureInitialized());
diff --git a/src/win32/base/uninstall_helper.cc b/src/win32/base/uninstall_helper.cc
index a49ab81..5313685 100644
--- a/src/win32/base/uninstall_helper.cc
+++ b/src/win32/base/uninstall_helper.cc
@@ -576,15 +576,6 @@
}
}
-void UnloadLayoutsForXP(
- const vector<KeyboardLayoutInfo> &new_preload_layouts) {
- vector <wstring> ime_filenames;
- for (size_t i = 0; i < new_preload_layouts.size(); ++i) {
- ime_filenames.push_back(new_preload_layouts[i].ime_filename);
- }
- UnloadActivatedKeyboardMain(ime_filenames, false);
-}
-
void UnloadProfilesForVista(
const vector<LayoutProfileInfo> &profiles_to_be_removed) {
vector <wstring> ime_filenames;
@@ -692,25 +683,6 @@
// Currently this function is Mozc-specific.
// TODO(yukawa): Generalize this function for any IME.
-void RemoveHotKeyForXP(const vector<KeyboardLayoutInfo> &installed_layouts) {
- vector<KeyboardLayoutInfo> hotkey_remove_targets;
- for (size_t i = 0; i < installed_layouts.size(); ++i) {
- const KeyboardLayoutInfo &layout = installed_layouts[i];
- if (WinUtil::SystemEqualString(
- layout.ime_filename, ImmRegistrar::GetFileNameForIME(), true)) {
- // This is the full IMM32 version of Google Japanese Input.
- hotkey_remove_targets.push_back(layout);
- continue;
- }
- }
-
- if (!RemoveHotKeyForIME(hotkey_remove_targets)) {
- DLOG(ERROR) << "RemoveHotKeyForIME failed.";
- }
-}
-
-// Currently this function is Mozc-specific.
-// TODO(yukawa): Generalize this function for any IME.
void RemoveHotKeyForVista(const vector<LayoutProfileInfo> &installed_profiles) {
vector<KeyboardLayoutInfo> hotkey_remove_targets;
for (size_t i = 0; i < installed_profiles.size(); ++i) {
@@ -746,39 +718,6 @@
is_enabled(false) {}
// Currently this function is Mozc-specific.
-// TODO(yukawa): Generalize this function for any IME.
-bool UninstallHelper::GetNewPreloadLayoutsForXP(
- const vector<KeyboardLayoutInfo> &preload_layouts,
- const vector<KeyboardLayoutInfo> &installed_layouts,
- vector<KeyboardLayoutInfo> *new_preloads) {
- if (new_preloads == nullptr) {
- return false;
- }
-
- new_preloads->clear();
- for (size_t i = 0; i < preload_layouts.size(); ++i) {
- const KeyboardLayoutInfo &layout = preload_layouts[i];
- if (WinUtil::SystemEqualString(
- layout.ime_filename, ImmRegistrar::GetFileNameForIME(), true)) {
- // This is the full IMM32 version of Google Japanese Input.
- continue;
- }
- new_preloads->push_back(layout);
- }
-
- if (new_preloads->size() == 0) {
- // TODO(yukawa): Consider this case.
- // Use MS-IME as a fallback.
- KeyboardLayoutInfo msime_info;
- msime_info.klid = kDefaultKLIDForMSIMEJa;
- msime_info.ime_filename = kDefaultMSIMEJaFileName;
- new_preloads->push_back(msime_info);
- }
-
- return true;
-}
-
-// Currently this function is Mozc-specific.
// TODO(yukawa): Generalize this function for any IME and/or TIP.
bool UninstallHelper::GetNewEnabledProfileForVista(
const vector<LayoutProfileInfo> ¤t_profiles,
@@ -874,45 +813,6 @@
return true;
}
-bool UninstallHelper::GetKeyboardLayoutsForXP(
- vector<KeyboardLayoutInfo> *preload_layouts,
- vector<KeyboardLayoutInfo> *installed_layouts) {
- if (preload_layouts == nullptr) {
- return false;
- }
- preload_layouts->clear();
- if (installed_layouts == nullptr) {
- return false;
- }
- installed_layouts->clear();
- if (!GenerateKeyboardLayoutList(installed_layouts)) {
- return false;
- }
-
- map<DWORD, wstring> keyboard_layouts;
- for (size_t i = 0; i < installed_layouts->size(); ++i) {
- const KeyboardLayoutInfo &layout = (*installed_layouts)[i];
- keyboard_layouts[layout.klid] = layout.ime_filename;
- }
-
- PreloadOrderToKLIDMap preload_map;
- if (!GetPreloadLayoutsMain(&preload_map)) {
- return false;
- }
-
- for (PreloadOrderToKLIDMap::const_iterator it = preload_map.begin();
- it != preload_map.end(); ++it) {
- KeyboardLayoutInfo info;
- info.klid = it->second;
- if (keyboard_layouts.find(info.klid) != keyboard_layouts.end()) {
- info.ime_filename = keyboard_layouts[info.klid];
- }
- preload_layouts->push_back(info);
- }
-
- return true;
-}
-
bool UninstallHelper::GetCurrentProfilesForVista(
vector<LayoutProfileInfo> *current_profiles) {
if (current_profiles == nullptr) {
@@ -989,65 +889,6 @@
return true;
}
-bool UninstallHelper::UpdatePreloadLayoutsForXP(
- const vector<KeyboardLayoutInfo> &new_preload_layouts) {
- // First, retrieve existing preload entries. |current_preload_map|
- // represents the relationship between the value name and KLID as following
- // example.
- // 1: 0xE0200411
- // 2: 0x00000411
- // 3: 0xE0210411
- // 4: 0xE0220411
- PreloadOrderToKLIDMap current_preload_map;
- if (!GetPreloadLayoutsMain(¤t_preload_map)) {
- return false;
- }
-
- if (IsEqualPreload(current_preload_map, new_preload_layouts)) {
- // Already the same.
- return true;
- }
-
- // Open the preload key for update.
- CRegKey preload_key;
- LONG result = preload_key.Open(
- HKEY_CURRENT_USER, kPreloadKeyName, KEY_READ | KEY_WRITE);
- if (ERROR_SUCCESS != result) {
- return false;
- }
-
- // Second, delete unnecessary entries from bottom to top. For example,
- // if |new_preload_layouts| consists of [0xE0210411, 0xE0220411], the
- // following code removes |current_preload_map[4]| and
- // |current_preload_map[3]| in this order.
- bool failed = false;
- for (PreloadOrderToKLIDMap::const_reverse_iterator it =
- current_preload_map.rbegin();
- it != current_preload_map.rend(); ++it) {
- if (it->first > new_preload_layouts.size()) {
- result = preload_key.DeleteValue(utow(it->first).c_str());
- if (result != ERROR_SUCCESS) {
- failed = true;
- }
- }
- }
-
- // Third, (over)write the new entry from top to down. Note that
- // the preload value name, which seems to be a sort of index, is
- // 1-origin.
- for (size_t i = 0; i < new_preload_layouts.size(); ++i) {
- const KeyboardLayoutID klid(new_preload_layouts[i].klid);
- const int preload_index = i + 1; // 1-origin.
- result = preload_key.SetStringValue(
- utow(preload_index).c_str(), klid.ToString().c_str());
- if (result != ERROR_SUCCESS) {
- failed = true;
- }
- }
-
- return !failed;
-}
-
bool UninstallHelper::RemoveProfilesForVista(
const vector<LayoutProfileInfo> &profiles_to_be_removed) {
if (profiles_to_be_removed.size() == 0) {
@@ -1100,20 +941,6 @@
return ss.str();
}
-bool UninstallHelper::SetDefaultForXP(
- const KeyboardLayoutInfo &layout, bool broadcast_change) {
- EnableAndSetDefaultIfLayoutIsTIP(layout);
-
- if (broadcast_change) {
- if (!BroadcastNewIME(layout)) {
- DLOG(ERROR) << "BroadcastNewIME failed";
- return false;
- }
- }
-
- return true;
-}
-
bool UninstallHelper::SetDefaultForVista(
const LayoutProfileInfo ¤t_default,
const LayoutProfileInfo &new_default, bool broadcast_change) {
@@ -1160,42 +987,6 @@
return true;
}
-bool UninstallHelper::RestoreUserIMEEnvironmentForXP(bool broadcast_change) {
- vector<KeyboardLayoutInfo> preload_layouts;
- vector<KeyboardLayoutInfo> installed_layouts;
- if (!GetKeyboardLayoutsForXP(&preload_layouts, &installed_layouts)) {
- return false;
- }
-
- RemoveHotKeyForXP(installed_layouts);
-
- vector<KeyboardLayoutInfo> new_preloads;
- if (!GetNewPreloadLayoutsForXP(
- preload_layouts, installed_layouts, &new_preloads)) {
- return false;
- }
- if (new_preloads.size() > 0) {
- // The entry named '1' under the 'Preload' key corresponds to the user's
- // default layout. This was documented at least Windows 2000 Server and
- // seems to be applicable on later version such as Windows XP.
- // http://technet.microsoft.com/en-us/library/cc978687.aspx
- // Starting with Vista, there are some documented functions to tweak
- // default keyboard layout or TIP. See input_dll.h for details.
- const KeyboardLayoutInfo &new_default = new_preloads[0];
- if (!SetDefaultForXP(new_default, broadcast_change)) {
- DLOG(ERROR) << "SetDefaultForXP failed.";
- }
- if (!UpdatePreloadLayoutsForXP(new_preloads)) {
- DLOG(ERROR) << "UpdatePreloadLayoutsForXP failed.";
- }
- if (broadcast_change) {
- // Finally unload unnecessary keyboard layouts.
- UnloadLayoutsForXP(new_preloads);
- }
- }
- return true;
-}
-
bool UninstallHelper::RestoreUserIMEEnvironmentForVista(bool broadcast_change) {
vector<LayoutProfileInfo> installed_profiles;
if (!GetInstalledProfilesByLanguage(kLANGJaJP, &installed_profiles)) {
@@ -1237,11 +1028,7 @@
// start to use the new default IME.
const bool kBroadcastNewIME = true;
- if (SystemUtil::IsVistaOrLater()) {
- return RestoreUserIMEEnvironmentForVista(kBroadcastNewIME);
- } else {
- return RestoreUserIMEEnvironmentForXP(kBroadcastNewIME);
- }
+ return RestoreUserIMEEnvironmentForVista(kBroadcastNewIME);
}
bool UninstallHelper::EnsureIMEIsRemovedForCurrentUser(
@@ -1264,11 +1051,8 @@
// notification will not be sent in case it causes unwilling side-effects
// against other important processes running in the service session.
const bool kBroadcastNewIME = false;
- if (SystemUtil::IsVistaOrLater()) {
- return RestoreUserIMEEnvironmentForVista(kBroadcastNewIME);
- } else {
- return RestoreUserIMEEnvironmentForXP(kBroadcastNewIME);
- }
+ return RestoreUserIMEEnvironmentForVista(kBroadcastNewIME);
}
+
} // namespace win32
} // namespace mozc
diff --git a/src/win32/base/uninstall_helper.h b/src/win32/base/uninstall_helper.h
index feda6e3..d0e5323 100644
--- a/src/win32/base/uninstall_helper.h
+++ b/src/win32/base/uninstall_helper.h
@@ -92,19 +92,9 @@
private:
// This function is the main part of RestoreUserIMEEnvironmentMain for
- // Windows XP.
- static bool RestoreUserIMEEnvironmentForXP(bool broadcast_change);
-
- // This function is the main part of RestoreUserIMEEnvironmentMain for
// Windows Vista and later.
static bool RestoreUserIMEEnvironmentForVista(bool broadcast_change);
- // Returns true if new preload layouts are successfully determined.
- static bool GetNewPreloadLayoutsForXP(
- const vector<KeyboardLayoutInfo> &preload_layouts,
- const vector<KeyboardLayoutInfo> &installed_layouts,
- vector<KeyboardLayoutInfo> *new_preloads);
-
// Returns true if both new enabled profiles and new default profile are
// successfully determined.
static bool GetNewEnabledProfileForVista(
@@ -114,33 +104,16 @@
LayoutProfileInfo *new_default,
vector<LayoutProfileInfo> *removed_profiles);
- // Returns true if the list of keyboard layout in 'Preload' key under HKCU
- // and 'Keyboard Layouts' key under HKLM are retrieved in successful.
- // For Windows Vista and later, use GetCurrentProfilesForVista instead.
- static bool GetKeyboardLayoutsForXP(
- vector<KeyboardLayoutInfo> *preload_layouts,
- vector<KeyboardLayoutInfo> *installed_layouts);
-
// Returns true if the list of keyboard layout and TIP for the current user
// is retrieved in successful.
static bool GetCurrentProfilesForVista(
vector<LayoutProfileInfo> *current_profiles);
- // Returns true if the 'Preload' key for the current user is updated with
- // the specified list of keyboard layout as |preload_layouts|.
- static bool UpdatePreloadLayoutsForXP(
- const vector<KeyboardLayoutInfo> &new_preload_layouts);
-
// Returns true if the list of keyboard layout and TIP for the current user
// is updated with the specified list as |profiles_to_be_removed|.
static bool RemoveProfilesForVista(
const vector<LayoutProfileInfo> &profiles_to_be_removed);
- // Returns true if |layout| is set as the new default IME. If |layout| is
- // substituted by a TIP, this function sets the underlaying TIP to default.
- static bool SetDefaultForXP(
- const KeyboardLayoutInfo &layout, bool broadcast_change);
-
// Returns true if |profile| is set as the new default IME or TIP.
static bool SetDefaultForVista(
const LayoutProfileInfo ¤t_default,
@@ -152,7 +125,6 @@
static wstring ComposeProfileStringForVista(
const vector<LayoutProfileInfo> &profiles);
- FRIEND_TEST(UninstallHelperTest, Issue_2950946);
FRIEND_TEST(UninstallHelperTest, BasicCaseForVista);
FRIEND_TEST(UninstallHelperTest, BasicCaseForWin8);
FRIEND_TEST(UninstallHelperTest, LoadKeyboardProfilesTest);
diff --git a/src/win32/base/uninstall_helper_test.cc b/src/win32/base/uninstall_helper_test.cc
index 4821ee7..68bc706 100644
--- a/src/win32/base/uninstall_helper_test.cc
+++ b/src/win32/base/uninstall_helper_test.cc
@@ -31,7 +31,6 @@
#include <CGuid.h>
#include "base/const.h"
-#include "base/system_util.h"
#include "base/util.h"
#include "testing/base/public/googletest.h"
#include "testing/base/public/gunit.h"
@@ -63,47 +62,6 @@
} // namespace
-// Test case for b/2950946
-// 1. Install Google Japanese Input into Windows XP.
-// 2. Set Google Japanese Input as the default IME.
-// 3. Uninstall Google Japanese Input.
-// -> MS-IME should be the default IME.
-TEST(UninstallHelperTest, Issue_2950946) {
- // Full IMM32 version of Google Japanese Input.
- KeyboardLayoutInfo gimeja;
- {
- gimeja.klid = kJapaneseKLID;
- gimeja.ime_filename = ToWideString(kIMEFile);
- }
- // Built-in MS-IME.
- KeyboardLayoutInfo msime;
- {
- msime.klid = 0xE0010411;
- msime.ime_filename = L"imjp81.ime";
- }
-
- // First entry of |current_preloads| is the default IME.
- vector<KeyboardLayoutInfo> current_preloads;
- current_preloads.push_back(gimeja);
- current_preloads.push_back(msime);
-
- // |installed_preloads| is sorted by |klid|.
- vector<KeyboardLayoutInfo> installed_preloads;
- installed_preloads.push_back(msime);
- installed_preloads.push_back(gimeja);
-
- vector<KeyboardLayoutInfo> new_preloads;
-
- EXPECT_TRUE(UninstallHelper::GetNewPreloadLayoutsForXP(
- current_preloads,
- installed_preloads,
- &new_preloads));
-
- EXPECT_EQ(1, new_preloads.size());
- EXPECT_EQ(msime.klid, new_preloads.at(0).klid);
- EXPECT_EQ(msime.ime_filename, new_preloads.at(0).ime_filename);
-}
-
TEST(UninstallHelperTest, BasicCaseForVista) {
// 1. Install Google Japanese Input into Windows Vista.
// 2. Set Google Japanese Input as the default IME.
@@ -234,16 +192,9 @@
EXPECT_TRUE(UninstallHelper::GetInstalledProfilesByLanguage(
kLANGJaJP, &installed_profiles));
- if (SystemUtil::IsVistaOrLater()) {
- vector<LayoutProfileInfo> current_profiles;
- EXPECT_TRUE(UninstallHelper::GetCurrentProfilesForVista(
- ¤t_profiles));
- }
-
- vector<KeyboardLayoutInfo> preload_layouts;
- vector<KeyboardLayoutInfo> installed_layouts;
- EXPECT_TRUE(UninstallHelper::GetKeyboardLayoutsForXP(
- &preload_layouts, &installed_layouts));
+ vector<LayoutProfileInfo> current_profiles;
+ EXPECT_TRUE(UninstallHelper::GetCurrentProfilesForVista(
+ ¤t_profiles));
}
TEST(UninstallHelperTest, ComposeProfileStringForVistaTest) {
diff --git a/src/win32/base/win32_window_util.cc b/src/win32/base/win32_window_util.cc
index 6a25568..df53b4f 100644
--- a/src/win32/base/win32_window_util.cc
+++ b/src/win32/base/win32_window_util.cc
@@ -41,7 +41,6 @@
#include "base/logging.h"
#include "base/port.h"
-#include "base/system_util.h"
#include "base/win_util.h"
namespace mozc {
@@ -100,13 +99,6 @@
const int kMessageFilterAdd = 1; // MSGFLT_ADD (WINVER >=0x0600)
const int kMessageFilterAllow = 1; // MSGFLT_ALLOW (WINVER >=0x0601)
- // Skip windows XP.
- // ChangeWindowMessageFilter is only available on Windows Vista or Later
- if (!SystemUtil::IsVistaOrLater()) {
- LOG(ERROR) << "Skip ChangeWindowMessageFilter on Windows XP";
- return true;
- }
-
const HMODULE lib = WinUtil::GetSystemModuleHandle(L"user32.dll");
if (lib == nullptr) {
LOG(ERROR) << L"GetModuleHandle for user32.dll failed.";
@@ -132,17 +124,7 @@
}
// Windows Vista
- FPChangeWindowMessageFilter change_window_message_filter
- = reinterpret_cast<FPChangeWindowMessageFilter>(
- ::GetProcAddress(lib, "ChangeWindowMessageFilter"));
- if (change_window_message_filter == nullptr) {
- const int error = ::GetLastError();
- LOG(ERROR) << L"GetProcAddress failed. error = " << error;
- return false;
- }
-
- DCHECK(change_window_message_filter != nullptr);
- if (!(*change_window_message_filter)(message, kMessageFilterAdd)) {
+ if (!::ChangeWindowMessageFilter(message, kMessageFilterAdd)) {
const int error = ::GetLastError();
LOG(ERROR) << L"ChangeWindowMessageFilter failed. error = " << error;
return false;
diff --git a/src/win32/broker/prelauncher.cc b/src/win32/broker/prelauncher.cc
index 9d4f487..aa750ad 100644
--- a/src/win32/broker/prelauncher.cc
+++ b/src/win32/broker/prelauncher.cc
@@ -39,7 +39,6 @@
#include "base/const.h"
#include "base/logging.h"
#include "base/run_level.h"
-#include "base/system_util.h"
#include "base/util.h"
#include "base/win_util.h"
#include "client/client_interface.h"
@@ -78,11 +77,7 @@
const HANDLE thread_handle = ::GetCurrentThread();
// Enter low priority mode.
- if (SystemUtil::IsVistaOrLater()) {
- ::SetThreadPriority(thread_handle, THREAD_MODE_BACKGROUND_BEGIN);
- } else {
- ::SetThreadPriority(thread_handle, THREAD_PRIORITY_IDLE);
- }
+ ::SetThreadPriority(thread_handle, THREAD_MODE_BACKGROUND_BEGIN);
}
} // namespace
diff --git a/src/win32/ime/ime_language_bar_menu.cc b/src/win32/ime/ime_language_bar_menu.cc
index 8f0d132..96d0d6b 100644
--- a/src/win32/ime/ime_language_bar_menu.cc
+++ b/src/win32/ime/ime_language_bar_menu.cc
@@ -44,7 +44,6 @@
#include <limits>
#include "base/logging.h"
-#include "base/system_util.h"
#include "base/win_util.h"
#include "win32/base/text_icon.h"
#include "win32/ime/ime_impl_imm.h"
@@ -407,12 +406,6 @@
}
bool ImeLangBarMenu::CanContextMenuDisplay32bppIcon() {
- // Windows XP does not support a 32-bpp icon for a context menu icon on the
- // LangBar. See http://b/2260057 for details.
- if (!mozc::SystemUtil::IsVistaOrLater()) {
- return false;
- }
-
// We always use a non-theme icon for a context menu icon on the LangBar
// unless the current display mode is 32-bpp. We cannot assume we can
// display a 32-bpp icon for a context menu icon on the LangBar unless the
diff --git a/src/win32/tip/tip_lang_bar_menu.cc b/src/win32/tip/tip_lang_bar_menu.cc
index bdaee64..8ba0135 100644
--- a/src/win32/tip/tip_lang_bar_menu.cc
+++ b/src/win32/tip/tip_lang_bar_menu.cc
@@ -42,7 +42,6 @@
#include <limits>
-#include "base/system_util.h"
#include "base/win_util.h"
#include "win32/base/text_icon.h"
#include "win32/base/tsf_profile.h"
@@ -480,12 +479,6 @@
}
bool TipLangBarButton::CanContextMenuDisplay32bppIcon() {
- // Windows XP does not support a 32-bpp icon for a context menu icon on the
- // LangBar. See http://b/2260057 for details.
- if (!SystemUtil::IsVistaOrLater()) {
- return false;
- }
-
// We always use a non-theme icon for a context menu icon on the LangBar
// unless the current display mode is 32-bpp. We cannot assume we can
// display a 32-bpp icon for a context menu icon on the LangBar unless the