| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/ui/app_list/app_list_view_delegate.h" | 5 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
| 8 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 8 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
| 9 #include "chrome/browser/ui/app_list/apps_model_builder.h" | 9 #include "chrome/browser/ui/app_list/apps_model_builder.h" |
| 10 #include "chrome/browser/ui/app_list/chrome_app_list_item.h" | 10 #include "chrome/browser/ui/app_list/chrome_app_list_item.h" |
| 11 #include "chrome/browser/ui/app_list/chrome_signin_delegate.h" | |
| 12 #include "chrome/browser/ui/app_list/search_builder.h" | 11 #include "chrome/browser/ui/app_list/search_builder.h" |
| 13 #include "content/public/browser/user_metrics.h" | 12 #include "content/public/browser/user_metrics.h" |
| 14 | 13 |
| 15 #if defined(USE_ASH) | 14 #if defined(USE_ASH) |
| 16 #include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h" | 15 #include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h" |
| 17 #endif | 16 #endif |
| 18 | 17 |
| 19 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller) | 18 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller) |
| 20 : controller_(controller) {} | 19 : controller_(controller) {} |
| 21 | 20 |
| 22 AppListViewDelegate::~AppListViewDelegate() {} | 21 AppListViewDelegate::~AppListViewDelegate() {} |
| 23 | 22 |
| 24 void AppListViewDelegate::SetModel(app_list::AppListModel* model) { | 23 void AppListViewDelegate::SetModel(app_list::AppListModel* model) { |
| 25 if (model) { | 24 if (model) { |
| 26 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 25 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
| 27 apps_builder_.reset(new AppsModelBuilder(profile, | 26 apps_builder_.reset(new AppsModelBuilder(profile, |
| 28 model->apps(), | 27 model->apps(), |
| 29 controller_.get())); | 28 controller_.get())); |
| 30 apps_builder_->Build(); | 29 apps_builder_->Build(); |
| 31 | 30 |
| 32 search_builder_.reset(new SearchBuilder(profile, | 31 search_builder_.reset(new SearchBuilder(profile, |
| 33 model->search_box(), | 32 model->search_box(), |
| 34 model->results(), | 33 model->results(), |
| 35 controller_.get())); | 34 controller_.get())); |
| 36 | |
| 37 signin_delegate_.reset(new ChromeSigninDelegate(profile)); | |
| 38 | |
| 39 #if defined(USE_ASH) | 35 #if defined(USE_ASH) |
| 40 app_sync_ui_state_watcher_.reset(new AppSyncUIStateWatcher(profile, model)); | 36 app_sync_ui_state_watcher_.reset(new AppSyncUIStateWatcher(profile, model)); |
| 41 #endif | 37 #endif |
| 42 } else { | 38 } else { |
| 43 apps_builder_.reset(); | 39 apps_builder_.reset(); |
| 44 search_builder_.reset(); | 40 search_builder_.reset(); |
| 45 #if defined(USE_ASH) | 41 #if defined(USE_ASH) |
| 46 app_sync_ui_state_watcher_.reset(); | 42 app_sync_ui_state_watcher_.reset(); |
| 47 #endif | 43 #endif |
| 48 } | 44 } |
| 49 } | 45 } |
| 50 | 46 |
| 51 app_list::SigninDelegate* AppListViewDelegate::GetSigninDelegate() { | |
| 52 return signin_delegate_.get(); | |
| 53 } | |
| 54 | |
| 55 void AppListViewDelegate::ActivateAppListItem( | 47 void AppListViewDelegate::ActivateAppListItem( |
| 56 app_list::AppListItemModel* item, | 48 app_list::AppListItemModel* item, |
| 57 int event_flags) { | 49 int event_flags) { |
| 58 content::RecordAction(content::UserMetricsAction("AppList_ClickOnApp")); | 50 content::RecordAction(content::UserMetricsAction("AppList_ClickOnApp")); |
| 59 static_cast<ChromeAppListItem*>(item)->Activate(event_flags); | 51 static_cast<ChromeAppListItem*>(item)->Activate(event_flags); |
| 60 } | 52 } |
| 61 | 53 |
| 62 void AppListViewDelegate::StartSearch() { | 54 void AppListViewDelegate::StartSearch() { |
| 63 if (search_builder_.get()) | 55 if (search_builder_.get()) |
| 64 search_builder_->StartSearch(); | 56 search_builder_->StartSearch(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 88 controller_->DismissView(); | 80 controller_->DismissView(); |
| 89 } | 81 } |
| 90 | 82 |
| 91 void AppListViewDelegate::ViewClosing() { | 83 void AppListViewDelegate::ViewClosing() { |
| 92 controller_->ViewClosing(); | 84 controller_->ViewClosing(); |
| 93 } | 85 } |
| 94 | 86 |
| 95 void AppListViewDelegate::ViewActivationChanged(bool active) { | 87 void AppListViewDelegate::ViewActivationChanged(bool active) { |
| 96 controller_->ViewActivationChanged(active); | 88 controller_->ViewActivationChanged(active); |
| 97 } | 89 } |
| OLD | NEW |