browser_observer.h 3.4 KB

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