| OLD | NEW |
| 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <malloc.h> | 6 #include <malloc.h> |
| 7 #include <shellscalingapi.h> | 7 #include <shellscalingapi.h> |
| 8 #include <tchar.h> | 8 #include <tchar.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 bool IsFastStartSwitch(const std::string& command_line_switch) { | 38 bool IsFastStartSwitch(const std::string& command_line_switch) { |
| 39 for (size_t i = 0; i < arraysize(kFastStartSwitches); ++i) { | 39 for (size_t i = 0; i < arraysize(kFastStartSwitches); ++i) { |
| 40 if (command_line_switch == kFastStartSwitches[i]) | 40 if (command_line_switch == kFastStartSwitches[i]) |
| 41 return true; | 41 return true; |
| 42 } | 42 } |
| 43 return false; | 43 return false; |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool ContainsNonFastStartFlag(const CommandLine& command_line) { | 46 bool ContainsNonFastStartFlag(const base::CommandLine& command_line) { |
| 47 const CommandLine::SwitchMap& switches = command_line.GetSwitches(); | 47 const base::CommandLine::SwitchMap& switches = command_line.GetSwitches(); |
| 48 if (switches.size() > arraysize(kFastStartSwitches)) | 48 if (switches.size() > arraysize(kFastStartSwitches)) |
| 49 return true; | 49 return true; |
| 50 for (CommandLine::SwitchMap::const_iterator it = switches.begin(); | 50 for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); |
| 51 it != switches.end(); ++it) { | 51 it != switches.end(); ++it) { |
| 52 if (!IsFastStartSwitch(it->first)) | 52 if (!IsFastStartSwitch(it->first)) |
| 53 return true; | 53 return true; |
| 54 } | 54 } |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool AttemptFastNotify(const CommandLine& command_line) { | 58 bool AttemptFastNotify(const base::CommandLine& command_line) { |
| 59 if (ContainsNonFastStartFlag(command_line)) | 59 if (ContainsNonFastStartFlag(command_line)) |
| 60 return false; | 60 return false; |
| 61 | 61 |
| 62 base::FilePath user_data_dir; | 62 base::FilePath user_data_dir; |
| 63 if (!chrome::GetDefaultUserDataDirectory(&user_data_dir)) | 63 if (!chrome::GetDefaultUserDataDirectory(&user_data_dir)) |
| 64 return false; | 64 return false; |
| 65 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); | 65 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); |
| 66 | 66 |
| 67 HWND chrome = chrome::FindRunningChromeWindow(user_data_dir); | 67 HWND chrome = chrome::FindRunningChromeWindow(user_data_dir); |
| 68 if (!chrome) | 68 if (!chrome) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 HINSTANCE instance = GetModuleHandle(NULL); | 131 HINSTANCE instance = GetModuleHandle(NULL); |
| 132 #endif | 132 #endif |
| 133 SwitchToLFHeap(); | 133 SwitchToLFHeap(); |
| 134 | 134 |
| 135 startup_metric_utils::RecordExeMainEntryTime(); | 135 startup_metric_utils::RecordExeMainEntryTime(); |
| 136 | 136 |
| 137 // Signal Chrome Elf that Chrome has begun to start. | 137 // Signal Chrome Elf that Chrome has begun to start. |
| 138 SignalChromeElf(); | 138 SignalChromeElf(); |
| 139 | 139 |
| 140 // Initialize the commandline singleton from the environment. | 140 // Initialize the commandline singleton from the environment. |
| 141 CommandLine::Init(0, NULL); | 141 base::CommandLine::Init(0, NULL); |
| 142 // The exit manager is in charge of calling the dtors of singletons. | 142 // The exit manager is in charge of calling the dtors of singletons. |
| 143 base::AtExitManager exit_manager; | 143 base::AtExitManager exit_manager; |
| 144 | 144 |
| 145 // We don't want to set DPI awareness on pre-Win7 because we don't support | 145 // We don't want to set DPI awareness on pre-Win7 because we don't support |
| 146 // DirectWrite there. GDI fonts are kerned very badly, so better to leave | 146 // DirectWrite there. GDI fonts are kerned very badly, so better to leave |
| 147 // DPI-unaware and at effective 1.0. See also ShouldUseDirectWrite(). | 147 // DPI-unaware and at effective 1.0. See also ShouldUseDirectWrite(). |
| 148 if (base::win::GetVersion() >= base::win::VERSION_WIN7) | 148 if (base::win::GetVersion() >= base::win::VERSION_WIN7) |
| 149 EnableHighDPISupport(); | 149 EnableHighDPISupport(); |
| 150 | 150 |
| 151 if (AttemptFastNotify(*CommandLine::ForCurrentProcess())) | 151 if (AttemptFastNotify(*base::CommandLine::ForCurrentProcess())) |
| 152 return 0; | 152 return 0; |
| 153 | 153 |
| 154 // Load and launch the chrome dll. *Everything* happens inside. | 154 // Load and launch the chrome dll. *Everything* happens inside. |
| 155 VLOG(1) << "About to load main DLL."; | 155 VLOG(1) << "About to load main DLL."; |
| 156 MainDllLoader* loader = MakeMainDllLoader(); | 156 MainDllLoader* loader = MakeMainDllLoader(); |
| 157 int rc = loader->Launch(instance); | 157 int rc = loader->Launch(instance); |
| 158 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 158 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
| 159 delete loader; | 159 delete loader; |
| 160 return rc; | 160 return rc; |
| 161 } | 161 } |
| OLD | NEW |