Chromium Code Reviews| Index: chrome/browser/ui/app_list/app_list_view_delegate.cc |
| 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 ee4769fc650c333695c975dc3b291ad0fd8c40c5..ea824e2c1f41e42a82e53d82d2e034f68c717662 100644 |
| --- a/chrome/browser/ui/app_list/app_list_view_delegate.cc |
| +++ b/chrome/browser/ui/app_list/app_list_view_delegate.cc |
| @@ -6,9 +6,12 @@ |
| #include "base/callback.h" |
| #include "base/files/file_path.h" |
| +#include "base/stl_util.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/feedback/feedback_util.h" |
| +#include "chrome/browser/profiles/profile_info_cache.h" |
| +#include "chrome/browser/profiles/profile_info_util.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
| #include "chrome/browser/ui/app_list/apps_model_builder.h" |
| @@ -25,6 +28,7 @@ |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/page_navigator.h" |
| #include "content/public/browser/user_metrics.h" |
| +#include "ui/base/models/avatar_menu_item_model.h" |
| #if defined(USE_ASH) |
| #include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h" |
| @@ -58,8 +62,26 @@ AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller, |
| AppListViewDelegate::~AppListViewDelegate() {} |
| +void AppListViewDelegate::SetProfile(Profile* profile) { |
| + profile_ = profile; |
|
benwells
2013/07/31 05:47:13
Shouldn't this rebuild models and suchlike? Feels
calamity
2013/08/01 08:35:45
Done.
|
| +} |
| + |
| void AppListViewDelegate::SetModel(app_list::AppListModel* model) { |
|
benwells
2013/07/31 05:47:13
This name is really bad. It rebuilds the whole mod
calamity
2013/08/01 08:35:45
Done. Switched to InitModel.
|
| if (model) { |
| + ProfileInfoCache& cache = |
| + g_browser_process->profile_manager()->GetProfileInfoCache(); |
| + |
| + // Initialize the current user details. |
| + size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); |
| + if (profile_index == std::string::npos) |
| + NOTREACHED(); |
|
tapted
2013/07/31 05:43:53
maybe DCHECK_NE(std::string::npos, profile_index),
calamity
2013/08/01 08:35:45
Done.
|
| + model->SetCurrentUser(cache.GetNameOfProfileAtIndex(profile_index), |
| + cache.GetUserNameOfProfileAtIndex(profile_index)); |
| + |
| + // Initialize the profile menu. |
| + RebuildAvatarMenuItems(model); |
| + |
| + // Initialize apps model. |
| apps_builder_.reset(new AppsModelBuilder(profile_, |
| model->apps(), |
| controller_.get())); |
| @@ -69,10 +91,9 @@ void AppListViewDelegate::SetModel(app_list::AppListModel* model) { |
| profile_, model->search_box(), model->results(), controller_.get())); |
| signin_delegate_.reset(new ChromeSigninDelegate(profile_)); |
| - |
| #if defined(USE_ASH) |
| app_sync_ui_state_watcher_.reset(new AppSyncUIStateWatcher(profile_, |
| - model)); |
| + model_)); |
|
tapted
2013/07/31 05:43:53
`model_` with an underscore might be an error?
calamity
2013/08/01 08:35:45
Done.
|
| #endif |
| } else { |
|
tapted
2013/07/31 05:43:53
Does something need to be done for the `else` case
calamity
2013/08/01 08:35:45
I removed the else case because it doesn't seem to
|
| apps_builder_.reset(); |
| @@ -160,26 +181,6 @@ gfx::ImageSkia AppListViewDelegate::GetWindowIcon() { |
| return controller_->GetWindowIcon(); |
| } |
| -string16 AppListViewDelegate::GetCurrentUserName() { |
| - ProfileInfoCache& cache = |
| - g_browser_process->profile_manager()->GetProfileInfoCache(); |
| - size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); |
| - if (profile_index != std::string::npos) |
| - return cache.GetNameOfProfileAtIndex(profile_index); |
| - |
| - return string16(); |
| -} |
| - |
| -string16 AppListViewDelegate::GetCurrentUserEmail() { |
| - ProfileInfoCache& cache = |
| - g_browser_process->profile_manager()->GetProfileInfoCache(); |
| - size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); |
| - if (profile_index != std::string::npos) |
| - return cache.GetUserNameOfProfileAtIndex(profile_index); |
| - |
| - return string16(); |
| -} |
| - |
| void AppListViewDelegate::OpenSettings() { |
| ExtensionService* service = profile_->GetExtensionService(); |
| DCHECK(service); |
| @@ -209,3 +210,17 @@ void AppListViewDelegate::OpenFeedback() { |
| chrome::ShowFeedbackPage(browser, std::string(), |
| chrome::kAppLauncherCategoryTag); |
| } |
| + |
| +void AppListViewDelegate::ShowForProfileAtIndex(size_t index) { |
| + controller_->ShowForProfileAtIndex(index); |
| +} |
| + |
| +void AppListViewDelegate::RebuildAvatarMenuItems( |
| + app_list::AppListModel* model) { |
| + ProfileInfoCache& cache = |
| + g_browser_process->profile_manager()->GetProfileInfoCache(); |
| + STLDeleteElements(&model->avatar_menu_items()); |
|
tapted
2013/07/31 05:43:53
it's a bit odd to expose a non-const reference to
calamity
2013/08/01 08:35:45
Done.
|
| + profiles::PopulateAvatarMenuItemModels(model->avatar_menu_items(), |
| + &cache, |
| + base::FilePath()); |
| +} |