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

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

Issue 6538059: Revert 75405 - Register Application Restart with Windows Restart Manager on b... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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,
162 RESTART_NO_CRASH | RESTART_NO_HANG | RESTART_NO_PATCH);
163 DCHECK(SUCCEEDED(hr)) << "RegisterApplicationRestart failed.";
164 return SUCCEEDED(hr);
165 }
166
167 // This method handles the --hide-icons and --show-icons command line options 149 // This method handles the --hide-icons and --show-icons command line options
168 // for chrome that get triggered by Windows from registry entries 150 // for chrome that get triggered by Windows from registry entries
169 // HideIconsCommand & ShowIconsCommand. Chrome doesn't support hide icons 151 // HideIconsCommand & ShowIconsCommand. Chrome doesn't support hide icons
170 // functionality so we just ask the users if they want to uninstall Chrome. 152 // functionality so we just ask the users if they want to uninstall Chrome.
171 int HandleIconsCommands(const CommandLine& parsed_command_line) { 153 int HandleIconsCommands(const CommandLine &parsed_command_line) {
172 if (parsed_command_line.HasSwitch(switches::kHideIcons)) { 154 if (parsed_command_line.HasSwitch(switches::kHideIcons)) {
173 string16 cp_applet; 155 string16 cp_applet;
174 base::win::Version version = base::win::GetVersion(); 156 base::win::Version version = base::win::GetVersion();
175 if (version >= base::win::VERSION_VISTA) { 157 if (version >= base::win::VERSION_VISTA) {
176 cp_applet.assign(L"Programs and Features"); // Windows Vista and later. 158 cp_applet.assign(L"Programs and Features"); // Windows Vista and later.
177 } else if (version >= base::win::VERSION_XP) { 159 } else if (version >= base::win::VERSION_XP) {
178 cp_applet.assign(L"Add/Remove Programs"); // Windows XP. 160 cp_applet.assign(L"Add/Remove Programs"); // Windows XP.
179 } else { 161 } else {
180 return ResultCodes::UNSUPPORTED_PARAM; // Not supported 162 return ResultCodes::UNSUPPORTED_PARAM; // Not supported
181 } 163 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 base::EnsureNSPRInit(); 245 base::EnsureNSPRInit();
264 } 246 }
265 } 247 }
266 }; 248 };
267 249
268 // static 250 // static
269 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( 251 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts(
270 const MainFunctionParams& parameters) { 252 const MainFunctionParams& parameters) {
271 return new BrowserMainPartsWin(parameters); 253 return new BrowserMainPartsWin(parameters);
272 } 254 }
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