[email protected] | 81ce2c4 | 2012-03-24 01:43:26 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | // Contains functions used by BrowserMain() that are win32-specific. | ||||
6 | |||||
[email protected] | e6b5bc2 | 2011-09-08 22:01:56 | [diff] [blame] | 7 | #ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_WIN_H_ |
8 | #define CHROME_BROWSER_CHROME_BROWSER_MAIN_WIN_H_ | ||||
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 9 | |
Patrick Monette | 70c6860b | 2017-06-14 19:20:15 | [diff] [blame] | 10 | #include <memory> |
11 | |||||
erikwright | 0cdddbff | 2015-03-12 18:05:34 | [diff] [blame] | 12 | #include "base/files/file_path_watcher.h" |
[email protected] | e6b5bc2 | 2011-09-08 22:01:56 | [diff] [blame] | 13 | #include "chrome/browser/chrome_browser_main.h" |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 14 | |
chrisha | 927d8fe | 2017-01-18 23:09:51 | [diff] [blame] | 15 | class ModuleWatcher; |
grt | aa9d8d2 | 2014-11-13 19:52:36 | [diff] [blame] | 16 | |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 17 | namespace base { |
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 18 | class CommandLine; |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 19 | } |
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 20 | |
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 21 | // Handle uninstallation when given the appropriate the command-line switch. |
[email protected] | 53c38d23 | 2009-02-13 20:52:18 | [diff] [blame] | 22 | // If |chrome_still_running| is true a modal dialog will be shown asking the |
23 | // user to close the other chrome instance. | ||||
24 | int DoUninstallTasks(bool chrome_still_running); | ||||
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 25 | |
[email protected] | e6b5bc2 | 2011-09-08 22:01:56 | [diff] [blame] | 26 | class ChromeBrowserMainPartsWin : public ChromeBrowserMainParts { |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 27 | public: |
Xi Han | 85079c2 | 2019-04-18 21:43:05 | [diff] [blame] | 28 | ChromeBrowserMainPartsWin(const content::MainFunctionParams& parameters, |
29 | StartupData* startup_data); | ||||
David Bienvenu | 1fafcf3 | 2020-07-01 00:33:42 | [diff] [blame] | 30 | ChromeBrowserMainPartsWin(const ChromeBrowserMainPartsWin&) = delete; |
31 | ChromeBrowserMainPartsWin& operator=(const ChromeBrowserMainPartsWin&) = | ||||
32 | delete; | ||||
nick | ddb02ac | 2015-04-24 20:45:38 | [diff] [blame] | 33 | ~ChromeBrowserMainPartsWin() override; |
[email protected] | b83575d | 2012-04-25 18:35:08 | [diff] [blame] | 34 | |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 35 | // BrowserParts overrides. |
nick | ddb02ac | 2015-04-24 20:45:38 | [diff] [blame] | 36 | void ToolkitInitialized() override; |
37 | void PreMainMessageLoopStart() override; | ||||
38 | int PreCreateThreads() override; | ||||
Greg Thompson | dfc7d7f4 | 2020-05-14 19:30:50 | [diff] [blame] | 39 | void PostMainMessageLoopRun() override; |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 40 | |
41 | // ChromeBrowserMainParts overrides. | ||||
nick | ddb02ac | 2015-04-24 20:45:38 | [diff] [blame] | 42 | void ShowMissingLocaleMessageBox() override; |
43 | void PostProfileInit() override; | ||||
44 | void PostBrowserStart() override; | ||||
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 45 | |
46 | // Prepares the localized strings that are going to be displayed to | ||||
47 | // the user if the browser process dies. These strings are stored in the | ||||
48 | // environment block so they are accessible in the early stages of the | ||||
49 | // chrome executable's lifetime. | ||||
50 | static void PrepareRestartOnCrashEnviroment( | ||||
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 51 | const base::CommandLine& parsed_command_line); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 52 | |
53 | // Registers Chrome with the Windows Restart Manager, which will restore the | ||||
54 | // Chrome session when the computer is restarted after a system update. | ||||
55 | static void RegisterApplicationRestart( | ||||
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 56 | const base::CommandLine& parsed_command_line); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 57 | |
58 | // This method handles the --hide-icons and --show-icons command line options | ||||
59 | // for chrome that get triggered by Windows from registry entries | ||||
60 | // HideIconsCommand & ShowIconsCommand. Chrome doesn't support hide icons | ||||
61 | // functionality so we just ask the users if they want to uninstall Chrome. | ||||
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 62 | static int HandleIconsCommands(const base::CommandLine& parsed_command_line); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 63 | |
gab | c535d22 | 2015-12-15 22:00:15 | [diff] [blame] | 64 | // Checks if there is any machine level Chrome installed on the current |
65 | // machine. If yes and the current Chrome process is user level, uninstalls | ||||
66 | // the user-level Chrome and susbsequently auto-launches the system-level | ||||
67 | // Chrome. Returns true if the uninstall was kicked off and this process | ||||
68 | // should exit. | ||||
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 69 | static bool CheckMachineLevelInstall(); |
[email protected] | 81ce2c4 | 2012-03-24 01:43:26 | [diff] [blame] | 70 | |
[email protected] | b4d08ea | 2012-05-24 19:26:57 | [diff] [blame] | 71 | // Sets the TranslationDelegate which provides localized strings to |
72 | // installer_util. | ||||
73 | static void SetupInstallerUtilStrings(); | ||||
74 | |||||
David Bienvenu | 1fafcf3 | 2020-07-01 00:33:42 | [diff] [blame] | 75 | // Return a |command_line| copy modified to restore the session after Windows |
76 | // updates. Removes URL args, unnecessary switches, and the program name. | ||||
77 | static base::CommandLine GetRestartCommandLine( | ||||
78 | const base::CommandLine& command_line); | ||||
79 | |||||
[email protected] | 81ce2c4 | 2012-03-24 01:43:26 | [diff] [blame] | 80 | private: |
Patrick Monette | 70c6860b | 2017-06-14 19:20:15 | [diff] [blame] | 81 | // Watches module load events and forwards them to the ModuleDatabase. |
chrisha | 927d8fe | 2017-01-18 23:09:51 | [diff] [blame] | 82 | std::unique_ptr<ModuleWatcher> module_watcher_; |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 83 | }; |
84 | |||||
[email protected] | e6b5bc2 | 2011-09-08 22:01:56 | [diff] [blame] | 85 | #endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_WIN_H_ |