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

Side by Side Diff: chrome_frame/chrome_frame_helper_util.cc

Issue 7065024: Add a self-destruct mechanism to user-level Chrome Frame when it detects that system-level Chrome... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
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 #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
11 namespace {
9 const wchar_t kGetBrowserMessage[] = L"GetAutomationObject"; 12 const wchar_t kGetBrowserMessage[] = L"GetAutomationObject";
grt (UTC plus 2) 2011/05/26 17:08:58 nit: add a blank line before this (and before the
robertshield 2011/05/27 03:34:59 Done.
10 13
14 const wchar_t kBHORegistrationPathFmt[] =
15 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer"
16 L"\\Browser Helper Objects\\%s";
17 const wchar_t kChromeFrameClientKey[] =
18 L"Software\\Google\\Update\\Clients\\"
19 L"{8BA986DA-5100-405E-AA35-86F34A02ACBF}";
20 const wchar_t kGoogleUpdateVersionValue[] = L"pv";
21 } // namespace
22
11 bool UtilIsWebBrowserWindow(HWND window_to_check) { 23 bool UtilIsWebBrowserWindow(HWND window_to_check) {
12 bool is_browser_window = false; 24 bool is_browser_window = false;
13 25
14 if (!IsWindow(window_to_check)) { 26 if (!IsWindow(window_to_check)) {
15 return is_browser_window; 27 return is_browser_window;
16 } 28 }
17 29
18 static wchar_t* known_ie_window_classes[] = { 30 static wchar_t* known_ie_window_classes[] = {
19 L"IEFrame", 31 L"IEFrame",
20 L"TabWindowClass" 32 L"TabWindowClass"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 DWORD thread_id_to_match, 190 DWORD thread_id_to_match,
179 DWORD process_id_to_match) { 191 DWORD process_id_to_match) {
180 if ((class_name == NULL) && (window_name == NULL)) { 192 if ((class_name == NULL) && (window_name == NULL)) {
181 return NULL; 193 return NULL;
182 } 194 }
183 FindWindowParams params(parent, class_name, window_name, 195 FindWindowParams params(parent, class_name, window_name,
184 thread_id_to_match, process_id_to_match); 196 thread_id_to_match, process_id_to_match);
185 EnumChildWindows(parent, WndEnumProc, reinterpret_cast<LPARAM>(&params)); 197 EnumChildWindows(parent, WndEnumProc, reinterpret_cast<LPARAM>(&params));
186 return params.window_found_; 198 return params.window_found_;
187 } 199 }
200
201 // TODO(robertshield): This is stolen shamelessly from mini_installer.cc.
202 // Refactor this before (more) bad things happen.
203 LONG ReadValue(HKEY key,
204 const wchar_t* value_name,
205 size_t value_size,
206 wchar_t* value) {
207 DWORD type;
208 DWORD byte_length = static_cast<DWORD>(value_size * sizeof(wchar_t));
209 LONG result = ::RegQueryValueEx(key, value_name, NULL, &type,
210 reinterpret_cast<BYTE*>(value),
211 &byte_length);
212 if (result == ERROR_SUCCESS) {
213 if (type != REG_SZ) {
214 result = ERROR_NOT_SUPPORTED;
215 } else if (byte_length == 0) {
216 *value = L'\0';
217 } else if (value[byte_length/sizeof(wchar_t) - 1] != L'\0') {
218 if ((byte_length / sizeof(wchar_t)) < value_size)
219 value[byte_length / sizeof(wchar_t)] = L'\0';
220 else
221 result = ERROR_MORE_DATA;
222 }
223 }
224 return result;
225 }
226
227 bool IsBHOLoadingPolicyRegistered() {
228 wchar_t bho_clsid_as_string[MAX_PATH] = {0};
229 int count = StringFromGUID2(CLSID_ChromeFrameBHO, bho_clsid_as_string,
230 ARRAYSIZE(bho_clsid_as_string));
231
232 bool bho_registered = false;
233 if (count > 0) {
234 wchar_t reg_path_buffer[MAX_PATH] = {0};
235 int path_count = _snwprintf(reg_path_buffer,
236 MAX_PATH - 1,
237 kBHORegistrationPathFmt,
238 bho_clsid_as_string);
239
240 if (path_count > 0) {
241 HKEY reg_handle = NULL;
242 LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
243 reg_path_buffer,
244 0,
245 KEY_QUERY_VALUE,
246 &reg_handle);
247 if (result == ERROR_SUCCESS) {
248 RegCloseKey(reg_handle);
249 bho_registered = true;
250 }
251 }
252 }
253
254 return bho_registered;
255 }
256
257 bool IsSystemLevelChromeFrameInstalled() {
258 bool system_level_installed = false;
259 HKEY reg_handle = NULL;
260 LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
261 kChromeFrameClientKey,
262 0,
263 KEY_QUERY_VALUE,
264 &reg_handle);
265 if (result == ERROR_SUCCESS) {
266 wchar_t version_buffer[MAX_PATH] = {0};
267 result = ReadValue(reg_handle,
268 kGoogleUpdateVersionValue,
269 MAX_PATH,
270 version_buffer);
271 if (result == ERROR_SUCCESS && *version_buffer != L'\0') {
grt (UTC plus 2) 2011/05/26 17:08:58 gak! make that version_buffer[0] != L'\0' since v
robertshield 2011/05/27 03:34:59 Done.
272 system_level_installed = true;
273 }
274 RegCloseKey(reg_handle);
275 }
276
277 return system_level_installed;
278 }
279
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698