Home | History | Annotate | Download | only in pnacl
      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
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/component_updater/pnacl/pnacl_profile_observer.h"
      6 
      7 #include "base/logging.h"
      8 #include "chrome/browser/chrome_notification_types.h"
      9 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
     10 #include "content/public/browser/notification_service.h"
     11 
     12 PnaclProfileObserver::PnaclProfileObserver(
     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,
     18                  chrome::NOTIFICATION_LOGIN_USER_CHANGED,
     19                  content::NotificationService::AllSources());
     20 #endif
     21 }
     22 
     23 PnaclProfileObserver::~PnaclProfileObserver() { }
     24 
     25 void PnaclProfileObserver::Observe(
     26     int type,
     27     const content::NotificationSource& source,
     28     const content::NotificationDetails& details) {
     29 #if defined(OS_CHROMEOS)
     30   if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) {
     31     pnacl_installer_->ReRegisterPnacl();
     32     return;
     33   }
     34   NOTREACHED() << "Unexpected notification observed";
     35 #endif
     36 }
     37