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

Side by Side Diff: chrome_frame/chrome_tab.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, 7 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 | « chrome_frame/chrome_frame_launcher.gyp ('k') | chrome_frame/registry_watcher.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // chrome_tab.cc : Implementation of DLL Exports. 5 // chrome_tab.cc : Implementation of DLL Exports.
6 6
7 // Include without path to make GYP build see it. 7 // Include without path to make GYP build see it.
8 #include "chrome_tab.h" // NOLINT 8 #include "chrome_tab.h" // NOLINT
9 9
10 #include <atlsecurity.h> 10 #include <atlsecurity.h>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 const wchar_t kProtocolHandlers[] = 64 const wchar_t kProtocolHandlers[] =
65 L"Software\\Classes\\Protocols\\Handler"; 65 L"Software\\Classes\\Protocols\\Handler";
66 66
67 const wchar_t kRunOnce[] = 67 const wchar_t kRunOnce[] =
68 L"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce"; 68 L"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
69 69
70 const wchar_t kRunKeyName[] = L"ChromeFrameHelper"; 70 const wchar_t kRunKeyName[] = L"ChromeFrameHelper";
71 71
72 const wchar_t kChromeFrameHelperExe[] = L"chrome_frame_helper.exe"; 72 const wchar_t kChromeFrameHelperExe[] = L"chrome_frame_helper.exe";
73 const wchar_t kChromeFrameHelperStartupArg[] = L"--startup";
73 74
74 // Window class and window names. 75 // Window class and window names.
75 // TODO(robertshield): These and other constants need to be refactored into 76 // TODO(robertshield): These and other constants need to be refactored into
76 // a common chrome_frame_constants.h|cc and built into a separate lib 77 // a common chrome_frame_constants.h|cc and built into a separate lib
77 // (either chrome_frame_utils or make another one). 78 // (either chrome_frame_utils or make another one).
78 const wchar_t kChromeFrameHelperWindowClassName[] = 79 const wchar_t kChromeFrameHelperWindowClassName[] =
79 L"ChromeFrameHelperWindowClass"; 80 L"ChromeFrameHelperWindowClass";
80 const wchar_t kChromeFrameHelperWindowName[] = 81 const wchar_t kChromeFrameHelperWindowName[] =
81 L"ChromeFrameHelperWindowName"; 82 L"ChromeFrameHelperWindowName";
82 83
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 HRESULT result = E_FAIL; 308 HRESULT result = E_FAIL;
308 309
309 std::wstring channel_name; 310 std::wstring channel_name;
310 if (base::win::GetVersion() < base::win::VERSION_VISTA && 311 if (base::win::GetVersion() < base::win::VERSION_VISTA &&
311 GoogleUpdateSettings::GetChromeChannelAndModifiers(true, &channel_name)) { 312 GoogleUpdateSettings::GetChromeChannelAndModifiers(true, &channel_name)) {
312 std::transform(channel_name.begin(), channel_name.end(), 313 std::transform(channel_name.begin(), channel_name.end(),
313 channel_name.begin(), tolower); 314 channel_name.begin(), tolower);
314 // Use this only for the dev channel and CEEE channels. 315 // Use this only for the dev channel and CEEE channels.
315 if (channel_name.find(L"dev") != std::wstring::npos || 316 if (channel_name.find(L"dev") != std::wstring::npos ||
316 channel_name.find(L"ceee") != std::wstring::npos) { 317 channel_name.find(L"ceee") != std::wstring::npos) {
317
318 HKEY hive = HKEY_CURRENT_USER; 318 HKEY hive = HKEY_CURRENT_USER;
319 if (IsSystemProcess()) { 319 if (IsSystemProcess()) {
320 // For system installs, our updates will be running as SYSTEM which 320 // For system installs, our updates will be running as SYSTEM which
321 // makes writing to a RunOnce key under HKCU not so terribly useful. 321 // makes writing to a RunOnce key under HKCU not so terribly useful.
322 hive = HKEY_LOCAL_MACHINE; 322 hive = HKEY_LOCAL_MACHINE;
323 } 323 }
324 324
325 RegKey run_once; 325 RegKey run_once;
326 LONG ret = run_once.Create(hive, kRunOnce, KEY_READ | KEY_WRITE); 326 LONG ret = run_once.Create(hive, kRunOnce, KEY_READ | KEY_WRITE);
327 if (ret == ERROR_SUCCESS) { 327 if (ret == ERROR_SUCCESS) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 368 }
369 } else { 369 } else {
370 NOTREACHED(); 370 NOTREACHED();
371 } 371 }
372 372
373 // Find window handle of existing instance. 373 // Find window handle of existing instance.
374 HWND old_window = FindWindow(kChromeFrameHelperWindowClassName, 374 HWND old_window = FindWindow(kChromeFrameHelperWindowClassName,
375 kChromeFrameHelperWindowName); 375 kChromeFrameHelperWindowName);
376 376
377 if (file_util::PathExists(helper_path)) { 377 if (file_util::PathExists(helper_path)) {
378 std::wstring helper_path_cmd(L"\"");
379 helper_path_cmd += helper_path.value();
380 helper_path_cmd += L"\" ";
381 helper_path_cmd += kChromeFrameHelperStartupArg;
382
378 // Add new run-at-startup entry. 383 // Add new run-at-startup entry.
379 base::win::AddCommandToAutoRun(HKEY_CURRENT_USER, kRunKeyName, 384 base::win::AddCommandToAutoRun(HKEY_CURRENT_USER, kRunKeyName,
380 helper_path.value()); 385 helper_path_cmd);
381 386
382 // Start new instance. 387 // Start new instance.
383 bool launched = base::LaunchApp(helper_path.value(), false, true, NULL); 388 bool launched = base::LaunchApp(helper_path.value(), false, true, NULL);
384 if (!launched) { 389 if (!launched) {
385 NOTREACHED(); 390 NOTREACHED();
386 LOG(ERROR) << "Could not launch helper process."; 391 LOG(ERROR) << "Could not launch helper process.";
387 } 392 }
388 393
389 // Kill old instance using window handle. 394 // Kill old instance using window handle.
390 if (IsWindow(old_window)) { 395 if (IsWindow(old_window)) {
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 sd.GetDacl(&new_dacl); 845 sd.GetDacl(&new_dacl);
841 new_dacl.AddAllowedAce(token_.GetUser(), GENERIC_WRITE | GENERIC_READ); 846 new_dacl.AddAllowedAce(token_.GetUser(), GENERIC_WRITE | GENERIC_READ);
842 if (AtlSetDacl(object_name.c_str(), SE_REGISTRY_KEY, new_dacl)) { 847 if (AtlSetDacl(object_name.c_str(), SE_REGISTRY_KEY, new_dacl)) {
843 result = SetOrDeleteMimeHandlerKey(enable, HKEY_LOCAL_MACHINE); 848 result = SetOrDeleteMimeHandlerKey(enable, HKEY_LOCAL_MACHINE);
844 } 849 }
845 } 850 }
846 851
847 backup.RestoreSecurity(object_name.c_str()); 852 backup.RestoreSecurity(object_name.c_str());
848 return result; 853 return result;
849 } 854 }
OLDNEW
« no previous file with comments | « chrome_frame/chrome_frame_launcher.gyp ('k') | chrome_frame/registry_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698