browser_process_platform_part_chromeos.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_CHROMEOS_H_
  5. #define CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_CHROMEOS_H_
  6. #include "base/callback_list.h"
  7. #include "base/sequence_checker.h"
  8. #include "chrome/browser/browser_process_platform_part_base.h"
  9. #include "chrome/browser/ui/browser_list_observer.h"
  10. class Browser;
  11. class BrowserProcessPlatformPartChromeOS
  12. : public BrowserProcessPlatformPartBase {
  13. public:
  14. BrowserProcessPlatformPartChromeOS();
  15. BrowserProcessPlatformPartChromeOS(
  16. const BrowserProcessPlatformPartChromeOS&) = delete;
  17. BrowserProcessPlatformPartChromeOS& operator=(
  18. const BrowserProcessPlatformPartChromeOS&) = delete;
  19. ~BrowserProcessPlatformPartChromeOS() override;
  20. protected:
  21. // Returns true if we can restore URLs for `profile`. Restoring URLs should
  22. // only be allowed for regular signed-in users. This is currently virtual as
  23. // lacros-chrome and ash-chrome check this in different ways.
  24. // TODO(tluk): Have both ash-chrome and lacros-chrome share the same profile
  25. // check code.
  26. virtual bool CanRestoreUrlsForProfile(const Profile* profile) const;
  27. private:
  28. // An observer that restores urls based on the on startup setting after a new
  29. // browser is added to the BrowserList.
  30. class BrowserRestoreObserver : public BrowserListObserver {
  31. public:
  32. explicit BrowserRestoreObserver(const BrowserProcessPlatformPartChromeOS*
  33. browser_process_platform_part);
  34. ~BrowserRestoreObserver() override;
  35. protected:
  36. // BrowserListObserver:
  37. void OnBrowserAdded(Browser* browser) override;
  38. private:
  39. // Returns true, if the url defined in the on startup setting should be
  40. // opened. Otherwise, returns false.
  41. bool ShouldRestoreUrls(Browser* browser) const;
  42. // Returns true, if the url defined in the on startup setting should be
  43. // opened in a new browser. Otherwise, returns false.
  44. bool ShouldOpenUrlsInNewBrowser(Browser* browser) const;
  45. // Restores urls based on the on startup setting.
  46. void RestoreUrls(Browser* browser);
  47. // Called when a session is restored.
  48. void OnSessionRestoreDone(Profile* profile, int num_tabs_restored);
  49. const raw_ptr<const BrowserProcessPlatformPartChromeOS>
  50. browser_process_platform_part_;
  51. base::CallbackListSubscription on_session_restored_callback_subscription_;
  52. };
  53. BrowserRestoreObserver browser_restore_observer_;
  54. };
  55. #endif // CHROME_BROWSER_BROWSER_PROCESS_PLATFORM_PART_CHROMEOS_H_