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 <tchar.h> | 6 #include <tchar.h> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | |
10 #include "chrome/app/breakpad_win.h" | 11 #include "chrome/app/breakpad_win.h" |
11 #include "chrome/app/client_util.h" | 12 #include "chrome/app/client_util.h" |
12 #include "chrome/app/metro_driver_win.h" | 13 #include "chrome/app/metro_driver_win.h" |
14 #include "chrome/browser/chrome_process_finder_win.h" | |
15 #include "chrome/common/chrome_paths_internal.h" | |
16 #include "chrome/common/chrome_switches.h" | |
13 #include "content/public/app/startup_helper_win.h" | 17 #include "content/public/app/startup_helper_win.h" |
14 #include "content/public/common/result_codes.h" | 18 #include "content/public/common/result_codes.h" |
15 #include "sandbox/win/src/sandbox_factory.h" | 19 #include "sandbox/win/src/sandbox_factory.h" |
16 | 20 |
17 int RunChrome(HINSTANCE instance) { | 21 int RunChrome(HINSTANCE instance) { |
18 bool exit_now = true; | 22 bool exit_now = true; |
19 // We restarted because of a previous crash. Ask user if we should relaunch. | 23 // We restarted because of a previous crash. Ask user if we should relaunch. |
20 if (ShowRestartDialogIfCrashed(&exit_now)) { | 24 if (ShowRestartDialogIfCrashed(&exit_now)) { |
21 if (exit_now) | 25 if (exit_now) |
22 return content::RESULT_CODE_NORMAL_EXIT; | 26 return content::RESULT_CODE_NORMAL_EXIT; |
23 } | 27 } |
24 | 28 |
25 // Initialize the sandbox services. | 29 // Initialize the sandbox services. |
26 sandbox::SandboxInterfaceInfo sandbox_info = {0}; | 30 sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
27 content::InitializeSandboxInfo(&sandbox_info); | 31 content::InitializeSandboxInfo(&sandbox_info); |
28 | 32 |
29 // Load and launch the chrome dll. *Everything* happens inside. | 33 // Load and launch the chrome dll. *Everything* happens inside. |
30 MainDllLoader* loader = MakeMainDllLoader(); | 34 MainDllLoader* loader = MakeMainDllLoader(); |
31 int rc = loader->Launch(instance, &sandbox_info); | 35 int rc = loader->Launch(instance, &sandbox_info); |
32 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 36 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
33 delete loader; | 37 delete loader; |
34 return rc; | 38 return rc; |
35 } | 39 } |
36 | 40 |
41 bool AttemptFastNotify() { | |
42 // We only support the fast path for the default user data dir. | |
43 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserDataDir)) | |
pastarmovj
2013/05/01 10:54:09
You have to check that the UserDataDir policy is n
koz (OOO until 15th September)
2013/05/09 01:47:42
Done.
| |
44 return false; | |
45 | |
46 base::FilePath udd; | |
cpu_(ooo_6.6-7.5)
2013/04/30 19:33:37
udd -> data_dir
koz (OOO until 15th September)
2013/05/09 01:47:42
Done.
| |
47 if (!chrome::GetDefaultUserDataDirectory(&udd)) | |
48 return false; | |
49 HWND chrome = chrome::FindRunningChromeWindow(udd); | |
50 if (chrome && chrome::AttemptToNotifyRunningChrome(chrome)) | |
51 return true; | |
52 return false; | |
53 } | |
54 | |
37 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) { | 55 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) { |
38 // Initialize the commandline singleton from the environment. | 56 // Initialize the commandline singleton from the environment. |
39 CommandLine::Init(0, NULL); | 57 CommandLine::Init(0, NULL); |
40 // The exit manager is in charge of calling the dtors of singletons. | 58 // The exit manager is in charge of calling the dtors of singletons. |
41 base::AtExitManager exit_manager; | 59 base::AtExitManager exit_manager; |
42 | 60 |
61 if (AttemptFastNotify()) | |
62 return 0; | |
63 | |
43 MetroDriver metro_driver; | 64 MetroDriver metro_driver; |
44 if (metro_driver.in_metro_mode()) | 65 if (metro_driver.in_metro_mode()) |
45 return metro_driver.RunInMetro(instance, &RunChrome); | 66 return metro_driver.RunInMetro(instance, &RunChrome); |
46 // Not in metro mode, proceed as normal. | 67 // Not in metro mode, proceed as normal. |
47 return RunChrome(instance); | 68 return RunChrome(instance); |
48 } | 69 } |
OLD | NEW |