diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 20:11:08 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 20:11:08 +0000 |
commit | cdd9fea014653052e1e2fc2a354b8526235bc65f (patch) | |
tree | c429690a9320d43be04b3013785af50d1333db72 | |
parent | 82b0f03294d4a9ee705cddf4a157572ea91512e9 (diff) | |
download | chromium_src-cdd9fea014653052e1e2fc2a354b8526235bc65f.zip chromium_src-cdd9fea014653052e1e2fc2a354b8526235bc65f.tar.gz chromium_src-cdd9fea014653052e1e2fc2a354b8526235bc65f.tar.bz2 |
Remove old ap-value munging code in Chrome Frame.
Review URL: http://codereview.chromium.org/303023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29696 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome_frame/chrome_tab.cc | 11 | ||||
-rw-r--r-- | chrome_frame/test/util_unittests.cc | 60 | ||||
-rw-r--r-- | chrome_frame/utils.cc | 71 | ||||
-rw-r--r-- | chrome_frame/utils.h | 28 |
4 files changed, 0 insertions, 170 deletions
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index a9423f3..8c526c4 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -272,12 +272,6 @@ STDAPI DllRegisterServer() { // registers object, typelib and all interfaces in typelib HRESULT hr = _AtlModule.DllRegisterServer(TRUE); -#ifdef GOOGLE_CHROME_BUILD - // Muck with the Omaha configuration so that we don't get updated by non-CF - // Google Chrome builds. - UtilUpdateOmahaConfig(true); -#endif - if (SUCCEEDED(hr)) { // Best effort attempt to register the BHO. At this point we silently // ignore any errors during registration. There are some traces emitted @@ -294,11 +288,6 @@ STDAPI DllRegisterServer() { STDAPI DllUnregisterServer() { HRESULT hr = _AtlModule.DllUnregisterServer(TRUE); -#ifdef GOOGLE_CHROME_BUILD - // Undo any prior mucking with the Omaha config. - UtilUpdateOmahaConfig(false); -#endif - if (SUCCEEDED(hr)) { // Best effort attempt to unregister the BHO. At this point we silently // ignore any errors during unregistration. There are some traces emitted diff --git a/chrome_frame/test/util_unittests.cc b/chrome_frame/test/util_unittests.cc index 3f07b82..b926ee4 100644 --- a/chrome_frame/test/util_unittests.cc +++ b/chrome_frame/test/util_unittests.cc @@ -9,66 +9,6 @@ const wchar_t kChannelName[] = L"-dev"; const wchar_t kSuffix[] = L"-fix"; -TEST(UtilTests, AppendSuffixToChannelNameTest) { - std::wstring str_base; - std::wstring channel_name(kChannelName); - std::wstring suffix(kSuffix); - - str_base = L"2.0-dev-bar"; - EXPECT_TRUE(AppendSuffixToChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0-dev-fix-bar", str_base.c_str()); - - str_base = L"2.0-dev-fix-bar"; - EXPECT_FALSE(AppendSuffixToChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0-dev-fix-bar", str_base.c_str()); - - str_base = L"2.0-dev-bar-dev-bar"; - EXPECT_TRUE(AppendSuffixToChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0-dev-fix-bar-dev-bar", str_base.c_str()); - - str_base = L"2.0"; - EXPECT_FALSE(AppendSuffixToChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0", str_base.c_str()); - - str_base = L"2.0-devvvv"; - EXPECT_TRUE(AppendSuffixToChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0-dev-fixvvv", str_base.c_str()); -} - -TEST(UtilTests, RemoveSuffixFromStringTest) { - std::wstring str_base; - std::wstring channel_name(kChannelName); - std::wstring suffix(kSuffix); - - str_base = L"2.0-dev-fix"; - EXPECT_TRUE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0-dev", str_base.c_str()); - - str_base = L"2.0-dev-fix-full"; - EXPECT_TRUE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0-dev-full", str_base.c_str()); - - str_base = L"2.0"; - EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0", str_base.c_str()); - - str_base = L"2.0-dev"; - EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0-dev", str_base.c_str()); - - str_base = L"2.0-fix"; - EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0-fix", str_base.c_str()); - - str_base = L"2.0-full-fix"; - EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0-full-fix", str_base.c_str()); - - str_base = L"2.0-dev-dev-fix"; - EXPECT_TRUE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); - EXPECT_STREQ(L"2.0-dev-dev", str_base.c_str()); -} - TEST(UtilTests, GetModuleVersionTest) { HMODULE mod = GetModuleHandle(L"kernel32.dll"); EXPECT_NE(mod, static_cast<HMODULE>(NULL)); diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index 36e8afd..246fa0d 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -194,77 +194,6 @@ HRESULT UtilGetXUACompatContentValue(const std::wstring& html_string, return E_FAIL; } -bool AppendSuffixToChannelName(std::wstring* string, - const std::wstring& channel_name, - const std::wstring& suffix) { - size_t pos = string->find(channel_name); - // Append the suffix only if we find the channel name. - if (pos != std::wstring::npos) { - pos += channel_name.size(); - // Append the suffix only to the channel name only if the name is not - // already followed by suffix. - if (string->find(suffix, pos) != pos) { - string->insert(pos, suffix); - return true; - } - } - return false; -} - -bool RemoveSuffixFromChannelName(std::wstring* string, - const std::wstring& channel_name, - const std::wstring& suffix) { - std::wstring decorated_channel(channel_name + suffix); - size_t pos = string->find(decorated_channel); - // TODO(robertshield): Remove the suffix iff the suffix is the last thing in - // the string or is followed by another suffix that starts with '-'. - if (pos != std::wstring::npos) { - pos += channel_name.size(); - string->erase(pos, suffix.size()); - return true; - } - return false; -} - -HRESULT UtilUpdateOmahaConfig(bool add_cf_suffix) { - HKEY reg_root = HKEY_LOCAL_MACHINE; - - RegKey key; - std::wstring ap_key_value; - std::wstring reg_key(google_update::kRegPathClientState); - reg_key.append(L"\\"); - reg_key.append(google_update::kChromeGuid); - if (!key.Open(reg_root, reg_key.c_str(), KEY_READ | KEY_WRITE) || - !key.ReadValue(google_update::kRegApField, &ap_key_value)) { - // Can't read the Omaha config. - return REGDB_E_READREGDB; - } - - HRESULT result = S_OK; - // We've read the key in, try and modify it then write it back. - if (add_cf_suffix && AppendSuffixToChannelName(&ap_key_value, - kDevChannelName, - kChromeFrameOmahaSuffix)) { - if (!key.WriteValue(google_update::kRegApField, ap_key_value.c_str())) { - DLOG(ERROR) << "Failed to add suffix to omaha ap key value."; - result = REGDB_E_WRITEREGDB; - } - } else if (!add_cf_suffix && - RemoveSuffixFromChannelName(&ap_key_value, - kDevChannelName, - kChromeFrameOmahaSuffix)) { - if (!key.WriteValue(google_update::kRegApField, ap_key_value.c_str())) { - DLOG(ERROR) << "Failed to remove suffix from omaha ap key value."; - result = REGDB_E_WRITEREGDB; - } - } else { - // Getting here means that no modifications needed to be made. - result = S_FALSE; - } - - return result; -} - std::wstring GetResourceString(int resource_id) { std::wstring resource_string; HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase); diff --git a/chrome_frame/utils.h b/chrome_frame/utils.h index 7b56621..2f79013 100644 --- a/chrome_frame/utils.h +++ b/chrome_frame/utils.h @@ -54,34 +54,6 @@ HRESULT UtilUnRegisterTypeLib(ITypeLib* typelib, HRESULT UtilGetXUACompatContentValue(const std::wstring& html_string, std::wstring* content_value); - -// Appends |suffix| to the substring |channel_name| of |string| iff -// the first instance of |channel_name| in |string| is not already followed by -// |suffix|. -// Returns true if |string| was modified. -bool AppendSuffixToChannelName(std::wstring* string, - const std::wstring& channel_name, - const std::wstring& suffix); - -// Removes |suffix| from |string| if |string| contains |channel_name| followed -// by |suffix|. -// Returns true if |string| was modified. -bool RemoveSuffixFromChannelName(std::wstring* string, - const std::wstring& channel_name, - const std::wstring& suffix); - -// Looks for and alters if found the Omaha configuration for Chrome in the -// registry. This changes the auto-update release channel to prevent installed -// builds of Chrome that include Chrome Frame from getting replaced by -// Chrome updates without it. -// Adds the Chrome Frame suffix if add_cf_suffix is true, removes it -// otherwise. -// Returns S_OK if the Chrome Omaha configuration was found and updated. -// Returns S_FALSE if the configuration was found but didn't need updating. -// Returns REGDB_E_READREGDB if the Chrome Omaha key could not be read. -// Returns REGDB_E_WRITEREGDB if the Chrome Omaha key could not be written. -HRESULT UtilUpdateOmahaConfig(bool add_cf_suffix); - // Returns a string from ChromeFrame's string table by resource. Must be // provided with a valid resource id. std::wstring GetResourceString(int resource_id); |