auto_updater.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_AUTO_UPDATER_H_
  5. #define SHELL_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 gin {
  14. class Arguments;
  15. }
  16. namespace auto_updater {
  17. class Delegate {
  18. public:
  19. // An error happened.
  20. virtual void OnError(const std::string& message) {}
  21. virtual void OnError(const std::string& message,
  22. const int code,
  23. const std::string& domain) {}
  24. // Checking to see if there is an update
  25. virtual void OnCheckingForUpdate() {}
  26. // There is an update available and it is being downloaded
  27. virtual void OnUpdateAvailable() {}
  28. // There is no available update.
  29. virtual void OnUpdateNotAvailable() {}
  30. // There is a new update which has been downloaded.
  31. virtual void OnUpdateDownloaded(const std::string& release_notes,
  32. const std::string& release_name,
  33. const base::Time& release_date,
  34. const std::string& update_url) {}
  35. protected:
  36. virtual ~Delegate() {}
  37. };
  38. class AutoUpdater {
  39. public:
  40. typedef std::map<std::string, std::string> HeaderMap;
  41. // Gets/Sets the delegate.
  42. static Delegate* GetDelegate();
  43. static void SetDelegate(Delegate* delegate);
  44. static std::string GetFeedURL();
  45. // FIXME(zcbenz): We should not do V8 in this file, this method should only
  46. // accept C++ struct as parameter, and atom_api_auto_updater.cc is responsible
  47. // for parsing the parameter from JavaScript.
  48. static void SetFeedURL(gin::Arguments* args);
  49. static void CheckForUpdates();
  50. static void QuitAndInstall();
  51. private:
  52. static Delegate* delegate_;
  53. DISALLOW_IMPLICIT_CONSTRUCTORS(AutoUpdater);
  54. };
  55. } // namespace auto_updater
  56. #endif // SHELL_BROWSER_AUTO_UPDATER_H_