browser_observer.h 3.2 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 ATOM_BROWSER_BROWSER_OBSERVER_H_
  5. #define ATOM_BROWSER_BROWSER_OBSERVER_H_
  6. #include <string>
  7. #include "atom/browser/login_handler.h"
  8. #include "base/memory/scoped_refptr.h"
  9. #include "build/build_config.h"
  10. namespace base {
  11. class DictionaryValue;
  12. }
  13. namespace atom {
  14. class BrowserObserver {
  15. public:
  16. // The browser is about to close all windows.
  17. virtual void OnBeforeQuit(bool* prevent_default) {}
  18. // The browser has closed all windows and will quit.
  19. virtual void OnWillQuit(bool* prevent_default) {}
  20. // The browser has closed all windows. If the browser is quiting, then this
  21. // method will not be called, instead it will call OnWillQuit.
  22. virtual void OnWindowAllClosed() {}
  23. // The browser is quitting.
  24. virtual void OnQuit() {}
  25. // The browser has opened a file by double clicking in Finder or dragging the
  26. // file to the Dock icon. (macOS only)
  27. virtual void OnOpenFile(bool* prevent_default, const std::string& file_path) {
  28. }
  29. // Browser is used to open a url.
  30. virtual void OnOpenURL(const std::string& url) {}
  31. // The browser is activated with visible/invisible windows (usually by
  32. // clicking on the dock icon).
  33. virtual void OnActivate(bool has_visible_windows) {}
  34. // The browser has finished loading.
  35. virtual void OnWillFinishLaunching() {}
  36. virtual void OnFinishLaunching(const base::DictionaryValue& launch_info) {}
  37. // The browser requests HTTP login.
  38. virtual void OnLogin(scoped_refptr<LoginHandler> login_handler,
  39. const base::DictionaryValue& request_details) {}
  40. // The browser's accessibility suppport has changed.
  41. virtual void OnAccessibilitySupportChanged() {}
  42. // The app message loop is ready
  43. virtual void OnPreMainMessageLoopRun() {}
  44. #if defined(OS_MACOSX)
  45. // The browser wants to report that an user activity will resume. (macOS only)
  46. virtual void OnWillContinueUserActivity(bool* prevent_default,
  47. const std::string& type) {}
  48. // The browser wants to report an user activity resuming error. (macOS only)
  49. virtual void OnDidFailToContinueUserActivity(const std::string& type,
  50. const std::string& error) {}
  51. // The browser wants to resume a user activity via handoff. (macOS only)
  52. virtual void OnContinueUserActivity(bool* prevent_default,
  53. const std::string& type,
  54. const base::DictionaryValue& user_info) {}
  55. // The browser wants to notify that an user activity was resumed. (macOS only)
  56. virtual void OnUserActivityWasContinued(
  57. const std::string& type,
  58. const base::DictionaryValue& user_info) {}
  59. // The browser wants to update an user activity payload. (macOS only)
  60. virtual void OnUpdateUserActivityState(
  61. bool* prevent_default,
  62. const std::string& type,
  63. const base::DictionaryValue& user_info) {}
  64. // User clicked the native macOS new tab button. (macOS only)
  65. virtual void OnNewWindowForTab() {}
  66. #endif
  67. protected:
  68. virtual ~BrowserObserver() {}
  69. };
  70. } // namespace atom
  71. #endif // ATOM_BROWSER_BROWSER_OBSERVER_H_