| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_browser_main_win.h" | 5 #include "chrome/browser/chrome_browser_main_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "grit/app_locale_settings.h" | 44 #include "grit/app_locale_settings.h" |
| 45 #include "grit/chromium_strings.h" | 45 #include "grit/chromium_strings.h" |
| 46 #include "grit/generated_resources.h" | 46 #include "grit/generated_resources.h" |
| 47 #include "installer_util_strings/installer_util_strings.h" | 47 #include "installer_util_strings/installer_util_strings.h" |
| 48 #include "ui/base/cursor/cursor_loader_win.h" | 48 #include "ui/base/cursor/cursor_loader_win.h" |
| 49 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
| 50 #include "ui/base/l10n/l10n_util_win.h" | 50 #include "ui/base/l10n/l10n_util_win.h" |
| 51 #include "ui/base/ui_base_switches.h" | 51 #include "ui/base/ui_base_switches.h" |
| 52 #include "ui/base/win/message_box_win.h" | 52 #include "ui/base/win/message_box_win.h" |
| 53 #include "ui/gfx/platform_font_win.h" | 53 #include "ui/gfx/platform_font_win.h" |
| 54 #include "ui/gfx/switches.h" |
| 54 | 55 |
| 55 namespace { | 56 namespace { |
| 56 | 57 |
| 57 typedef HRESULT (STDAPICALLTYPE* RegisterApplicationRestartProc)( | 58 typedef HRESULT (STDAPICALLTYPE* RegisterApplicationRestartProc)( |
| 58 const wchar_t* command_line, | 59 const wchar_t* command_line, |
| 59 DWORD flags); | 60 DWORD flags); |
| 60 | 61 |
| 61 void InitializeWindowProcExceptions() { | 62 void InitializeWindowProcExceptions() { |
| 62 // Get the breakpad pointer from chrome.exe | 63 // Get the breakpad pointer from chrome.exe |
| 63 base::win::WinProcExceptionFilter exception_filter = | 64 base::win::WinProcExceptionFilter exception_filter = |
| (...skipping 15 matching lines...) Expand all Loading... |
| 79 base::StringToInt(l10n_util::GetStringUTF16(IDS_MINIMUM_UI_FONT_SIZE), | 80 base::StringToInt(l10n_util::GetStringUTF16(IDS_MINIMUM_UI_FONT_SIZE), |
| 80 &min_font_size); | 81 &min_font_size); |
| 81 return min_font_size; | 82 return min_font_size; |
| 82 } | 83 } |
| 83 | 84 |
| 84 class TranslationDelegate : public installer::TranslationDelegate { | 85 class TranslationDelegate : public installer::TranslationDelegate { |
| 85 public: | 86 public: |
| 86 virtual string16 GetLocalizedString(int installer_string_id) OVERRIDE; | 87 virtual string16 GetLocalizedString(int installer_string_id) OVERRIDE; |
| 87 }; | 88 }; |
| 88 | 89 |
| 90 // There is a special shortcut that you can start Chrome with that |
| 91 // puts it in a safe mode. Used for troubleshooting end-user issues. |
| 92 bool IsSafeModeStart() { |
| 93 STARTUPINFOW si = {0}; |
| 94 ::GetStartupInfo(&si); |
| 95 if ((si.dwFlags & STARTF_USEHOTKEY) == 0) |
| 96 return false; |
| 97 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 98 return (reinterpret_cast<ULONG_PTR>(si.hStdInput) == |
| 99 static_cast<ULONG_PTR>(dist->GetSafeModeHotkey())); |
| 100 } |
| 101 |
| 89 } // namespace | 102 } // namespace |
| 90 | 103 |
| 91 void ShowCloseBrowserFirstMessageBox() { | 104 void ShowCloseBrowserFirstMessageBox() { |
| 92 int message_id = IDS_UNINSTALL_CLOSE_APP; | 105 int message_id = IDS_UNINSTALL_CLOSE_APP; |
| 93 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && | 106 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && |
| 94 (ShellIntegration::GetDefaultBrowser() == ShellIntegration::IS_DEFAULT)) { | 107 (ShellIntegration::GetDefaultBrowser() == ShellIntegration::IS_DEFAULT)) { |
| 95 message_id = IDS_UNINSTALL_CLOSE_APP_IMMERSIVE; | 108 message_id = IDS_UNINSTALL_CLOSE_APP_IMMERSIVE; |
| 96 } | 109 } |
| 97 chrome::ShowMessageBox(NULL, | 110 chrome::ShowMessageBox(NULL, |
| 98 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 111 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 ChromeBrowserMainParts::PreMainMessageLoopStart(); | 214 ChromeBrowserMainParts::PreMainMessageLoopStart(); |
| 202 if (!parameters().ui_task) { | 215 if (!parameters().ui_task) { |
| 203 // Make sure that we know how to handle exceptions from the message loop. | 216 // Make sure that we know how to handle exceptions from the message loop. |
| 204 InitializeWindowProcExceptions(); | 217 InitializeWindowProcExceptions(); |
| 205 } | 218 } |
| 206 } | 219 } |
| 207 | 220 |
| 208 int ChromeBrowserMainPartsWin::PreCreateThreads() { | 221 int ChromeBrowserMainPartsWin::PreCreateThreads() { |
| 209 int rv = ChromeBrowserMainParts::PreCreateThreads(); | 222 int rv = ChromeBrowserMainParts::PreCreateThreads(); |
| 210 | 223 |
| 224 if (IsSafeModeStart()) { |
| 225 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableGpu); |
| 226 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 227 switches::kHighDPISupport, "0"); |
| 228 } |
| 229 |
| 211 // TODO(viettrungluu): why don't we run this earlier? | 230 // TODO(viettrungluu): why don't we run this earlier? |
| 212 if (!parsed_command_line().HasSwitch(switches::kNoErrorDialogs) && | 231 if (!parsed_command_line().HasSwitch(switches::kNoErrorDialogs) && |
| 213 base::win::GetVersion() < base::win::VERSION_XP) { | 232 base::win::GetVersion() < base::win::VERSION_XP) { |
| 214 chrome::ShowMessageBox(NULL, | 233 chrome::ShowMessageBox(NULL, |
| 215 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 234 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
| 216 l10n_util::GetStringUTF16(IDS_UNSUPPORTED_OS_PRE_WIN_XP), | 235 l10n_util::GetStringUTF16(IDS_UNSUPPORTED_OS_PRE_WIN_XP), |
| 217 chrome::MESSAGE_BOX_TYPE_WARNING); | 236 chrome::MESSAGE_BOX_TYPE_WARNING); |
| 218 } | 237 } |
| 219 | 238 |
| 220 return rv; | 239 return rv; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 if (resource_id) | 426 if (resource_id) |
| 408 return l10n_util::GetStringUTF16(resource_id); | 427 return l10n_util::GetStringUTF16(resource_id); |
| 409 return string16(); | 428 return string16(); |
| 410 } | 429 } |
| 411 | 430 |
| 412 // static | 431 // static |
| 413 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { | 432 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { |
| 414 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); | 433 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); |
| 415 installer::SetTranslationDelegate(&delegate); | 434 installer::SetTranslationDelegate(&delegate); |
| 416 } | 435 } |
| OLD | NEW |