1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Contains functions used by BrowserMain() that are win32-specific.
7 #ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_WIN_H_
8 #define CHROME_BROWSER_CHROME_BROWSER_MAIN_WIN_H_
12 #include "chrome/browser/chrome_browser_main.h"
13 #include "chrome/common/conflicts/module_watcher_win.h"
15 class PlatformAuthPolicyObserver;
21 // Handle uninstallation when given the appropriate the command-line switch.
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);
26 class ChromeBrowserMainPartsWin : public ChromeBrowserMainParts {
28 ChromeBrowserMainPartsWin(bool is_integration_test,
29 StartupData* startup_data);
30 ChromeBrowserMainPartsWin(const ChromeBrowserMainPartsWin&) = delete;
31 ChromeBrowserMainPartsWin& operator=(const ChromeBrowserMainPartsWin&) =
33 ~ChromeBrowserMainPartsWin() override;
35 // BrowserParts overrides.
36 void ToolkitInitialized() override;
37 void PreCreateMainMessageLoop() override;
38 int PreCreateThreads() override;
39 void PostMainMessageLoopRun() override;
41 // ChromeBrowserMainParts overrides.
42 void ShowMissingLocaleMessageBox() override;
43 void PreProfileInit() override;
44 void PostProfileInit(Profile* profile, bool is_initial_profile) override;
45 void PostBrowserStart() override;
47 // Prepares the localized strings that are going to be displayed to
48 // the user if the browser process dies. These strings are stored in the
49 // environment block so they are accessible in the early stages of the
50 // chrome executable's lifetime.
51 static void PrepareRestartOnCrashEnviroment(
52 const base::CommandLine& parsed_command_line);
54 // Registers Chrome with the Windows Restart Manager, which will restore the
55 // Chrome session when the computer is restarted after a system update.
56 static void RegisterApplicationRestart(
57 const base::CommandLine& parsed_command_line);
59 // This method handles the --hide-icons and --show-icons command line options
60 // for chrome that get triggered by Windows from registry entries
61 // HideIconsCommand & ShowIconsCommand. Chrome doesn't support hide icons
62 // functionality so we just ask the users if they want to uninstall Chrome.
63 static int HandleIconsCommands(const base::CommandLine& parsed_command_line);
65 // Checks if there is any machine level Chrome installed on the current
66 // machine. If yes and the current Chrome process is user level, uninstalls
67 // the user-level Chrome and susbsequently auto-launches the system-level
68 // Chrome. Returns true if the uninstall was kicked off and this process
70 static bool CheckMachineLevelInstall();
72 // Sets the TranslationDelegate which provides localized strings to
74 static void SetupInstallerUtilStrings();
76 // Return a |command_line| copy modified to restore the session after Windows
77 // updates. Removes URL args, unnecessary switches, and the program name.
78 static base::CommandLine GetRestartCommandLine(
79 const base::CommandLine& command_line);
82 void OnModuleEvent(const ModuleWatcher::ModuleEvent& event);
83 void SetupModuleDatabase(std::unique_ptr<ModuleWatcher>* module_watcher);
85 // Watches module load events and forwards them to the ModuleDatabase.
86 std::unique_ptr<ModuleWatcher> module_watcher_;
88 // Applies enterprise policies for platform auth SSO.
89 std::unique_ptr<PlatformAuthPolicyObserver> platform_auth_policy_observer_;
92 #endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_WIN_H_