diff options
author | amit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-19 07:28:46 +0000 |
---|---|---|
committer | amit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-19 07:28:46 +0000 |
commit | e06f4d5c6bd7bad162c45784e39cd0114635eb42 (patch) | |
tree | e53d6b4188af6e49393babc92a797ed5734a1026 /chrome_frame/chrome_tab.cc | |
parent | 2b107a348f2b27934fe38680ec8010d743f61765 (diff) | |
download | chromium_src-e06f4d5c6bd7bad162c45784e39cd0114635eb42.zip chromium_src-e06f4d5c6bd7bad162c45784e39cd0114635eb42.tar.gz chromium_src-e06f4d5c6bd7bad162c45784e39cd0114635eb42.tar.bz2 |
Regkey functions return error code instead of bool
Change the Regkey helper to consistently use and return LONG
instead of bool. Fix RegKey usage all over the code base and
get rid of workarounds due to lack of return value.
Reviewers:
brettw: everything (skip parts for other reviewers if you wish)
robertshield,grt: chrome_frame, installer
siggi: ceee
BUG=none
TEST=covered by existing tests
Review URL: http://codereview.chromium.org/6090006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71768 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_tab.cc')
-rw-r--r-- | chrome_frame/chrome_tab.cc | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index 280e0a4..bc4a7d1 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -324,16 +324,16 @@ HRESULT SetupRunOnce() { } RegKey run_once; - if (run_once.Create(hive, kRunOnce, KEY_READ | KEY_WRITE)) { + LONG ret = run_once.Create(hive, kRunOnce, KEY_READ | KEY_WRITE); + if (ret == ERROR_SUCCESS) { CommandLine run_once_cmd(chrome_launcher::GetChromeExecutablePath()); run_once_cmd.AppendSwitchASCII(switches::kAutomationClientChannelID, "0"); run_once_cmd.AppendSwitch(switches::kChromeFrame); - if (run_once.WriteValue(L"A", - run_once_cmd.command_line_string().c_str())) { - result = S_OK; - } + ret = run_once.WriteValue(L"A", + run_once_cmd.command_line_string().c_str()); } + result = HRESULT_FROM_WIN32(ret); } else { result = S_FALSE; } @@ -434,7 +434,8 @@ HRESULT SetChromeFrameUA(bool is_system, const wchar_t* value) { HKEY parent_hive = is_system ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; RegKey ua_key; - if (ua_key.Create(parent_hive, kPostPlatformUAKey, KEY_READ | KEY_WRITE)) { + if (ua_key.Create(parent_hive, kPostPlatformUAKey, + KEY_READ | KEY_WRITE) == ERROR_SUCCESS) { // Make sure that we unregister ChromeFrame UA strings registered previously wchar_t value_name[MAX_PATH + 1] = {}; wchar_t value_data[MAX_PATH + 1] = {}; @@ -654,7 +655,7 @@ class SecurityDescBackup { RegKey backup_key(HKEY_LOCAL_MACHINE, backup_key_name_.c_str(), KEY_READ | KEY_WRITE); if (backup_key.Valid()) { - return backup_key.WriteValue(NULL, str.GetString()); + return backup_key.WriteValue(NULL, str.GetString()) == ERROR_SUCCESS; } return false; @@ -696,15 +697,15 @@ class SecurityDescBackup { DWORD len = 0; DWORD reg_type = REG_NONE; - if (!backup_key.ReadValue(NULL, NULL, &len, ®_type)) + if (backup_key.ReadValue(NULL, NULL, &len, ®_type) != ERROR_SUCCESS) return false; if (reg_type != REG_SZ) return false; size_t wchar_count = 1 + len / sizeof(wchar_t); - if (!backup_key.ReadValue(NULL, WriteInto(sddl, wchar_count), &len, - ®_type)) { + if (backup_key.ReadValue(NULL, WriteInto(sddl, wchar_count), &len, + ®_type) != ERROR_SUCCESS) { return false; } @@ -760,16 +761,17 @@ static bool SetOrDeleteMimeHandlerKey(bool set, HKEY root_key) { if (!key.Valid()) return false; - bool result; + LONG result1 = ERROR_SUCCESS; + LONG result2 = ERROR_SUCCESS; if (set) { - result = key.WriteValue(L"ChromeTab.ChromeActiveDocument", 1); - result = key.WriteValue(L"ChromeTab.ChromeActiveDocument.1", 1) && result; + result1 = key.WriteValue(L"ChromeTab.ChromeActiveDocument", 1); + result2 = key.WriteValue(L"ChromeTab.ChromeActiveDocument.1", 1); } else { - result = key.DeleteValue(L"ChromeTab.ChromeActiveDocument"); - result = key.DeleteValue(L"ChromeTab.ChromeActiveDocument.1") && result; + result1 = key.DeleteValue(L"ChromeTab.ChromeActiveDocument"); + result2 = key.DeleteValue(L"ChromeTab.ChromeActiveDocument.1"); } - return result; + return (result2 == ERROR_SUCCESS) && (result2 == ERROR_SUCCESS); } bool RegisterSecuredMimeHandler(bool enable, bool is_system) { |