browser_observer.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Copyright (c) 2013 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_BROWSER_BROWSER_OBSERVER_H_
  5. #define ELECTRON_SHELL_BROWSER_BROWSER_OBSERVER_H_
  6. #include <string>
  7. #include "base/memory/scoped_refptr.h"
  8. #include "base/observer_list_types.h"
  9. #include "build/build_config.h"
  10. #include "shell/browser/login_handler.h"
  11. namespace electron {
  12. class BrowserObserver : public base::CheckedObserver {
  13. public:
  14. // The browser is about to close all windows.
  15. virtual void OnBeforeQuit(bool* prevent_default) {}
  16. // The browser has closed all windows and will quit.
  17. virtual void OnWillQuit(bool* prevent_default) {}
  18. // The browser has closed all windows. If the browser is quiting, then this
  19. // method will not be called, instead it will call OnWillQuit.
  20. virtual void OnWindowAllClosed() {}
  21. // The browser is quitting.
  22. virtual void OnQuit() {}
  23. // The browser has opened a file by double clicking in Finder or dragging the
  24. // file to the Dock icon. (macOS only)
  25. virtual void OnOpenFile(bool* prevent_default, const std::string& file_path) {
  26. }
  27. // Browser is used to open a url.
  28. virtual void OnOpenURL(const std::string& url) {}
  29. // The browser is activated with visible/invisible windows (usually by
  30. // clicking on the dock icon).
  31. virtual void OnActivate(bool has_visible_windows) {}
  32. // The browser has finished loading.
  33. virtual void OnWillFinishLaunching() {}
  34. virtual void OnFinishLaunching(base::Value::Dict launch_info) {}
  35. // The browser's accessibility support has changed.
  36. virtual void OnAccessibilitySupportChanged() {}
  37. // The app message loop is ready
  38. virtual void OnPreMainMessageLoopRun() {}
  39. // Called just before app threads are created, this is where first access
  40. // to in-process GpuDataManager should be made.
  41. // Refer https://chromium-review.googlesource.com/c/chromium/src/+/2134864
  42. virtual void OnPreCreateThreads() {}
  43. #if BUILDFLAG(IS_MAC)
  44. // The browser wants to report that an user activity will resume. (macOS only)
  45. virtual void OnWillContinueUserActivity(bool* prevent_default,
  46. const std::string& type) {}
  47. // The browser wants to report an user activity resuming error. (macOS only)
  48. virtual void OnDidFailToContinueUserActivity(const std::string& type,
  49. const std::string& error) {}
  50. // The browser wants to resume a user activity via handoff. (macOS only)
  51. virtual void OnContinueUserActivity(bool* prevent_default,
  52. const std::string& type,
  53. base::Value::Dict user_info,
  54. base::Value::Dict details) {}
  55. // The browser wants to notify that an user activity was resumed. (macOS only)
  56. virtual void OnUserActivityWasContinued(const std::string& type,
  57. base::Value::Dict user_info) {}
  58. // The browser wants to update an user activity payload. (macOS only)
  59. virtual void OnUpdateUserActivityState(bool* prevent_default,
  60. const std::string& type,
  61. base::Value::Dict user_info) {}
  62. // User clicked the native macOS new tab button. (macOS only)
  63. virtual void OnNewWindowForTab() {}
  64. // Browser did become active.
  65. virtual void OnDidBecomeActive() {}
  66. #endif
  67. protected:
  68. ~BrowserObserver() override {}
  69. };
  70. } // namespace electron
  71. #endif // ELECTRON_SHELL_BROWSER_BROWSER_OBSERVER_H_