Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9904)

Unified Diff: chrome_frame/chrome_tab.cc

Issue 6355001: Unregister previous ChromeFrame UA strings registered under the PostPlatform ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698