Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
|
grt (UTC plus 2)
2011/05/25 16:10:07
2011
robertshield
2011/05/26 15:14:28
This is because of the beeping UPS, isn't it?
grt (UTC plus 2)
2011/05/26 17:08:58
Are you making a statement by not fixing this one?
robertshield
2011/05/27 03:34:59
Fixed.
| |
| 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 #include "chrome_frame/chrome_frame_helper_util.h" | 5 #include "chrome_frame/chrome_frame_helper_util.h" |
| 6 #include "chrome_tab.h" // NOLINT | |
| 6 | 7 |
| 7 #include <shlwapi.h> | 8 #include <shlwapi.h> |
| 9 #include <stdio.h> | |
| 8 | 10 |
| 9 const wchar_t kGetBrowserMessage[] = L"GetAutomationObject"; | 11 const wchar_t kGetBrowserMessage[] = L"GetAutomationObject"; |
|
grt (UTC plus 2)
2011/05/25 16:10:07
nit: wrap as much of these as reasonable in namesp
robertshield
2011/05/26 15:14:28
Done.
| |
| 10 | 12 |
| 13 const wchar_t kSystemLevelRegPath[] = L"Software\\Classes\\CLSID\\%s"; | |
|
grt (UTC plus 2)
2011/05/25 16:10:07
Consider putting "Format" or "Fmt" or something in
robertshield
2011/05/26 15:14:28
Done.
| |
| 14 const wchar_t kChromeFrameClientKey[] = | |
|
grt (UTC plus 2)
2011/05/25 16:10:07
Same comment about trailing separator.
robertshield
2011/05/26 15:14:28
Done.
| |
| 15 L"Software\\Google\\Update\\Clients\\" | |
| 16 L"{8BA986DA-5100-405E-AA35-86F34A02ACBF}\\"; | |
| 17 const wchar_t kChromeFrameVersionValue[] = L"pv"; | |
|
grt (UTC plus 2)
2011/05/25 16:10:07
Hmm. This is a Google Update value, not a Chrome
robertshield
2011/05/26 15:14:28
Done.
| |
| 18 | |
| 11 bool UtilIsWebBrowserWindow(HWND window_to_check) { | 19 bool UtilIsWebBrowserWindow(HWND window_to_check) { |
| 12 bool is_browser_window = false; | 20 bool is_browser_window = false; |
| 13 | 21 |
| 14 if (!IsWindow(window_to_check)) { | 22 if (!IsWindow(window_to_check)) { |
| 15 return is_browser_window; | 23 return is_browser_window; |
| 16 } | 24 } |
| 17 | 25 |
| 18 static wchar_t* known_ie_window_classes[] = { | 26 static wchar_t* known_ie_window_classes[] = { |
| 19 L"IEFrame", | 27 L"IEFrame", |
| 20 L"TabWindowClass" | 28 L"TabWindowClass" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 DWORD thread_id_to_match, | 186 DWORD thread_id_to_match, |
| 179 DWORD process_id_to_match) { | 187 DWORD process_id_to_match) { |
| 180 if ((class_name == NULL) && (window_name == NULL)) { | 188 if ((class_name == NULL) && (window_name == NULL)) { |
| 181 return NULL; | 189 return NULL; |
| 182 } | 190 } |
| 183 FindWindowParams params(parent, class_name, window_name, | 191 FindWindowParams params(parent, class_name, window_name, |
| 184 thread_id_to_match, process_id_to_match); | 192 thread_id_to_match, process_id_to_match); |
| 185 EnumChildWindows(parent, WndEnumProc, reinterpret_cast<LPARAM>(¶ms)); | 193 EnumChildWindows(parent, WndEnumProc, reinterpret_cast<LPARAM>(¶ms)); |
| 186 return params.window_found_; | 194 return params.window_found_; |
| 187 } | 195 } |
| 196 | |
| 197 | |
|
grt (UTC plus 2)
2011/05/25 16:10:07
remove blank line
robertshield
2011/05/26 15:14:28
Done.
| |
| 198 // TODO(robertshield): This is stolen shamelessly from mini_installer.cc. | |
| 199 // Refactor this before (more) bad things happen. | |
| 200 LONG ReadValue(HKEY key, | |
| 201 const wchar_t* value_name, | |
| 202 size_t value_size, | |
| 203 wchar_t* value) { | |
| 204 DWORD type; | |
| 205 DWORD byte_length = static_cast<DWORD>(value_size * sizeof(wchar_t)); | |
| 206 LONG result = ::RegQueryValueEx(key, value_name, NULL, &type, | |
| 207 reinterpret_cast<BYTE*>(value), | |
| 208 &byte_length); | |
| 209 if (result == ERROR_SUCCESS) { | |
| 210 if (type != REG_SZ) { | |
| 211 result = ERROR_NOT_SUPPORTED; | |
| 212 } else if (byte_length == 0) { | |
| 213 *value = L'\0'; | |
| 214 } else if (value[byte_length/sizeof(wchar_t) - 1] != L'\0') { | |
| 215 if ((byte_length / sizeof(wchar_t)) < value_size) | |
| 216 value[byte_length / sizeof(wchar_t)] = L'\0'; | |
| 217 else | |
| 218 result = ERROR_MORE_DATA; | |
| 219 } | |
| 220 } | |
| 221 return result; | |
| 222 } | |
| 223 | |
| 224 bool IsSystemLevelChromeFrameInstalled() { | |
| 225 wchar_t bho_clsid_as_string[MAX_PATH] = {0}; | |
| 226 int count = StringFromGUID2(CLSID_ChromeFrameBHO, bho_clsid_as_string, | |
| 227 ARRAYSIZE(bho_clsid_as_string)); | |
| 228 | |
| 229 bool bho_registered = false; | |
| 230 if (count > 0) { | |
| 231 wchar_t reg_path_buffer[MAX_PATH] = {0}; | |
| 232 int path_count = _snwprintf(reg_path_buffer, | |
| 233 MAX_PATH - 1, | |
| 234 kSystemLevelRegPath, | |
| 235 bho_clsid_as_string); | |
| 236 | |
| 237 if (path_count > 0) { | |
| 238 HKEY reg_handle = NULL; | |
| 239 LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, | |
| 240 reg_path_buffer, | |
| 241 0, | |
| 242 KEY_READ, | |
|
grt (UTC plus 2)
2011/05/25 16:10:07
KEY_READ -> KEY_QUERY_VALUE
robertshield
2011/05/26 15:14:28
Done.
| |
| 243 ®_handle); | |
| 244 if (result == ERROR_SUCCESS) { | |
| 245 RegCloseKey(reg_handle); | |
| 246 bho_registered = true; | |
| 247 } | |
| 248 } | |
| 249 } | |
| 250 | |
| 251 // If our bho is registered, also check that we appear to have a valid | |
|
grt (UTC plus 2)
2011/05/25 16:10:07
Under what circumstances would the BHO be register
robertshield
2011/05/26 15:14:28
As discussed, this function is now split in two pa
| |
| 252 // system-level installation. | |
| 253 bool system_level_installed = false; | |
| 254 if (bho_registered) { | |
| 255 HKEY reg_handle = NULL; | |
| 256 LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, | |
| 257 kChromeFrameClientKey, | |
| 258 0, | |
| 259 KEY_QUERY_VALUE, | |
| 260 ®_handle); | |
| 261 if (result == ERROR_SUCCESS) { | |
| 262 wchar_t version_buffer[MAX_PATH] = {0}; | |
|
grt (UTC plus 2)
2011/05/25 16:10:07
Consider giving the bho_clsid_as_string buffer a m
robertshield
2011/05/26 15:14:28
I split the function in twine to be more specific,
| |
| 263 result = ReadValue(reg_handle, | |
| 264 kChromeFrameVersionValue, | |
| 265 MAX_PATH, | |
| 266 version_buffer); | |
| 267 if (result == ERROR_SUCCESS && wcslen(version_buffer) > 0) { | |
|
grt (UTC plus 2)
2011/05/25 16:10:07
wcslen(version_buffer) > 0 -> *version_buffer !=
robertshield
2011/05/26 15:14:28
Neato.
| |
| 268 system_level_installed = true; | |
| 269 } | |
|
grt (UTC plus 2)
2011/05/25 16:10:07
add RegCloseKey(reg_handle); after this line
robertshield
2011/05/26 15:14:28
Done.
| |
| 270 } | |
| 271 } | |
| 272 | |
| 273 return system_level_installed; | |
| 274 } | |
| OLD | NEW |