| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "base/timer.h" | 13 #include "base/timer.h" |
| 14 #include "chrome/browser/chromeos/system/automatic_reboot_manager_observer.h" |
| 14 #include "chrome/browser/extensions/update_observer.h" | 15 #include "chrome/browser/extensions/update_observer.h" |
| 15 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 16 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 16 #include "components/browser_context_keyed_service/browser_context_keyed_service
_factory.h" | 17 #include "components/browser_context_keyed_service/browser_context_keyed_service
_factory.h" |
| 17 | 18 |
| 18 class Profile; | 19 class Profile; |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace chromeos { |
| 21 | 22 |
| 22 // This class enforces automatic restart on app and Chrome updates in app mode. | 23 // This class enforces automatic restart on app and Chrome updates in app mode. |
| 23 class KioskAppUpdateService : public BrowserContextKeyedService, | 24 class KioskAppUpdateService : public BrowserContextKeyedService, |
| 24 public extensions::UpdateObserver { | 25 public extensions::UpdateObserver, |
| 26 public system::AutomaticRebootManagerObserver { |
| 25 public: | 27 public: |
| 26 explicit KioskAppUpdateService(Profile* profile); | 28 explicit KioskAppUpdateService(Profile* profile); |
| 27 virtual ~KioskAppUpdateService(); | 29 virtual ~KioskAppUpdateService(); |
| 28 | 30 |
| 29 void set_app_id(const std::string& app_id) { app_id_ = app_id; } | 31 void set_app_id(const std::string& app_id) { app_id_ = app_id; } |
| 30 std::string get_app_id() const { return app_id_; } | 32 std::string get_app_id() const { return app_id_; } |
| 31 | 33 |
| 32 private: | 34 private: |
| 33 void StartRestartTimer(); | 35 void StartRestartTimer(); |
| 34 void ForceRestart(); | 36 void ForceRestart(); |
| 35 | 37 |
| 38 // BrowserContextKeyedService overrides: |
| 39 virtual void Shutdown() OVERRIDE; |
| 40 |
| 36 // extensions::UpdateObserver overrides: | 41 // extensions::UpdateObserver overrides: |
| 37 virtual void OnAppUpdateAvailable(const std::string& app_id) OVERRIDE; | 42 virtual void OnAppUpdateAvailable(const std::string& app_id) OVERRIDE; |
| 38 virtual void OnChromeUpdateAvailable() OVERRIDE {} | 43 virtual void OnChromeUpdateAvailable() OVERRIDE {} |
| 39 | 44 |
| 40 // BrowserContextKeyedService overrides: | 45 // system::AutomaticRebootManagerObserver overrides: |
| 41 virtual void Shutdown() OVERRIDE; | 46 virtual void OnRebootScheduled(Reason reason) OVERRIDE; |
| 42 | 47 |
| 43 private: | |
| 44 Profile* profile_; | 48 Profile* profile_; |
| 45 std::string app_id_; | 49 std::string app_id_; |
| 46 | 50 |
| 47 // After we detect an upgrade we start a one-short timer to force restart. | 51 // After we detect an upgrade we start a one-short timer to force restart. |
| 48 base::OneShotTimer<KioskAppUpdateService> restart_timer_; | 52 base::OneShotTimer<KioskAppUpdateService> restart_timer_; |
| 49 | 53 |
| 50 DISALLOW_COPY_AND_ASSIGN(KioskAppUpdateService); | 54 DISALLOW_COPY_AND_ASSIGN(KioskAppUpdateService); |
| 51 }; | 55 }; |
| 52 | 56 |
| 53 // Singleton that owns all KioskAppUpdateServices and associates them with | 57 // Singleton that owns all KioskAppUpdateServices and associates them with |
| (...skipping 14 matching lines...) Expand all Loading... |
| 68 virtual ~KioskAppUpdateServiceFactory(); | 72 virtual ~KioskAppUpdateServiceFactory(); |
| 69 | 73 |
| 70 // BrowserContextKeyedServiceFactory overrides: | 74 // BrowserContextKeyedServiceFactory overrides: |
| 71 virtual BrowserContextKeyedService* BuildServiceInstanceFor( | 75 virtual BrowserContextKeyedService* BuildServiceInstanceFor( |
| 72 content::BrowserContext* profile) const OVERRIDE; | 76 content::BrowserContext* profile) const OVERRIDE; |
| 73 }; | 77 }; |
| 74 | 78 |
| 75 } // namespace chromeos | 79 } // namespace chromeos |
| 76 | 80 |
| 77 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_ | 81 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_ |
| OLD | NEW |