| 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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // This class enforces automatic restart on app and Chrome updates in app mode. | 32 // This class enforces automatic restart on app and Chrome updates in app mode. |
| 33 class KioskAppUpdateService : public KeyedService, | 33 class KioskAppUpdateService : public KeyedService, |
| 34 public extensions::UpdateObserver, | 34 public extensions::UpdateObserver, |
| 35 public system::AutomaticRebootManagerObserver, | 35 public system::AutomaticRebootManagerObserver, |
| 36 public KioskAppManagerObserver { | 36 public KioskAppManagerObserver { |
| 37 public: | 37 public: |
| 38 KioskAppUpdateService( | 38 KioskAppUpdateService( |
| 39 Profile* profile, | 39 Profile* profile, |
| 40 system::AutomaticRebootManager* automatic_reboot_manager); | 40 system::AutomaticRebootManager* automatic_reboot_manager); |
| 41 virtual ~KioskAppUpdateService(); | 41 ~KioskAppUpdateService() override; |
| 42 | 42 |
| 43 void Init(const std::string& app_id); | 43 void Init(const std::string& app_id); |
| 44 | 44 |
| 45 std::string get_app_id() const { return app_id_; } | 45 std::string get_app_id() const { return app_id_; } |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 friend class KioskAppUpdateServiceTest; | 48 friend class KioskAppUpdateServiceTest; |
| 49 | 49 |
| 50 void StartAppUpdateRestartTimer(); | 50 void StartAppUpdateRestartTimer(); |
| 51 void ForceAppUpdateRestart(); | 51 void ForceAppUpdateRestart(); |
| 52 | 52 |
| 53 // KeyedService overrides: | 53 // KeyedService overrides: |
| 54 virtual void Shutdown() override; | 54 void Shutdown() override; |
| 55 | 55 |
| 56 // extensions::UpdateObserver overrides: | 56 // extensions::UpdateObserver overrides: |
| 57 virtual void OnAppUpdateAvailable( | 57 void OnAppUpdateAvailable(const extensions::Extension* extension) override; |
| 58 const extensions::Extension* extension) override; | 58 void OnChromeUpdateAvailable() override {} |
| 59 virtual void OnChromeUpdateAvailable() override {} | |
| 60 | 59 |
| 61 // system::AutomaticRebootManagerObserver overrides: | 60 // system::AutomaticRebootManagerObserver overrides: |
| 62 virtual void OnRebootRequested(Reason reason) override; | 61 void OnRebootRequested(Reason reason) override; |
| 63 virtual void WillDestroyAutomaticRebootManager() override; | 62 void WillDestroyAutomaticRebootManager() override; |
| 64 | 63 |
| 65 // KioskAppManagerObserver overrides: | 64 // KioskAppManagerObserver overrides: |
| 66 virtual void OnKioskAppCacheUpdated(const std::string& app_id) override; | 65 void OnKioskAppCacheUpdated(const std::string& app_id) override; |
| 67 | 66 |
| 68 Profile* profile_; | 67 Profile* profile_; |
| 69 std::string app_id_; | 68 std::string app_id_; |
| 70 | 69 |
| 71 // After we detect an upgrade we start a one-short timer to force restart. | 70 // After we detect an upgrade we start a one-short timer to force restart. |
| 72 base::OneShotTimer<KioskAppUpdateService> restart_timer_; | 71 base::OneShotTimer<KioskAppUpdateService> restart_timer_; |
| 73 | 72 |
| 74 system::AutomaticRebootManager* automatic_reboot_manager_; // Not owned. | 73 system::AutomaticRebootManager* automatic_reboot_manager_; // Not owned. |
| 75 | 74 |
| 76 DISALLOW_COPY_AND_ASSIGN(KioskAppUpdateService); | 75 DISALLOW_COPY_AND_ASSIGN(KioskAppUpdateService); |
| 77 }; | 76 }; |
| 78 | 77 |
| 79 // Singleton that owns all KioskAppUpdateServices and associates them with | 78 // Singleton that owns all KioskAppUpdateServices and associates them with |
| 80 // profiles. | 79 // profiles. |
| 81 class KioskAppUpdateServiceFactory : public BrowserContextKeyedServiceFactory { | 80 class KioskAppUpdateServiceFactory : public BrowserContextKeyedServiceFactory { |
| 82 public: | 81 public: |
| 83 // Returns the KioskAppUpdateService for |profile|, creating it if it is not | 82 // Returns the KioskAppUpdateService for |profile|, creating it if it is not |
| 84 // yet created. | 83 // yet created. |
| 85 static KioskAppUpdateService* GetForProfile(Profile* profile); | 84 static KioskAppUpdateService* GetForProfile(Profile* profile); |
| 86 | 85 |
| 87 // Returns the KioskAppUpdateServiceFactory instance. | 86 // Returns the KioskAppUpdateServiceFactory instance. |
| 88 static KioskAppUpdateServiceFactory* GetInstance(); | 87 static KioskAppUpdateServiceFactory* GetInstance(); |
| 89 | 88 |
| 90 private: | 89 private: |
| 91 friend struct DefaultSingletonTraits<KioskAppUpdateServiceFactory>; | 90 friend struct DefaultSingletonTraits<KioskAppUpdateServiceFactory>; |
| 92 | 91 |
| 93 KioskAppUpdateServiceFactory(); | 92 KioskAppUpdateServiceFactory(); |
| 94 virtual ~KioskAppUpdateServiceFactory(); | 93 ~KioskAppUpdateServiceFactory() override; |
| 95 | 94 |
| 96 // BrowserContextKeyedServiceFactory overrides: | 95 // BrowserContextKeyedServiceFactory overrides: |
| 97 virtual KeyedService* BuildServiceInstanceFor( | 96 KeyedService* BuildServiceInstanceFor( |
| 98 content::BrowserContext* profile) const override; | 97 content::BrowserContext* profile) const override; |
| 99 }; | 98 }; |
| 100 | 99 |
| 101 } // namespace chromeos | 100 } // namespace chromeos |
| 102 | 101 |
| 103 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_ | 102 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_ |
| OLD | NEW |