auto_updater.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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, const int code,
  20. const std::string& domain) {}
  21. // Checking to see if there is an update
  22. virtual void OnCheckingForUpdate() {}
  23. // There is an update available and it is being downloaded
  24. virtual void OnUpdateAvailable() {}
  25. // There is no available update.
  26. virtual void OnUpdateNotAvailable() {}
  27. // There is a new update which has been downloaded.
  28. virtual void OnUpdateDownloaded(const std::string& release_notes,
  29. const std::string& release_name,
  30. const base::Time& release_date,
  31. const std::string& update_url) {}
  32. protected:
  33. virtual ~Delegate() {}
  34. };
  35. class AutoUpdater {
  36. public:
  37. typedef std::map<std::string, std::string> HeaderMap;
  38. // Gets/Sets the delegate.
  39. static Delegate* GetDelegate();
  40. static void SetDelegate(Delegate* delegate);
  41. static std::string GetFeedURL();
  42. static void SetFeedURL(mate::Arguments* args);
  43. static void CheckForUpdates();
  44. static void QuitAndInstall();
  45. private:
  46. static Delegate* delegate_;
  47. DISALLOW_IMPLICIT_CONSTRUCTORS(AutoUpdater);
  48. };
  49. } // namespace auto_updater
  50. #endif // ATOM_BROWSER_AUTO_UPDATER_H_