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 #include "chrome/browser/chromeos/app_mode/kiosk_app_update_service.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_update_service.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/app_mode/app_mode_utils.h" | 8 #include "chrome/browser/app_mode/app_mode_utils.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 10 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if (extension->id() != app_id_) | 90 if (extension->id() != app_id_) |
91 return; | 91 return; |
92 | 92 |
93 // Clears cached app data so that it will be reloaded if update from app | 93 // Clears cached app data so that it will be reloaded if update from app |
94 // does not finish in this run. | 94 // does not finish in this run. |
95 KioskAppManager::Get()->ClearAppData(app_id_); | 95 KioskAppManager::Get()->ClearAppData(app_id_); |
96 KioskAppManager::Get()->UpdateAppDataFromProfile( | 96 KioskAppManager::Get()->UpdateAppDataFromProfile( |
97 app_id_, profile_, extension); | 97 app_id_, profile_, extension); |
98 | 98 |
99 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent( | 99 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent( |
100 profile_, | 100 profile_, app_id_, |
101 app_id_, | 101 extensions::api::runtime::ON_RESTART_REQUIRED_REASON_APP_UPDATE); |
102 extensions::core_api::runtime::ON_RESTART_REQUIRED_REASON_APP_UPDATE); | |
103 | 102 |
104 StartAppUpdateRestartTimer(); | 103 StartAppUpdateRestartTimer(); |
105 } | 104 } |
106 | 105 |
107 void KioskAppUpdateService::OnRebootRequested(Reason reason) { | 106 void KioskAppUpdateService::OnRebootRequested(Reason reason) { |
108 extensions::core_api::runtime::OnRestartRequiredReason restart_reason = | 107 extensions::api::runtime::OnRestartRequiredReason restart_reason = |
109 extensions::core_api::runtime::ON_RESTART_REQUIRED_REASON_NONE; | 108 extensions::api::runtime::ON_RESTART_REQUIRED_REASON_NONE; |
110 switch (reason) { | 109 switch (reason) { |
111 case REBOOT_REASON_OS_UPDATE: | 110 case REBOOT_REASON_OS_UPDATE: |
112 restart_reason = | 111 restart_reason = |
113 extensions::core_api::runtime::ON_RESTART_REQUIRED_REASON_OS_UPDATE; | 112 extensions::api::runtime::ON_RESTART_REQUIRED_REASON_OS_UPDATE; |
114 break; | 113 break; |
115 case REBOOT_REASON_PERIODIC: | 114 case REBOOT_REASON_PERIODIC: |
116 restart_reason = | 115 restart_reason = |
117 extensions::core_api::runtime::ON_RESTART_REQUIRED_REASON_PERIODIC; | 116 extensions::api::runtime::ON_RESTART_REQUIRED_REASON_PERIODIC; |
118 break; | 117 break; |
119 default: | 118 default: |
120 NOTREACHED() << "Unknown reboot reason=" << reason; | 119 NOTREACHED() << "Unknown reboot reason=" << reason; |
121 return; | 120 return; |
122 } | 121 } |
123 | 122 |
124 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent( | 123 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent( |
125 profile_, app_id_, restart_reason); | 124 profile_, app_id_, restart_reason); |
126 } | 125 } |
127 | 126 |
128 void KioskAppUpdateService::WillDestroyAutomaticRebootManager() { | 127 void KioskAppUpdateService::WillDestroyAutomaticRebootManager() { |
129 automatic_reboot_manager_->RemoveObserver(this); | 128 automatic_reboot_manager_->RemoveObserver(this); |
130 automatic_reboot_manager_ = NULL; | 129 automatic_reboot_manager_ = NULL; |
131 } | 130 } |
132 | 131 |
133 void KioskAppUpdateService::OnKioskAppCacheUpdated(const std::string& app_id) { | 132 void KioskAppUpdateService::OnKioskAppCacheUpdated(const std::string& app_id) { |
134 if (app_id != app_id_) | 133 if (app_id != app_id_) |
135 return; | 134 return; |
136 | 135 |
137 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent( | 136 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent( |
138 profile_, | 137 profile_, app_id_, |
139 app_id_, | 138 extensions::api::runtime::ON_RESTART_REQUIRED_REASON_APP_UPDATE); |
140 extensions::core_api::runtime::ON_RESTART_REQUIRED_REASON_APP_UPDATE); | |
141 | 139 |
142 StartAppUpdateRestartTimer(); | 140 StartAppUpdateRestartTimer(); |
143 } | 141 } |
144 | 142 |
145 KioskAppUpdateServiceFactory::KioskAppUpdateServiceFactory() | 143 KioskAppUpdateServiceFactory::KioskAppUpdateServiceFactory() |
146 : BrowserContextKeyedServiceFactory( | 144 : BrowserContextKeyedServiceFactory( |
147 "KioskAppUpdateService", | 145 "KioskAppUpdateService", |
148 BrowserContextDependencyManager::GetInstance()) { | 146 BrowserContextDependencyManager::GetInstance()) { |
149 DependsOn( | 147 DependsOn( |
150 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 148 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
(...skipping 20 matching lines...) Expand all Loading... |
171 } | 169 } |
172 | 170 |
173 KeyedService* KioskAppUpdateServiceFactory::BuildServiceInstanceFor( | 171 KeyedService* KioskAppUpdateServiceFactory::BuildServiceInstanceFor( |
174 content::BrowserContext* context) const { | 172 content::BrowserContext* context) const { |
175 return new KioskAppUpdateService( | 173 return new KioskAppUpdateService( |
176 Profile::FromBrowserContext(context), | 174 Profile::FromBrowserContext(context), |
177 g_browser_process->platform_part()->automatic_reboot_manager()); | 175 g_browser_process->platform_part()->automatic_reboot_manager()); |
178 } | 176 } |
179 | 177 |
180 } // namespace chromeos | 178 } // namespace chromeos |
OLD | NEW |