auto_updater.h 1.6 KB

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