auto_updater.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_AUTO_UPDATER_H_
  5. #define ATOM_BROWSER_AUTO_UPDATER_H_
  6. #include <map>
  7. #include <string>
  8. #include "base/macros.h"
  9. #include "build/build_config.h"
  10. #include "native_mate/arguments.h"
  11. namespace base {
  12. class Time;
  13. }
  14. namespace auto_updater {
  15. class Delegate {
  16. public:
  17. // An error happened.
  18. virtual void OnError(const std::string& error) {}
  19. virtual void OnError(const std::string& error,
  20. const int code,
  21. const std::string& domain) {}
  22. // Checking to see if there is an update
  23. virtual void OnCheckingForUpdate() {}
  24. // There is an update available and it is being downloaded
  25. virtual void OnUpdateAvailable() {}
  26. // There is no available update.
  27. virtual void OnUpdateNotAvailable() {}
  28. // There is a new update which has been downloaded.
  29. virtual void OnUpdateDownloaded(const std::string& release_notes,
  30. const std::string& release_name,
  31. const base::Time& release_date,
  32. const std::string& update_url) {}
  33. protected:
  34. virtual ~Delegate() {}
  35. };
  36. class AutoUpdater {
  37. public:
  38. typedef std::map<std::string, std::string> HeaderMap;
  39. // Gets/Sets the delegate.
  40. static Delegate* GetDelegate();
  41. static void SetDelegate(Delegate* delegate);
  42. static std::string GetFeedURL();
  43. static void SetFeedURL(mate::Arguments* args);
  44. static void CheckForUpdates();
  45. static void QuitAndInstall();
  46. private:
  47. static Delegate* delegate_;
  48. DISALLOW_IMPLICIT_CONSTRUCTORS(AutoUpdater);
  49. };
  50. } // namespace auto_updater
  51. #endif // ATOM_BROWSER_AUTO_UPDATER_H_