| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/component_updater/pnacl/pnacl_profile_observer.h" | 5 #include "chrome/browser/component_updater/pnacl/pnacl_updater_observer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" | 8 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" |
| 9 #include "chrome/common/chrome_notification_types.h" | 9 #include "chrome/common/chrome_notification_types.h" |
| 10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| 11 | 11 |
| 12 PnaclProfileObserver::PnaclProfileObserver( | 12 PnaclUpdaterObserver::PnaclUpdaterObserver( |
| 13 PnaclComponentInstaller* installer) : pnacl_installer_(installer) { | 13 PnaclComponentInstaller* installer) : pnacl_installer_(installer) { |
| 14 // We only need to observe NOTIFICATION_LOGIN_USER_CHANGED for ChromeOS | |
| 15 // (and it's only defined for ChromeOS). | |
| 16 #if defined(OS_CHROMEOS) | |
| 17 registrar_.Add(this, | 14 registrar_.Add(this, |
| 18 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 15 chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, |
| 19 content::NotificationService::AllSources()); | 16 content::NotificationService::AllSources()); |
| 20 #endif | |
| 21 } | 17 } |
| 22 | 18 |
| 23 PnaclProfileObserver::~PnaclProfileObserver() { } | 19 PnaclUpdaterObserver::~PnaclUpdaterObserver() { } |
| 24 | 20 |
| 25 void PnaclProfileObserver::Observe( | 21 void PnaclUpdaterObserver::Observe( |
| 26 int type, | 22 int type, |
| 27 const content::NotificationSource& source, | 23 const content::NotificationSource& source, |
| 28 const content::NotificationDetails& details) { | 24 const content::NotificationDetails& details) { |
| 29 #if defined(OS_CHROMEOS) | 25 if (type == chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING) { |
| 30 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { | 26 // If the component updater sleeps before a NotifyInstallSuccess, |
| 31 pnacl_installer_->ReRegisterPnacl(); | 27 // then requests for installs were likely skipped, or an error occurred. |
| 28 pnacl_installer_->NotifyInstallError(); |
| 32 return; | 29 return; |
| 33 } | 30 } |
| 34 NOTREACHED() << "Unexpected notification observed"; | |
| 35 #endif | |
| 36 } | 31 } |
| OLD | NEW |