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

Side by Side Diff: chrome/browser/browser_main_win.cc

Issue 6462024: Register Application Restart with Windows Restart Manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 9 years, 10 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/browser/browser_main_win.h ('k') | no next file » | 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 #include "chrome/browser/browser_main.h" 5 #include "chrome/browser/browser_main.h"
6 #include "chrome/browser/browser_main_win.h" 6 #include "chrome/browser/browser_main_win.h"
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 ShellUtil::CURRENT_USER)) 107 ShellUtil::CURRENT_USER))
108 VLOG(1) << "Failed to delete quick launch shortcut."; 108 VLOG(1) << "Failed to delete quick launch shortcut.";
109 } 109 }
110 return ret; 110 return ret;
111 } 111 }
112 112
113 // Prepares the localized strings that are going to be displayed to 113 // Prepares the localized strings that are going to be displayed to
114 // the user if the browser process dies. These strings are stored in the 114 // the user if the browser process dies. These strings are stored in the
115 // environment block so they are accessible in the early stages of the 115 // environment block so they are accessible in the early stages of the
116 // chrome executable's lifetime. 116 // chrome executable's lifetime.
117 void PrepareRestartOnCrashEnviroment(const CommandLine &parsed_command_line) { 117 void PrepareRestartOnCrashEnviroment(const CommandLine& parsed_command_line) {
118 // Clear this var so child processes don't show the dialog by default. 118 // Clear this var so child processes don't show the dialog by default.
119 scoped_ptr<base::Environment> env(base::Environment::Create()); 119 scoped_ptr<base::Environment> env(base::Environment::Create());
120 env->UnSetVar(env_vars::kShowRestart); 120 env->UnSetVar(env_vars::kShowRestart);
121 121
122 // For non-interactive tests we don't restart on crash. 122 // For non-interactive tests we don't restart on crash.
123 if (env->HasVar(env_vars::kHeadless)) 123 if (env->HasVar(env_vars::kHeadless))
124 return; 124 return;
125 125
126 // If the known command-line test options are used we don't create the 126 // If the known command-line test options are used we don't create the
127 // environment block which means we don't get the restart dialog. 127 // environment block which means we don't get the restart dialog.
(...skipping 11 matching lines...) Expand all
139 l10n_util::GetStringUTF16(IDS_CRASH_RECOVERY_CONTENT)); 139 l10n_util::GetStringUTF16(IDS_CRASH_RECOVERY_CONTENT));
140 base::i18n::AdjustStringForLocaleDirection(&adjusted_string); 140 base::i18n::AdjustStringForLocaleDirection(&adjusted_string);
141 dlg_strings.append(adjusted_string); 141 dlg_strings.append(adjusted_string);
142 dlg_strings.push_back('|'); 142 dlg_strings.push_back('|');
143 dlg_strings.append(ASCIIToUTF16( 143 dlg_strings.append(ASCIIToUTF16(
144 base::i18n::IsRTL() ? env_vars::kRtlLocale : env_vars::kLtrLocale)); 144 base::i18n::IsRTL() ? env_vars::kRtlLocale : env_vars::kLtrLocale));
145 145
146 env->SetVar(env_vars::kRestartInfo, UTF16ToUTF8(dlg_strings)); 146 env->SetVar(env_vars::kRestartInfo, UTF16ToUTF8(dlg_strings));
147 } 147 }
148 148
149 bool RegisterApplicationRestart(const CommandLine& parsed_command_line) {
150 // The Windows Restart Manager expects a string of command line flags only,
151 // without the program.
152 CommandLine command_line(CommandLine::NO_PROGRAM);
153 command_line.AppendSwitches(parsed_command_line);
154 command_line.AppendArgs(parsed_command_line);
155 // Ensure restore last session is set.
156 if (!command_line.HasSwitch(switches::kRestoreLastSession))
157 command_line.AppendSwitch(switches::kRestoreLastSession);
158 const wchar_t *command_string = command_line.command_line_string().c_str();
159 // Restart Chrome if the computer is restarted as the result of an update.
160 // This could be extended to handle crashes, hangs, and patches.
161 HRESULT hr = ::RegisterApplicationRestart(command_string,
Ben Goodger (Google) 2011/02/17 04:12:29 One question: does this result in blocking I/O? (e
Finnur 2011/02/17 10:30:54 FileMon shows no File/Registry access while execut
msw 2011/02/17 12:18:29 Short answer: RegisterApplicationRestart() doesn't
162 RESTART_NO_CRASH | RESTART_NO_HANG | RESTART_NO_PATCH);
163 DCHECK(SUCCEEDED(hr)) << "RegisterApplicationRestart failed.";
164 return SUCCEEDED(hr);
165 }
166
149 // This method handles the --hide-icons and --show-icons command line options 167 // This method handles the --hide-icons and --show-icons command line options
150 // for chrome that get triggered by Windows from registry entries 168 // for chrome that get triggered by Windows from registry entries
151 // HideIconsCommand & ShowIconsCommand. Chrome doesn't support hide icons 169 // HideIconsCommand & ShowIconsCommand. Chrome doesn't support hide icons
152 // functionality so we just ask the users if they want to uninstall Chrome. 170 // functionality so we just ask the users if they want to uninstall Chrome.
153 int HandleIconsCommands(const CommandLine &parsed_command_line) { 171 int HandleIconsCommands(const CommandLine& parsed_command_line) {
154 if (parsed_command_line.HasSwitch(switches::kHideIcons)) { 172 if (parsed_command_line.HasSwitch(switches::kHideIcons)) {
155 string16 cp_applet; 173 string16 cp_applet;
156 base::win::Version version = base::win::GetVersion(); 174 base::win::Version version = base::win::GetVersion();
157 if (version >= base::win::VERSION_VISTA) { 175 if (version >= base::win::VERSION_VISTA) {
158 cp_applet.assign(L"Programs and Features"); // Windows Vista and later. 176 cp_applet.assign(L"Programs and Features"); // Windows Vista and later.
159 } else if (version >= base::win::VERSION_XP) { 177 } else if (version >= base::win::VERSION_XP) {
160 cp_applet.assign(L"Add/Remove Programs"); // Windows XP. 178 cp_applet.assign(L"Add/Remove Programs"); // Windows XP.
161 } else { 179 } else {
162 return ResultCodes::UNSUPPORTED_PARAM; // Not supported 180 return ResultCodes::UNSUPPORTED_PARAM; // Not supported
163 } 181 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 base::EnsureNSPRInit(); 263 base::EnsureNSPRInit();
246 } 264 }
247 } 265 }
248 }; 266 };
249 267
250 // static 268 // static
251 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( 269 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts(
252 const MainFunctionParams& parameters) { 270 const MainFunctionParams& parameters) {
253 return new BrowserMainPartsWin(parameters); 271 return new BrowserMainPartsWin(parameters);
254 } 272 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_main_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698