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

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

Issue 3076042: Use Environment::SetVar in more places. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: rebased to ToT Created 10 years, 4 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
« no previous file with comments | « chrome/app/client_util.cc ('k') | chrome/browser/first_run/first_run_win.cc » ('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) 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/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
11 #include <algorithm> 11 #include <algorithm>
12 12
13 #include "app/l10n_util.h" 13 #include "app/l10n_util.h"
14 #include "app/win_util.h" 14 #include "app/win_util.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/environment.h"
16 #include "base/i18n/rtl.h" 17 #include "base/i18n/rtl.h"
17 #include "base/nss_util.h" 18 #include "base/nss_util.h"
18 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/scoped_ptr.h"
19 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
20 #include "base/win_util.h" 22 #include "base/win_util.h"
21 #include "chrome/browser/browser_list.h" 23 #include "chrome/browser/browser_list.h"
22 #include "chrome/browser/first_run/first_run.h" 24 #include "chrome/browser/first_run/first_run.h"
23 #include "chrome/browser/metrics/metrics_service.h" 25 #include "chrome/browser/metrics/metrics_service.h"
24 #include "chrome/browser/views/uninstall_view.h" 26 #include "chrome/browser/views/uninstall_view.h"
25 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/env_vars.h" 28 #include "chrome/common/env_vars.h"
27 #include "chrome/common/result_codes.h" 29 #include "chrome/common/result_codes.h"
28 #include "chrome/installer/util/helper.h" 30 #include "chrome/installer/util/helper.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 104 }
103 return ret; 105 return ret;
104 } 106 }
105 107
106 // Prepares the localized strings that are going to be displayed to 108 // Prepares the localized strings that are going to be displayed to
107 // the user if the browser process dies. These strings are stored in the 109 // the user if the browser process dies. These strings are stored in the
108 // environment block so they are accessible in the early stages of the 110 // environment block so they are accessible in the early stages of the
109 // chrome executable's lifetime. 111 // chrome executable's lifetime.
110 void PrepareRestartOnCrashEnviroment(const CommandLine &parsed_command_line) { 112 void PrepareRestartOnCrashEnviroment(const CommandLine &parsed_command_line) {
111 // Clear this var so child processes don't show the dialog by default. 113 // Clear this var so child processes don't show the dialog by default.
112 ::SetEnvironmentVariableW(ASCIIToWide(env_vars::kShowRestart).c_str(), NULL); 114 scoped_ptr<base::Environment> env(base::Environment::Create());
115 env->UnSetVar(env_vars::kShowRestart);
113 116
114 // For non-interactive tests we don't restart on crash. 117 // For non-interactive tests we don't restart on crash.
115 if (::GetEnvironmentVariableW(ASCIIToWide(env_vars::kHeadless).c_str(), 118 if (env->HasVar(env_vars::kHeadless))
116 NULL, 0)) {
117 return; 119 return;
118 }
119 120
120 // If the known command-line test options are used we don't create the 121 // If the known command-line test options are used we don't create the
121 // environment block which means we don't get the restart dialog. 122 // environment block which means we don't get the restart dialog.
122 if (parsed_command_line.HasSwitch(switches::kBrowserCrashTest) || 123 if (parsed_command_line.HasSwitch(switches::kBrowserCrashTest) ||
123 parsed_command_line.HasSwitch(switches::kBrowserAssertTest) || 124 parsed_command_line.HasSwitch(switches::kBrowserAssertTest) ||
124 parsed_command_line.HasSwitch(switches::kNoErrorDialogs)) 125 parsed_command_line.HasSwitch(switches::kNoErrorDialogs))
125 return; 126 return;
126 127
127 // The encoding we use for the info is "title|context|direction" where 128 // The encoding we use for the info is "title|context|direction" where
128 // direction is either env_vars::kRtlLocale or env_vars::kLtrLocale depending 129 // direction is either env_vars::kRtlLocale or env_vars::kLtrLocale depending
129 // on the current locale. 130 // on the current locale.
130 std::wstring dlg_strings; 131 std::wstring dlg_strings;
131 dlg_strings.append(l10n_util::GetString(IDS_CRASH_RECOVERY_TITLE)); 132 dlg_strings.append(l10n_util::GetString(IDS_CRASH_RECOVERY_TITLE));
132 dlg_strings.append(L"|"); 133 dlg_strings.append(L"|");
133 dlg_strings.append(l10n_util::GetString(IDS_CRASH_RECOVERY_CONTENT)); 134 dlg_strings.append(l10n_util::GetString(IDS_CRASH_RECOVERY_CONTENT));
134 dlg_strings.append(L"|"); 135 dlg_strings.append(L"|");
135 if (base::i18n::IsRTL()) 136 if (base::i18n::IsRTL())
136 dlg_strings.append(ASCIIToWide(env_vars::kRtlLocale)); 137 dlg_strings.append(ASCIIToWide(env_vars::kRtlLocale));
137 else 138 else
138 dlg_strings.append(ASCIIToWide(env_vars::kLtrLocale)); 139 dlg_strings.append(ASCIIToWide(env_vars::kLtrLocale));
139 140
140 ::SetEnvironmentVariableW(ASCIIToWide(env_vars::kRestartInfo).c_str(), 141 env->SetVar(env_vars::kRestartInfo, WideToUTF8(dlg_strings));
141 dlg_strings.c_str());
142 } 142 }
143 143
144 // This method handles the --hide-icons and --show-icons command line options 144 // This method handles the --hide-icons and --show-icons command line options
145 // for chrome that get triggered by Windows from registry entries 145 // for chrome that get triggered by Windows from registry entries
146 // HideIconsCommand & ShowIconsCommand. Chrome doesn't support hide icons 146 // HideIconsCommand & ShowIconsCommand. Chrome doesn't support hide icons
147 // functionality so we just ask the users if they want to uninstall Chrome. 147 // functionality so we just ask the users if they want to uninstall Chrome.
148 int HandleIconsCommands(const CommandLine &parsed_command_line) { 148 int HandleIconsCommands(const CommandLine &parsed_command_line) {
149 if (parsed_command_line.HasSwitch(switches::kHideIcons)) { 149 if (parsed_command_line.HasSwitch(switches::kHideIcons)) {
150 std::wstring cp_applet; 150 std::wstring cp_applet;
151 win_util::WinVersion version = win_util::GetWinVersion(); 151 win_util::WinVersion version = win_util::GetWinVersion();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 base::EnsureNSPRInit(); 232 base::EnsureNSPRInit();
233 } 233 }
234 } 234 }
235 }; 235 };
236 236
237 // static 237 // static
238 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( 238 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts(
239 const MainFunctionParams& parameters) { 239 const MainFunctionParams& parameters) {
240 return new BrowserMainPartsWin(parameters); 240 return new BrowserMainPartsWin(parameters);
241 } 241 }
OLDNEW
« no previous file with comments | « chrome/app/client_util.cc ('k') | chrome/browser/first_run/first_run_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698