Index: chrome_frame/chrome_tab.cc |
=================================================================== |
--- chrome_frame/chrome_tab.cc (revision 71338) |
+++ chrome_frame/chrome_tab.cc (working copy) |
@@ -8,6 +8,7 @@ |
#include "chrome_tab.h" // NOLINT |
#include <atlsecurity.h> |
+#include <vector> |
#include "base/at_exit.h" |
#include "base/command_line.h" |
@@ -426,6 +427,23 @@ |
L"User Agent\\Post Platform"; |
const wchar_t kChromeFramePrefix[] = L"chromeframe/"; |
+// Returns the list of chrome frame UA agents registered under the |
+// kPostPlatformUAKey registry key. |
+void GetRegisteredChromeFrameUAStrings(HKEY parent_hive, |
+ std::vector<std::wstring>* ua_values) { |
+ base::win::RegistryValueIterator ua_registration(parent_hive, |
+ kPostPlatformUAKey); |
+ std::wstring chrome_frame_ua_pattern = kChromeFramePrefix; |
+ chrome_frame_ua_pattern += L"*"; |
+ while (ua_registration.Valid()) { |
+ if (MatchPattern(ua_registration.Name(), |
+ chrome_frame_ua_pattern)) { |
+ ua_values->push_back(ua_registration.Name()); |
+ } |
+ ++ua_registration; |
+ } |
+} |
+ |
// To delete the user agent, set value to NULL. |
// The is_system parameter indicates whether this is a per machine or a per |
// user installation. |
@@ -433,11 +451,21 @@ |
HRESULT hr = E_FAIL; |
HKEY parent_hive = is_system ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
+ // If we are registering the ChromeFrame UA in the kPostPlatformUAKey key |
amit
2011/01/14 05:26:01
why not delete all the matching values anyway? If
|
+ // make sure that we unregister ChromeFrame UA strings registered by previous |
+ // ChromeFrame versions. |
+ std::vector<std::wstring> cf_ua_list; |
+ if (value) { |
+ GetRegisteredChromeFrameUAStrings(parent_hive, &cf_ua_list); |
+ } |
RegKey ua_key; |
if (ua_key.Create(parent_hive, kPostPlatformUAKey, KEY_WRITE)) { |
std::wstring chrome_frame_ua_value_name = kChromeFramePrefix; |
chrome_frame_ua_value_name += GetCurrentModuleVersion(); |
if (value) { |
+ for (size_t ua_idx = 0; ua_idx < cf_ua_list.size(); ua_idx++) { |
+ ua_key.DeleteValue(cf_ua_list[ua_idx].c_str()); |
+ } |
ua_key.WriteValue(chrome_frame_ua_value_name.c_str(), value); |
} else { |
ua_key.DeleteValue(chrome_frame_ua_value_name.c_str()); |