| 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 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 | 12 |
| 13 #include "base/base_switches.h" | 13 #include "base/base_switches.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/environment.h" | 15 #include "base/environment.h" |
| 16 #include "base/files/file_enumerator.h" | 16 #include "base/files/file_enumerator.h" |
| 17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
| 19 #include "base/i18n/rtl.h" | 19 #include "base/i18n/rtl.h" |
| 20 #include "base/location.h" | 20 #include "base/location.h" |
| 21 #include "base/macros.h" | 21 #include "base/macros.h" |
| 22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 23 #include "base/metrics/histogram.h" | 23 #include "base/metrics/histogram.h" |
| 24 #include "base/path_service.h" | 24 #include "base/path_service.h" |
| 25 #include "base/scoped_native_library.h" | 25 #include "base/scoped_native_library.h" |
| 26 #include "base/strings/string_number_conversions.h" | 26 #include "base/strings/string_number_conversions.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 28 #include "base/win/metro.h" | |
| 29 #include "base/win/registry.h" | 28 #include "base/win/registry.h" |
| 30 #include "base/win/win_util.h" | 29 #include "base/win/win_util.h" |
| 31 #include "base/win/windows_version.h" | 30 #include "base/win/windows_version.h" |
| 32 #include "base/win/wrapped_window_proc.h" | 31 #include "base/win/wrapped_window_proc.h" |
| 33 #include "chrome/browser/browser_util_win.h" | 32 #include "chrome/browser/browser_util_win.h" |
| 34 #include "chrome/browser/chrome_elf_init_win.h" | 33 #include "chrome/browser/chrome_elf_init_win.h" |
| 35 #include "chrome/browser/first_run/first_run.h" | 34 #include "chrome/browser/first_run/first_run.h" |
| 36 #include "chrome/browser/install_verification/win/install_verification.h" | 35 #include "chrome/browser/install_verification/win/install_verification.h" |
| 37 #include "chrome/browser/profiles/profile_info_cache.h" | 36 #include "chrome/browser/profiles/profile_info_cache.h" |
| 38 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 37 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 271 } |
| 273 } | 272 } |
| 274 return result; | 273 return result; |
| 275 } | 274 } |
| 276 | 275 |
| 277 // ChromeBrowserMainPartsWin --------------------------------------------------- | 276 // ChromeBrowserMainPartsWin --------------------------------------------------- |
| 278 | 277 |
| 279 ChromeBrowserMainPartsWin::ChromeBrowserMainPartsWin( | 278 ChromeBrowserMainPartsWin::ChromeBrowserMainPartsWin( |
| 280 const content::MainFunctionParams& parameters) | 279 const content::MainFunctionParams& parameters) |
| 281 : ChromeBrowserMainParts(parameters) { | 280 : ChromeBrowserMainParts(parameters) { |
| 282 if (base::win::IsMetroProcess()) { | |
| 283 typedef const wchar_t* (*GetMetroSwitches)(void); | |
| 284 GetMetroSwitches metro_switches_proc = reinterpret_cast<GetMetroSwitches>( | |
| 285 GetProcAddress(base::win::GetMetroModule(), | |
| 286 "GetMetroCommandLineSwitches")); | |
| 287 if (metro_switches_proc) { | |
| 288 base::string16 metro_switches = (*metro_switches_proc)(); | |
| 289 if (!metro_switches.empty()) { | |
| 290 base::CommandLine extra_switches(base::CommandLine::NO_PROGRAM); | |
| 291 extra_switches.ParseFromString(metro_switches); | |
| 292 base::CommandLine::ForCurrentProcess()->AppendArguments(extra_switches, | |
| 293 false); | |
| 294 } | |
| 295 } | |
| 296 } | |
| 297 } | 281 } |
| 298 | 282 |
| 299 ChromeBrowserMainPartsWin::~ChromeBrowserMainPartsWin() { | 283 ChromeBrowserMainPartsWin::~ChromeBrowserMainPartsWin() { |
| 300 } | 284 } |
| 301 | 285 |
| 302 void ChromeBrowserMainPartsWin::ToolkitInitialized() { | 286 void ChromeBrowserMainPartsWin::ToolkitInitialized() { |
| 303 ChromeBrowserMainParts::ToolkitInitialized(); | 287 ChromeBrowserMainParts::ToolkitInitialized(); |
| 304 gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont; | 288 gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont; |
| 305 gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize; | 289 gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize; |
| 306 ui::CursorLoaderWin::SetCursorResourceModule(chrome::kBrowserResourcesDll); | 290 ui::CursorLoaderWin::SetCursorResourceModule(chrome::kBrowserResourcesDll); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 uninstall_cmd.AppendSwitch(installer::switches::kTriggerActiveSetup); | 519 uninstall_cmd.AppendSwitch(installer::switches::kTriggerActiveSetup); |
| 536 | 520 |
| 537 const base::FilePath setup_exe(uninstall_cmd.GetProgram()); | 521 const base::FilePath setup_exe(uninstall_cmd.GetProgram()); |
| 538 const base::string16 params(uninstall_cmd.GetArgumentsString()); | 522 const base::string16 params(uninstall_cmd.GetArgumentsString()); |
| 539 | 523 |
| 540 SHELLEXECUTEINFO sei = { sizeof(sei) }; | 524 SHELLEXECUTEINFO sei = { sizeof(sei) }; |
| 541 sei.fMask = SEE_MASK_NOASYNC; | 525 sei.fMask = SEE_MASK_NOASYNC; |
| 542 sei.nShow = SW_SHOWNORMAL; | 526 sei.nShow = SW_SHOWNORMAL; |
| 543 sei.lpFile = setup_exe.value().c_str(); | 527 sei.lpFile = setup_exe.value().c_str(); |
| 544 sei.lpParameters = params.c_str(); | 528 sei.lpParameters = params.c_str(); |
| 545 // On Windows 8 SEE_MASK_FLAG_LOG_USAGE is necessary to guarantee we | |
| 546 // flip to the Desktop when launching. | |
| 547 if (base::win::IsMetroProcess()) | |
| 548 sei.fMask |= SEE_MASK_FLAG_LOG_USAGE; | |
| 549 | 529 |
| 550 if (!::ShellExecuteEx(&sei)) | 530 if (!::ShellExecuteEx(&sei)) |
| 551 DPCHECK(false); | 531 DPCHECK(false); |
| 552 } | 532 } |
| 553 return true; | 533 return true; |
| 554 } | 534 } |
| 555 } | 535 } |
| 556 return false; | 536 return false; |
| 557 } | 537 } |
| 558 | 538 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 574 if (resource_id) | 554 if (resource_id) |
| 575 return l10n_util::GetStringUTF16(resource_id); | 555 return l10n_util::GetStringUTF16(resource_id); |
| 576 return base::string16(); | 556 return base::string16(); |
| 577 } | 557 } |
| 578 | 558 |
| 579 // static | 559 // static |
| 580 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { | 560 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { |
| 581 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); | 561 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); |
| 582 installer::SetTranslationDelegate(&delegate); | 562 installer::SetTranslationDelegate(&delegate); |
| 583 } | 563 } |
| OLD | NEW |