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

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

Issue 6386009: Remove app/win/win_util.h,cc etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with NSApp changes in r73581 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
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 "app/win/win_util.h"
14 #include "base/command_line.h" 13 #include "base/command_line.h"
15 #include "base/environment.h" 14 #include "base/environment.h"
16 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
17 #include "base/nss_util.h" 16 #include "base/nss_util.h"
18 #include "base/path_service.h" 17 #include "base/path_service.h"
19 #include "base/scoped_ptr.h" 18 #include "base/scoped_ptr.h"
20 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
21 #include "base/win/windows_version.h" 20 #include "base/win/windows_version.h"
22 #include "chrome/browser/browser_list.h" 21 #include "chrome/browser/browser_list.h"
23 #include "chrome/browser/first_run/first_run.h" 22 #include "chrome/browser/first_run/first_run.h"
24 #include "chrome/browser/metrics/metrics_service.h" 23 #include "chrome/browser/metrics/metrics_service.h"
25 #include "chrome/browser/ui/views/uninstall_view.h" 24 #include "chrome/browser/ui/views/uninstall_view.h"
26 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/env_vars.h" 26 #include "chrome/common/env_vars.h"
28 #include "chrome/common/main_function_params.h" 27 #include "chrome/common/main_function_params.h"
29 #include "chrome/common/result_codes.h" 28 #include "chrome/common/result_codes.h"
30 #include "chrome/installer/util/browser_distribution.h" 29 #include "chrome/installer/util/browser_distribution.h"
31 #include "chrome/installer/util/helper.h" 30 #include "chrome/installer/util/helper.h"
32 #include "chrome/installer/util/install_util.h" 31 #include "chrome/installer/util/install_util.h"
33 #include "chrome/installer/util/shell_util.h" 32 #include "chrome/installer/util/shell_util.h"
34 #include "grit/chromium_strings.h" 33 #include "grit/chromium_strings.h"
35 #include "grit/generated_resources.h" 34 #include "grit/generated_resources.h"
36 #include "net/base/winsock_init.h" 35 #include "net/base/winsock_init.h"
37 #include "net/socket/ssl_client_socket_nss_factory.h" 36 #include "net/socket/ssl_client_socket_nss_factory.h"
38 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
39 #include "ui/base/l10n/l10n_util_win.h" 38 #include "ui/base/l10n/l10n_util_win.h"
39 #include "ui/base/message_box_win.h"
40 #include "views/focus/accelerator_handler.h" 40 #include "views/focus/accelerator_handler.h"
41 #include "views/window/window.h" 41 #include "views/window/window.h"
42 42
43 void DidEndMainMessageLoop() { 43 void DidEndMainMessageLoop() {
44 OleUninitialize(); 44 OleUninitialize();
45 } 45 }
46 46
47 void RecordBreakpadStatusUMA(MetricsService* metrics) { 47 void RecordBreakpadStatusUMA(MetricsService* metrics) {
48 DWORD len = ::GetEnvironmentVariableW( 48 DWORD len = ::GetEnvironmentVariableW(
49 ASCIIToWide(env_vars::kNoOOBreakpad).c_str() , NULL, 0); 49 ASCIIToWide(env_vars::kNoOOBreakpad).c_str() , NULL, 0);
50 metrics->RecordBreakpadRegistration((len == 0)); 50 metrics->RecordBreakpadRegistration((len == 0));
51 metrics->RecordBreakpadHasDebugger(TRUE == ::IsDebuggerPresent()); 51 metrics->RecordBreakpadHasDebugger(TRUE == ::IsDebuggerPresent());
52 } 52 }
53 53
54 void WarnAboutMinimumSystemRequirements() { 54 void WarnAboutMinimumSystemRequirements() {
55 if (base::win::GetVersion() < base::win::VERSION_XP) { 55 if (base::win::GetVersion() < base::win::VERSION_XP) {
56 // Display a warning message if the user is running chrome on Windows 2000. 56 // Display a warning message if the user is running chrome on Windows 2000.
57 const string16 text = 57 const string16 text =
58 l10n_util::GetStringUTF16(IDS_UNSUPPORTED_OS_PRE_WIN_XP); 58 l10n_util::GetStringUTF16(IDS_UNSUPPORTED_OS_PRE_WIN_XP);
59 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); 59 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
60 app::win::MessageBox(NULL, text, caption, 60 ui::MessageBox(NULL, text, caption, MB_OK | MB_ICONWARNING | MB_TOPMOST);
61 MB_OK | MB_ICONWARNING | MB_TOPMOST);
62 } 61 }
63 } 62 }
64 63
65 int AskForUninstallConfirmation() { 64 int AskForUninstallConfirmation() {
66 int ret = ResultCodes::NORMAL_EXIT; 65 int ret = ResultCodes::NORMAL_EXIT;
67 views::Window::CreateChromeWindow(NULL, gfx::Rect(), 66 views::Window::CreateChromeWindow(NULL, gfx::Rect(),
68 new UninstallView(ret))->Show(); 67 new UninstallView(ret))->Show();
69 views::AcceleratorHandler accelerator_handler; 68 views::AcceleratorHandler accelerator_handler;
70 MessageLoopForUI::current()->Run(&accelerator_handler); 69 MessageLoopForUI::current()->Run(&accelerator_handler);
71 return ret; 70 return ret;
72 } 71 }
73 72
74 void ShowCloseBrowserFirstMessageBox() { 73 void ShowCloseBrowserFirstMessageBox() {
75 const string16 text = l10n_util::GetStringUTF16(IDS_UNINSTALL_CLOSE_APP); 74 const string16 text = l10n_util::GetStringUTF16(IDS_UNINSTALL_CLOSE_APP);
76 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); 75 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
77 const UINT flags = MB_OK | MB_ICONWARNING | MB_TOPMOST; 76 const UINT flags = MB_OK | MB_ICONWARNING | MB_TOPMOST;
78 app::win::MessageBox(NULL, text, caption, flags); 77 ui::MessageBox(NULL, text, caption, flags);
79 } 78 }
80 79
81 int DoUninstallTasks(bool chrome_still_running) { 80 int DoUninstallTasks(bool chrome_still_running) {
82 // We want to show a warning to user (and exit) if Chrome is already running 81 // We want to show a warning to user (and exit) if Chrome is already running
83 // *before* we show the uninstall confirmation dialog box. But while the 82 // *before* we show the uninstall confirmation dialog box. But while the
84 // uninstall confirmation dialog is up, user might start Chrome, so we 83 // uninstall confirmation dialog is up, user might start Chrome, so we
85 // check once again after user acknowledges Uninstall dialog. 84 // check once again after user acknowledges Uninstall dialog.
86 if (chrome_still_running) { 85 if (chrome_still_running) {
87 ShowCloseBrowserFirstMessageBox(); 86 ShowCloseBrowserFirstMessageBox();
88 return ResultCodes::UNINSTALL_CHROME_ALIVE; 87 return ResultCodes::UNINSTALL_CHROME_ALIVE;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } else if (version >= base::win::VERSION_XP) { 159 } else if (version >= base::win::VERSION_XP) {
161 cp_applet.assign(L"Add/Remove Programs"); // Windows XP. 160 cp_applet.assign(L"Add/Remove Programs"); // Windows XP.
162 } else { 161 } else {
163 return ResultCodes::UNSUPPORTED_PARAM; // Not supported 162 return ResultCodes::UNSUPPORTED_PARAM; // Not supported
164 } 163 }
165 164
166 const string16 msg = 165 const string16 msg =
167 l10n_util::GetStringFUTF16(IDS_HIDE_ICONS_NOT_SUPPORTED, cp_applet); 166 l10n_util::GetStringFUTF16(IDS_HIDE_ICONS_NOT_SUPPORTED, cp_applet);
168 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); 167 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
169 const UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST; 168 const UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST;
170 if (IDOK == app::win::MessageBox(NULL, msg, caption, flags)) 169 if (IDOK == ui::MessageBox(NULL, msg, caption, flags))
171 ShellExecute(NULL, NULL, L"appwiz.cpl", NULL, NULL, SW_SHOWNORMAL); 170 ShellExecute(NULL, NULL, L"appwiz.cpl", NULL, NULL, SW_SHOWNORMAL);
172 return ResultCodes::NORMAL_EXIT; // Exit as we are not launching browser. 171 return ResultCodes::NORMAL_EXIT; // Exit as we are not launching browser.
173 } 172 }
174 // We don't hide icons so we shouldn't do anything special to show them 173 // We don't hide icons so we shouldn't do anything special to show them
175 return ResultCodes::UNSUPPORTED_PARAM; 174 return ResultCodes::UNSUPPORTED_PARAM;
176 } 175 }
177 176
178 // Check if there is any machine level Chrome installed on the current 177 // Check if there is any machine level Chrome installed on the current
179 // machine. If yes and the current Chrome process is user level, we do not 178 // machine. If yes and the current Chrome process is user level, we do not
180 // allow the user level Chrome to run. So we notify the user and uninstall 179 // allow the user level Chrome to run. So we notify the user and uninstall
181 // user level Chrome. 180 // user level Chrome.
182 bool CheckMachineLevelInstall() { 181 bool CheckMachineLevelInstall() {
183 // TODO(tommi): Check if using the default distribution is always the right 182 // TODO(tommi): Check if using the default distribution is always the right
184 // thing to do. 183 // thing to do.
185 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 184 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
186 scoped_ptr<Version> version(InstallUtil::GetChromeVersion(dist, true)); 185 scoped_ptr<Version> version(InstallUtil::GetChromeVersion(dist, true));
187 if (version.get()) { 186 if (version.get()) {
188 FilePath exe_path; 187 FilePath exe_path;
189 PathService::Get(base::DIR_EXE, &exe_path); 188 PathService::Get(base::DIR_EXE, &exe_path);
190 std::wstring exe = exe_path.value(); 189 std::wstring exe = exe_path.value();
191 FilePath user_exe_path(installer::GetChromeInstallPath(false, dist)); 190 FilePath user_exe_path(installer::GetChromeInstallPath(false, dist));
192 if (FilePath::CompareEqualIgnoreCase(exe, user_exe_path.value())) { 191 if (FilePath::CompareEqualIgnoreCase(exe, user_exe_path.value())) {
193 const string16 text = 192 const string16 text =
194 l10n_util::GetStringUTF16(IDS_MACHINE_LEVEL_INSTALL_CONFLICT); 193 l10n_util::GetStringUTF16(IDS_MACHINE_LEVEL_INSTALL_CONFLICT);
195 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); 194 const string16 caption = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
196 const UINT flags = MB_OK | MB_ICONERROR | MB_TOPMOST; 195 const UINT flags = MB_OK | MB_ICONERROR | MB_TOPMOST;
197 app::win::MessageBox(NULL, text, caption, flags); 196 ui::MessageBox(NULL, text, caption, flags);
198 FilePath uninstall_path(InstallUtil::GetChromeUninstallCmd(false, dist)); 197 FilePath uninstall_path(InstallUtil::GetChromeUninstallCmd(false, dist));
199 CommandLine uninstall_cmd(uninstall_path); 198 CommandLine uninstall_cmd(uninstall_path);
200 if (!uninstall_cmd.GetProgram().value().empty()) { 199 if (!uninstall_cmd.GetProgram().value().empty()) {
201 uninstall_cmd.AppendSwitch(installer::switches::kForceUninstall); 200 uninstall_cmd.AppendSwitch(installer::switches::kForceUninstall);
202 uninstall_cmd.AppendSwitch( 201 uninstall_cmd.AppendSwitch(
203 installer::switches::kDoNotRemoveSharedItems); 202 installer::switches::kDoNotRemoveSharedItems);
204 base::LaunchApp(uninstall_cmd, false, false, NULL); 203 base::LaunchApp(uninstall_cmd, false, false, NULL);
205 } 204 }
206 return true; 205 return true;
207 } 206 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 base::EnsureNSPRInit(); 245 base::EnsureNSPRInit();
247 } 246 }
248 } 247 }
249 }; 248 };
250 249
251 // static 250 // static
252 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( 251 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts(
253 const MainFunctionParams& parameters) { 252 const MainFunctionParams& parameters) {
254 return new BrowserMainPartsWin(parameters); 253 return new BrowserMainPartsWin(parameters);
255 } 254 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_win.cc ('k') | chrome/browser/dom_ui/bug_report_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698