1// Copyright (c) 2012 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/ui/ash/app_list/app_sync_ui_state_watcher.h"
6
7#include "chrome/browser/ui/ash/app_sync_ui_state.h"
8#include "ui/app_list/app_list_model.h"
9
10AppSyncUIStateWatcher::AppSyncUIStateWatcher(Profile* profile,
11                                             app_list::AppListModel* model)
12    : app_sync_ui_state_(AppSyncUIState::Get(profile)),
13      model_(model) {
14  if (app_sync_ui_state_) {
15    app_sync_ui_state_->AddObserver(this);
16    OnAppSyncUIStatusChanged();
17  }
18}
19
20AppSyncUIStateWatcher::~AppSyncUIStateWatcher() {
21  if (app_sync_ui_state_)
22    app_sync_ui_state_->RemoveObserver(this);
23}
24
25void AppSyncUIStateWatcher::OnAppSyncUIStatusChanged() {
26  if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING)
27    model_->SetStatus(app_list::AppListModel::STATUS_SYNCING);
28  else
29    model_->SetStatus(app_list::AppListModel::STATUS_NORMAL);
30}
31