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

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

Issue 7377010: This change will split the result codes between content and chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: actually rename the files Created 9 years, 5 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) 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
11 #include <algorithm> 11 #include <algorithm>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/environment.h" 14 #include "base/environment.h"
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/scoped_native_library.h" 18 #include "base/scoped_native_library.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "base/win/windows_version.h" 20 #include "base/win/windows_version.h"
21 #include "base/win/wrapped_window_proc.h" 21 #include "base/win/wrapped_window_proc.h"
22 #include "chrome/browser/browser_util_win.h" 22 #include "chrome/browser/browser_util_win.h"
23 #include "chrome/browser/first_run/first_run.h" 23 #include "chrome/browser/first_run/first_run.h"
24 #include "chrome/browser/metrics/metrics_service.h" 24 #include "chrome/browser/metrics/metrics_service.h"
25 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list.h"
26 #include "chrome/browser/ui/views/uninstall_view.h" 26 #include "chrome/browser/ui/views/uninstall_view.h"
27 #include "chrome/common/chrome_constants.h" 27 #include "chrome/common/chrome_constants.h"
28 #include "chrome/common/chrome_result_codes.h"
28 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/env_vars.h" 30 #include "chrome/common/env_vars.h"
30 #include "chrome/installer/util/browser_distribution.h" 31 #include "chrome/installer/util/browser_distribution.h"
31 #include "chrome/installer/util/helper.h" 32 #include "chrome/installer/util/helper.h"
32 #include "chrome/installer/util/install_util.h" 33 #include "chrome/installer/util/install_util.h"
33 #include "chrome/installer/util/shell_util.h" 34 #include "chrome/installer/util/shell_util.h"
34 #include "content/common/main_function_params.h" 35 #include "content/common/main_function_params.h"
35 #include "content/common/result_codes.h"
36 #include "crypto/nss_util.h" 36 #include "crypto/nss_util.h"
37 #include "grit/chromium_strings.h" 37 #include "grit/chromium_strings.h"
38 #include "grit/generated_resources.h" 38 #include "grit/generated_resources.h"
39 #include "net/base/winsock_init.h" 39 #include "net/base/winsock_init.h"
40 #include "net/socket/client_socket_factory.h" 40 #include "net/socket/client_socket_factory.h"
41 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/base/l10n/l10n_util_win.h" 42 #include "ui/base/l10n/l10n_util_win.h"
43 #include "ui/base/message_box_win.h" 43 #include "ui/base/message_box_win.h"
44 #include "views/focus/accelerator_handler.h" 44 #include "views/focus/accelerator_handler.h"
45 #include "views/widget/widget.h" 45 #include "views/widget/widget.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 base::TimeDelta elapsed_from_startup = 93 base::TimeDelta elapsed_from_startup =
94 base::Time::Now() - base::Time::FromFileTime(creation_time); 94 base::Time::Now() - base::Time::FromFileTime(creation_time);
95 95
96 // Record the time to present in a histogram. 96 // Record the time to present in a histogram.
97 UMA_HISTOGRAM_MEDIUM_TIMES("Startup.BrowserMessageLoopStartTime", 97 UMA_HISTOGRAM_MEDIUM_TIMES("Startup.BrowserMessageLoopStartTime",
98 elapsed_from_startup); 98 elapsed_from_startup);
99 } 99 }
100 100
101 int AskForUninstallConfirmation() { 101 int AskForUninstallConfirmation() {
102 int ret = ResultCodes::NORMAL_EXIT; 102 int ret = content::RESULT_CODE_NORMAL_EXIT;
103 views::Widget::CreateWindow(new UninstallView(ret))->Show(); 103 views::Widget::CreateWindow(new UninstallView(ret))->Show();
104 views::AcceleratorHandler accelerator_handler; 104 views::AcceleratorHandler accelerator_handler;
105 MessageLoopForUI::current()->Run(&accelerator_handler); 105 MessageLoopForUI::current()->Run(&accelerator_handler);
106 return ret; 106 return ret;
107 } 107 }
108 108
109 void ShowCloseBrowserFirstMessageBox() { 109 void ShowCloseBrowserFirstMessageBox() {
110 const string16 text = l10n_util::GetStringUTF16(IDS_UNINSTALL_CLOSE_APP); 110 const string16 text = l10n_util::GetStringUTF16(IDS_UNINSTALL_CLOSE_APP);
111 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); 111 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
112 const UINT flags = MB_OK | MB_ICONWARNING | MB_TOPMOST; 112 const UINT flags = MB_OK | MB_ICONWARNING | MB_TOPMOST;
113 ui::MessageBox(NULL, text, caption, flags); 113 ui::MessageBox(NULL, text, caption, flags);
114 } 114 }
115 115
116 int DoUninstallTasks(bool chrome_still_running) { 116 int DoUninstallTasks(bool chrome_still_running) {
117 // We want to show a warning to user (and exit) if Chrome is already running 117 // We want to show a warning to user (and exit) if Chrome is already running
118 // *before* we show the uninstall confirmation dialog box. But while the 118 // *before* we show the uninstall confirmation dialog box. But while the
119 // uninstall confirmation dialog is up, user might start Chrome, so we 119 // uninstall confirmation dialog is up, user might start Chrome, so we
120 // check once again after user acknowledges Uninstall dialog. 120 // check once again after user acknowledges Uninstall dialog.
121 if (chrome_still_running) { 121 if (chrome_still_running) {
122 ShowCloseBrowserFirstMessageBox(); 122 ShowCloseBrowserFirstMessageBox();
123 return ResultCodes::UNINSTALL_CHROME_ALIVE; 123 return chrome::RESULT_CODE_UNINSTALL_CHROME_ALIVE;
124 } 124 }
125 int ret = AskForUninstallConfirmation(); 125 int ret = AskForUninstallConfirmation();
126 if (browser_util::IsBrowserAlreadyRunning()) { 126 if (browser_util::IsBrowserAlreadyRunning()) {
127 ShowCloseBrowserFirstMessageBox(); 127 ShowCloseBrowserFirstMessageBox();
128 return ResultCodes::UNINSTALL_CHROME_ALIVE; 128 return chrome::RESULT_CODE_UNINSTALL_CHROME_ALIVE;
129 } 129 }
130 130
131 if (ret != ResultCodes::UNINSTALL_USER_CANCEL) { 131 if (ret != chrome::RESULT_CODE_UNINSTALL_USER_CANCEL) {
132 // The following actions are just best effort. 132 // The following actions are just best effort.
133 VLOG(1) << "Executing uninstall actions"; 133 VLOG(1) << "Executing uninstall actions";
134 if (!FirstRun::RemoveSentinel()) 134 if (!FirstRun::RemoveSentinel())
135 VLOG(1) << "Failed to delete sentinel file."; 135 VLOG(1) << "Failed to delete sentinel file.";
136 // We want to remove user level shortcuts and we only care about the ones 136 // We want to remove user level shortcuts and we only care about the ones
137 // created by us and not by the installer so |alternate| is false. 137 // created by us and not by the installer so |alternate| is false.
138 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 138 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
139 if (!ShellUtil::RemoveChromeDesktopShortcut(dist, ShellUtil::CURRENT_USER, 139 if (!ShellUtil::RemoveChromeDesktopShortcut(dist, ShellUtil::CURRENT_USER,
140 false)) 140 false))
141 VLOG(1) << "Failed to delete desktop shortcut."; 141 VLOG(1) << "Failed to delete desktop shortcut.";
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // functionality so we just ask the users if they want to uninstall Chrome. 218 // functionality so we just ask the users if they want to uninstall Chrome.
219 int HandleIconsCommands(const CommandLine& parsed_command_line) { 219 int HandleIconsCommands(const CommandLine& parsed_command_line) {
220 if (parsed_command_line.HasSwitch(switches::kHideIcons)) { 220 if (parsed_command_line.HasSwitch(switches::kHideIcons)) {
221 string16 cp_applet; 221 string16 cp_applet;
222 base::win::Version version = base::win::GetVersion(); 222 base::win::Version version = base::win::GetVersion();
223 if (version >= base::win::VERSION_VISTA) { 223 if (version >= base::win::VERSION_VISTA) {
224 cp_applet.assign(L"Programs and Features"); // Windows Vista and later. 224 cp_applet.assign(L"Programs and Features"); // Windows Vista and later.
225 } else if (version >= base::win::VERSION_XP) { 225 } else if (version >= base::win::VERSION_XP) {
226 cp_applet.assign(L"Add/Remove Programs"); // Windows XP. 226 cp_applet.assign(L"Add/Remove Programs"); // Windows XP.
227 } else { 227 } else {
228 return ResultCodes::UNSUPPORTED_PARAM; // Not supported 228 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; // Not supported
229 } 229 }
230 230
231 const string16 msg = 231 const string16 msg =
232 l10n_util::GetStringFUTF16(IDS_HIDE_ICONS_NOT_SUPPORTED, cp_applet); 232 l10n_util::GetStringFUTF16(IDS_HIDE_ICONS_NOT_SUPPORTED, cp_applet);
233 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); 233 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
234 const UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST; 234 const UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST;
235 if (IDOK == ui::MessageBox(NULL, msg, caption, flags)) 235 if (IDOK == ui::MessageBox(NULL, msg, caption, flags))
236 ShellExecute(NULL, NULL, L"appwiz.cpl", NULL, NULL, SW_SHOWNORMAL); 236 ShellExecute(NULL, NULL, L"appwiz.cpl", NULL, NULL, SW_SHOWNORMAL);
237 return ResultCodes::NORMAL_EXIT; // Exit as we are not launching browser. 237 return content::RESULT_CODE_NORMAL_EXIT; // Exit as we are not launching
238 // the browser.
jam 2011/07/15 19:42:43 nit: this style of comments is not common in chrom
Dirk Pranke 2011/07/15 20:02:23 Done.
238 } 239 }
239 // We don't hide icons so we shouldn't do anything special to show them 240 // We don't hide icons so we shouldn't do anything special to show them
240 return ResultCodes::UNSUPPORTED_PARAM; 241 return chrome::RESULT_CODE_UNSUPPORTED_PARAM;
241 } 242 }
242 243
243 // Check if there is any machine level Chrome installed on the current 244 // Check if there is any machine level Chrome installed on the current
244 // machine. If yes and the current Chrome process is user level, we do not 245 // machine. If yes and the current Chrome process is user level, we do not
245 // allow the user level Chrome to run. So we notify the user and uninstall 246 // allow the user level Chrome to run. So we notify the user and uninstall
246 // user level Chrome. 247 // user level Chrome.
247 bool CheckMachineLevelInstall() { 248 bool CheckMachineLevelInstall() {
248 // TODO(tommi): Check if using the default distribution is always the right 249 // TODO(tommi): Check if using the default distribution is always the right
249 // thing to do. 250 // thing to do.
250 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 251 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 crypto::EnsureNSPRInit(); 314 crypto::EnsureNSPRInit();
314 } 315 }
315 } 316 }
316 }; 317 };
317 318
318 // static 319 // static
319 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( 320 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts(
320 const MainFunctionParams& parameters) { 321 const MainFunctionParams& parameters) {
321 return new BrowserMainPartsWin(parameters); 322 return new BrowserMainPartsWin(parameters);
322 } 323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698