Index: chrome_frame/chrome_tab.cc |
=================================================================== |
--- chrome_frame/chrome_tab.cc (revision 71338) |
+++ chrome_frame/chrome_tab.cc (working copy) |
@@ -434,13 +434,41 @@ |
HKEY parent_hive = is_system ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
RegKey ua_key; |
- if (ua_key.Create(parent_hive, kPostPlatformUAKey, KEY_WRITE)) { |
+ if (ua_key.Create(parent_hive, kPostPlatformUAKey, KEY_READ | KEY_WRITE)) { |
+ |
+ // Make sure that we unregister ChromeFrame UA strings registered previously |
+ std::wstring chrome_frame_ua_pattern = kChromeFramePrefix; |
+ chrome_frame_ua_pattern += L"*"; |
+ |
+ wchar_t name[MAX_PATH + 1] = {}; |
+ wchar_t value[MAX_PATH + 1] = {}; |
+ |
+ for (DWORD value_index = 0; value_index < ua_key.ValueCount(); |
amit
2011/01/14 06:38:51
nit: while (value_index < ua_key.ValueCount()) and
ananta
2011/01/14 06:44:11
Done.
|
+ value_index++) { |
+ DWORD name_size = arraysize(name); |
+ DWORD value_size = arraysize(value); |
+ DWORD type = 0; |
+ LRESULT ret = ::RegEnumValue(ua_key.Handle(), |
amit
2011/01/14 06:38:51
nit: fit more on one line to match rest of the sou
ananta
2011/01/14 06:44:11
Done.
|
+ value_index, |
+ name, |
+ &name_size, |
+ NULL, |
+ &type, reinterpret_cast<BYTE*>(value), |
+ &value_size); |
+ if (ret == ERROR_SUCCESS) { |
+ if (MatchPattern(name, chrome_frame_ua_pattern)) { |
amit
2011/01/14 06:38:51
A simple StartsWith is enough instead of MatchPatt
ananta
2011/01/14 06:44:11
Done.
|
+ ua_key.DeleteValue(name); |
+ value_index--; |
+ } |
+ } else { |
+ break; |
+ } |
+ } |
+ |
std::wstring chrome_frame_ua_value_name = kChromeFramePrefix; |
chrome_frame_ua_value_name += GetCurrentModuleVersion(); |
if (value) { |
ua_key.WriteValue(chrome_frame_ua_value_name.c_str(), value); |
- } else { |
- ua_key.DeleteValue(chrome_frame_ua_value_name.c_str()); |
} |
hr = S_OK; |
} else { |