Hello nicolasroard, zork,
I'd like you to do a code review. Please execute
g4 diff -c 8527797
or point your web browser to
http://mondrian/8527797
to review the following code:
Change 8527797 by [EMAIL PROTECTED] on 2008/10/08 15:31:44 *pending*
Correctly detect the locale on WinCE. A new CL will follow that will
remove strings_table.res (no longer needed) from the WinCE build.
R=nicolasroard,zork
[EMAIL PROTECTED]
DELTA=58 (58 added, 0 deleted, 0 changed)
OCL=8527797
Affected files ...
...
//depot/googleclient/gears/opensource/gears/base/common/wince_compatibility.cc#5
edit
...
//depot/googleclient/gears/opensource/gears/base/common/wince_compatibility.h#2
edit
... //depot/googleclient/gears/opensource/gears/ui/ie/html_dialog_ie.cc#3 edit
58 delta lines: 58 added, 0 deleted, 0 changed
Also consider running:
g4 lint -c 8527797
which verifies that the changelist doesn't introduce new style violations.
If you can't do the review, please let me know as soon as possible. During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately. Visit
http://www/eng/code_review.html for more information.
This is a semiautomated message from "g4 mail". Complaints or suggestions?
Mail [EMAIL PROTECTED]
Change 8527797 by [EMAIL PROTECTED] on 2008/10/08 15:31:44 *pending*
Correctly detect the locale on WinCE. A new CL will follow that will
remove strings_table.res (no longer needed) from the WinCE build.
Affected files ...
...
//depot/googleclient/gears/opensource/gears/base/common/wince_compatibility.cc#5
edit
...
//depot/googleclient/gears/opensource/gears/base/common/wince_compatibility.h#2
edit
... //depot/googleclient/gears/opensource/gears/ui/ie/html_dialog_ie.cc#3 edit
====
//depot/googleclient/gears/opensource/gears/base/common/wince_compatibility.cc#5
-
c:\GearsWinMo/googleclient/gears/opensource/gears/base/common/wince_compatibility.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/base/common/wince_compatibility.cc
2008-10-08 15:32:23.000000000 +0100
+++ googleclient/gears/opensource/gears/base/common/wince_compatibility.cc
2008-10-08 15:33:22.000000000 +0100
@@ -518,4 +518,48 @@
handler_ = NULL;
}
+// Localization
+
+static std::string16 GetSystemParameterInfo(UINT parameter) {
+ char16 parameter_value[MAX_PATH];
+ ZeroMemory(parameter_value, sizeof(parameter_value));
+ SystemParametersInfo(parameter,
+ sizeof(parameter_value),
+ parameter_value,
+ 0);
+ return std::string16(parameter_value);
+}
+
+static bool GetLocaleFromLcid(int32 locale_id, std::string16 *locale) {
+ // Get the current locale formatted as RFC-1766 from mlang.dll
+ HINSTANCE mlang_library = LoadLibrary(L"mlang");
+ assert(mlang_library);
+ char16 rfc_1766[6];
+ typedef HRESULT (LcidToRfc1766W)(LCID locale_id,
+ LPWSTR locale_string_out,
+ int nr_chars);
+ LcidToRfc1766W* ConvertLcidToRfc1766 = reinterpret_cast<LcidToRfc1766W*>(
+ GetProcAddress(mlang_library, L"LcidToRfc1766W"));
+ HRESULT ret = ConvertLcidToRfc1766(locale_id,
+ rfc_1766,
+ sizeof(rfc_1766) / sizeof(rfc_1766[0]));
+
+ FreeLibrary(mlang_library);
+ if (ret != S_OK) {return false;}
+ *locale = rfc_1766;
+ return true;
+}
+
+bool GetCurrentSystemLocale(std::string16 *locale) {
+ static const char16* kSmartphonePlatformType = L"SmartPhone";
+ LCID locale_id;
+ std::string16 platform_type = GetSystemParameterInfo(SPI_GETPLATFORMTYPE);
+ if (platform_type == kSmartphonePlatformType) {
+ locale_id = GetUserDefaultUILanguage();
+ } else {
+ locale_id = GetUserDefaultLCID();
+ }
+ return GetLocaleFromLcid(locale_id, locale);
+}
+
#endif // WINCE
====
//depot/googleclient/gears/opensource/gears/base/common/wince_compatibility.h#2
-
c:\GearsWinMo/googleclient/gears/opensource/gears/base/common/wince_compatibility.h
====
# action=edit type=text
--- googleclient/gears/opensource/gears/base/common/wince_compatibility.h
2008-10-08 15:32:23.000000000 +0100
+++ googleclient/gears/opensource/gears/base/common/wince_compatibility.h
2008-10-08 12:01:39.000000000 +0100
@@ -147,5 +147,12 @@
DISALLOW_EVIL_CONSTRUCTORS(UnloadEventSource);
};
+// Localization utilities
+
+// Returns the system local which the phone is operating in.
+// On smartphones this will be the locale of the selected language as opposed
+// to the selected system locale (which is a good thing).
+bool GetCurrentSystemLocale(std::string16 *locale);
+
#endif // GEARS_BASE_COMMON_WINCE_COMPATIBILITY_H__
#endif // WINCE
==== //depot/googleclient/gears/opensource/gears/ui/ie/html_dialog_ie.cc#3 -
c:\GearsWinMo/googleclient/gears/opensource/gears/ui/ie/html_dialog_ie.cc ====
# action=edit type=text
--- googleclient/gears/opensource/gears/ui/ie/html_dialog_ie.cc 2008-10-08
15:32:23.000000000 +0100
+++ googleclient/gears/opensource/gears/ui/ie/html_dialog_ie.cc 2008-10-08
11:59:49.000000000 +0100
@@ -26,6 +26,9 @@
#include "gears/base/common/process_utils_win32.h"
#include "gears/base/common/string16.h"
#include "gears/base/common/string_utils.h"
+#ifdef WINCE
+#include "gears/base/common/wince_compatibility.h"
+#endif
#include "gears/ui/common/html_dialog.h"
#ifdef WINCE
#include "gears/ui/ie/html_dialog_host_iemobile.h"
@@ -59,6 +62,9 @@
}
bool HtmlDialog::GetLocale(std::string16 *locale) {
+#ifdef WINCE
+ return GetCurrentSystemLocale(locale);
+#else
char16 locale_string[MAX_PATH];
if (LoadString(GetGearsModuleHandle(), IDS_LOCALE,
locale_string, MAX_PATH)) {
@@ -66,4 +72,5 @@
return true;
}
return false;
+#endif
}