diff options
Diffstat (limited to 'chrome/browser/ui')
4 files changed, 84 insertions, 0 deletions
diff --git a/chrome/browser/ui/app_list/app_list_view_delegate.cc b/chrome/browser/ui/app_list/app_list_view_delegate.cc index 56ff598..efdc66f 100644 --- a/chrome/browser/ui/app_list/app_list_view_delegate.cc +++ b/chrome/browser/ui/app_list/app_list_view_delegate.cc @@ -10,6 +10,10 @@ #include "chrome/browser/ui/app_list/search_builder.h" #include "content/public/browser/user_metrics.h" +#if defined(USE_ASH) +#include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h" +#endif + AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller) : controller_(controller) {} @@ -27,9 +31,15 @@ void AppListViewDelegate::SetModel(app_list::AppListModel* model) { model->search_box(), model->results(), controller_.get())); +#if defined(USE_ASH) + app_sync_ui_state_watcher_.reset(new AppSyncUIStateWatcher(profile, model)); +#endif } else { apps_builder_.reset(); search_builder_.reset(); +#if defined(USE_ASH) + app_sync_ui_state_watcher_.reset(); +#endif } } diff --git a/chrome/browser/ui/app_list/app_list_view_delegate.h b/chrome/browser/ui/app_list/app_list_view_delegate.h index c7bbae5..1159e9e 100644 --- a/chrome/browser/ui/app_list/app_list_view_delegate.h +++ b/chrome/browser/ui/app_list/app_list_view_delegate.h @@ -16,6 +16,10 @@ class AppsModelBuilder; class SearchBuilder; +#if defined(USE_ASH) +class AppSyncUIStateWatcher; +#endif + class AppListViewDelegate : public app_list::AppListViewDelegate { public: // The delegate will take ownership of the controller. @@ -42,6 +46,10 @@ class AppListViewDelegate : public app_list::AppListViewDelegate { scoped_ptr<SearchBuilder> search_builder_; scoped_ptr<AppListControllerDelegate> controller_; +#if defined(USE_ASH) + scoped_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_; +#endif + DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate); }; diff --git a/chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.cc b/chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.cc new file mode 100644 index 0000000..c791c00 --- /dev/null +++ b/chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.cc @@ -0,0 +1,30 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h" + +#include "chrome/browser/ui/ash/app_sync_ui_state.h" +#include "ui/app_list/app_list_model.h" + +AppSyncUIStateWatcher::AppSyncUIStateWatcher(Profile* profile, + app_list::AppListModel* model) + : app_sync_ui_state_(AppSyncUIState::Get(profile)), + model_(model) { + if (app_sync_ui_state_) { + app_sync_ui_state_->AddObserver(this); + OnAppSyncUIStatusChanged(); + } +} + +AppSyncUIStateWatcher::~AppSyncUIStateWatcher() { + if (app_sync_ui_state_) + app_sync_ui_state_->RemoveObserver(this); +} + +void AppSyncUIStateWatcher::OnAppSyncUIStatusChanged() { + if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) + model_->SetStatus(app_list::AppListModel::STATUS_SYNCING); + else + model_->SetStatus(app_list::AppListModel::STATUS_NORMAL); +} diff --git a/chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h b/chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h new file mode 100644 index 0000000..5ec74a1 --- /dev/null +++ b/chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h @@ -0,0 +1,36 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_ASH_APP_LIST_APP_SYNC_UI_STATE_WATCHER_H_ +#define CHROME_BROWSER_UI_ASH_APP_LIST_APP_SYNC_UI_STATE_WATCHER_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" + +namespace app_list { +class AppListModel; +} + +class AppSyncUIState; +class Profile; + +// AppSyncUIStateWatcher updates AppListModel status when AppSyncUIState +// of the given profile changes. +class AppSyncUIStateWatcher : public AppSyncUIStateObserver { + public: + AppSyncUIStateWatcher(Profile* profile, app_list::AppListModel* model); + virtual ~AppSyncUIStateWatcher(); + + private: + // AppSyncUIStateObserver overrides: + virtual void OnAppSyncUIStatusChanged() OVERRIDE; + + AppSyncUIState* app_sync_ui_state_; + app_list::AppListModel* model_; // Owned by AppListView + + DISALLOW_COPY_AND_ASSIGN(AppSyncUIStateWatcher); +}; + +#endif // CHROME_BROWSER_UI_ASH_APP_LIST_APP_SYNC_UI_STATE_WATCHER_H_ |