1 // Copyright 2022 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 #ifndef CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_CHROMEOS_H_
6 #define CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_CHROMEOS_H_
8 #include "base/callback_list.h"
9 #include "base/sequence_checker.h"
10 #include "chrome/browser/browser_process_platform_part_base.h"
11 #include "chrome/browser/ui/browser_list_observer.h"
16 class BrowserProcessPlatformPartChromeOS
17 : public BrowserProcessPlatformPartBase {
19 BrowserProcessPlatformPartChromeOS();
21 BrowserProcessPlatformPartChromeOS(
22 const BrowserProcessPlatformPartChromeOS&) = delete;
23 BrowserProcessPlatformPartChromeOS& operator=(
24 const BrowserProcessPlatformPartChromeOS&) = delete;
26 ~BrowserProcessPlatformPartChromeOS() override;
29 // Returns true if we can restore URLs for `profile`. Restoring URLs should
30 // only be allowed for regular signed-in users. This is currently virtual as
31 // lacros-chrome and ash-chrome check this in different ways.
32 // TODO(tluk): Have both ash-chrome and lacros-chrome share the same profile
34 virtual bool CanRestoreUrlsForProfile(const Profile* profile) const;
37 // An observer that restores urls based on the on startup setting after a new
38 // browser is added to the BrowserList.
39 class BrowserRestoreObserver : public BrowserListObserver {
41 explicit BrowserRestoreObserver(const BrowserProcessPlatformPartChromeOS*
42 browser_process_platform_part);
44 ~BrowserRestoreObserver() override;
47 // BrowserListObserver:
48 void OnBrowserAdded(Browser* browser) override;
51 // Returns true, if the url defined in the on startup setting should be
52 // opened. Otherwise, returns false.
53 bool ShouldRestoreUrls(Browser* browser) const;
55 // Returns true, if the url defined in the on startup setting should be
56 // opened in a new browser. Otherwise, returns false.
57 bool ShouldOpenUrlsInNewBrowser(Browser* browser) const;
59 // Restores urls based on the on startup setting.
60 void RestoreUrls(Browser* browser);
62 // Called when a session is restored.
63 void OnSessionRestoreDone(Profile* profile, int num_tabs_restored);
65 const raw_ptr<const BrowserProcessPlatformPartChromeOS>
66 browser_process_platform_part_;
68 base::CallbackListSubscription on_session_restored_callback_subscription_;
71 BrowserRestoreObserver browser_restore_observer_;
74 #endif // CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_CHROMEOS_H_