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

Side by Side Diff: ceee/ie/common/ie_util.cc

Issue 6090006: Regkey functions return error code instead of bool (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ceee/ie/common/ceee_util.cc ('k') | ceee/ie/common/ie_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Utility functions to interact with IE. 5 // Utility functions to interact with IE.
6 6
7 #include "ceee/ie/common/ie_util.h" 7 #include "ceee/ie/common/ie_util.h"
8 8
9 #include <atlcomcli.h> 9 #include <atlcomcli.h>
10 #include <exdisp.h> // IWebBrowser2 10 #include <exdisp.h> // IWebBrowser2
(...skipping 25 matching lines...) Expand all
36 return enum_punk->QueryInterface(IID_IEnumVARIANT, 36 return enum_punk->QueryInterface(IID_IEnumVARIANT,
37 reinterpret_cast<void**>(enum_windows)); 37 reinterpret_cast<void**>(enum_windows));
38 } 38 }
39 39
40 bool GetIeVersionString(std::wstring* version) { 40 bool GetIeVersionString(std::wstring* version) {
41 DCHECK(version != NULL); 41 DCHECK(version != NULL);
42 if (version == NULL) 42 if (version == NULL)
43 return false; 43 return false;
44 base::win::RegKey key(HKEY_LOCAL_MACHINE, kIeVersionKey, KEY_READ); 44 base::win::RegKey key(HKEY_LOCAL_MACHINE, kIeVersionKey, KEY_READ);
45 DCHECK(key.ValueExists(kIeVersionValue)); 45 DCHECK(key.ValueExists(kIeVersionValue));
46 return key.ReadValue(kIeVersionValue, version); 46 return (key.ReadValue(kIeVersionValue, version) == ERROR_SUCCESS);
47 } 47 }
48 48
49 } // namespace 49 } // namespace
50 50
51 namespace ie_util { 51 namespace ie_util {
52 52
53 HRESULT GetWebBrowserForTopLevelIeHwnd( 53 HRESULT GetWebBrowserForTopLevelIeHwnd(
54 HWND window, IWebBrowser2* not_him, IWebBrowser2** browser) { 54 HWND window, IWebBrowser2* not_him, IWebBrowser2** browser) {
55 DCHECK(browser != NULL); 55 DCHECK(browser != NULL);
56 CComPtr<IEnumVARIANT> enum_windows; 56 CComPtr<IEnumVARIANT> enum_windows;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 key_name += addon_id_str; 157 key_name += addon_id_str;
158 key_name += L"\\iexplore"; 158 key_name += L"\\iexplore";
159 159
160 base::win::RegKey stats_key(HKEY_CURRENT_USER, key_name.c_str(), KEY_READ); 160 base::win::RegKey stats_key(HKEY_CURRENT_USER, key_name.c_str(), KEY_READ);
161 if (!stats_key.Valid()) { 161 if (!stats_key.Valid()) {
162 LOG(ERROR) << "Missing stats key: " << key_name; 162 LOG(ERROR) << "Missing stats key: " << key_name;
163 return kInvalidTime; 163 return kInvalidTime;
164 } 164 }
165 165
166 DWORD load_time = 0; 166 DWORD load_time = 0;
167 LONG result = ERROR_SUCCESS;
167 if (GetIeVersion() < IEVERSION_IE9) { 168 if (GetIeVersion() < IEVERSION_IE9) {
168 if (!stats_key.ReadValueDW(time_prefix.c_str(), &load_time)) { 169 result = stats_key.ReadValueDW(time_prefix.c_str(), &load_time);
169 VLOG(1) << "Can't read time: " << time_prefix; 170 if (result != ERROR_SUCCESS) {
171 VLOG(1) << "Can't read time: " << time_prefix << " error: "
172 << com::LogWe(result);
170 return kInvalidTime; 173 return kInvalidTime;
171 } 174 }
172 } else { 175 } else {
173 std::wstring value_name(time_prefix); 176 std::wstring value_name(time_prefix);
174 value_name += L"Array"; 177 value_name += L"Array";
175 DWORD count = 0; 178 DWORD count = 0;
176 int32 values[100]; 179 int32 values[100];
177 DWORD data_size = sizeof(values); 180 DWORD data_size = sizeof(values);
178 DWORD data_type = REG_NONE; 181 DWORD data_type = REG_NONE;
179 182
180 if (!stats_key.ReadValue(value_name.c_str(), &values, &data_size, 183 result = stats_key.ReadValue(value_name.c_str(), &values, &data_size,
181 &data_type)) { 184 &data_type);
182 VLOG(1) << "Can't read time: " << value_name; 185 if (result != ERROR_SUCCESS) {
186 VLOG(1) << "Can't read time: " << value_name << " error: "
187 << com::LogWe(result);
183 return kInvalidTime; 188 return kInvalidTime;
184 } 189 }
185 190
186 if (data_type != REG_BINARY) { 191 if (data_type != REG_BINARY) {
187 LOG(ERROR) << "Unexpected data type:" << data_type; 192 LOG(ERROR) << "Unexpected data type:" << data_type;
188 return kInvalidTime; 193 return kInvalidTime;
189 } 194 }
190 195
191 if (data_size % sizeof(values[0]) != 0) { 196 if (data_size % sizeof(values[0]) != 0) {
192 LOG(ERROR) << "Unexpected data length:" << data_size; 197 LOG(ERROR) << "Unexpected data length:" << data_size;
(...skipping 22 matching lines...) Expand all
215 220
216 if (load_time < 0) { 221 if (load_time < 0) {
217 LOG(ERROR) << "Invalid time:" << load_time; 222 LOG(ERROR) << "Invalid time:" << load_time;
218 return kInvalidTime; 223 return kInvalidTime;
219 } 224 }
220 225
221 return load_time; 226 return load_time;
222 } 227 }
223 228
224 } // namespace ie_util 229 } // namespace ie_util
OLDNEW
« no previous file with comments | « ceee/ie/common/ceee_util.cc ('k') | ceee/ie/common/ie_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698