Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Side by Side Diff: chrome/browser/ui/app_list/app_list_view_delegate.cc

Issue 23179002: Update the app launcher menu on profile name change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@le_refactor_gigante_signin_into_model
Patch Set: actually register the observer Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/callback.h" 7 #include "base/callback.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } // namespace 54 } // namespace
55 55
56 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller, 56 AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller,
57 Profile* profile) 57 Profile* profile)
58 : controller_(controller), 58 : controller_(controller),
59 profile_(profile), 59 profile_(profile),
60 model_(NULL) { 60 model_(NULL) {
61 DCHECK(profile_); 61 DCHECK(profile_);
62 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, 62 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
63 content::Source<Profile>(profile_)); 63 content::Source<Profile>(profile_));
64 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
64 } 65 }
65 66
66 AppListViewDelegate::~AppListViewDelegate() { 67 AppListViewDelegate::~AppListViewDelegate() {
tapted 2013/08/15 06:34:31 Just be aware... I don't think this destructor is
67 if (signin_delegate_) 68 if (signin_delegate_)
68 signin_delegate_->RemoveObserver(this); 69 signin_delegate_->RemoveObserver(this);
70 g_browser_process->
71 profile_manager()->GetProfileInfoCache().RemoveObserver(this);
69 } 72 }
70 73
71 void AppListViewDelegate::OnProfileChanged() { 74 void AppListViewDelegate::OnProfileChanged() {
72 model_->SetSignedIn(!signin_delegate_->NeedSignin()); 75 model_->SetSignedIn(!signin_delegate_->NeedSignin());
73 ProfileInfoCache& cache = 76 ProfileInfoCache& cache =
74 g_browser_process->profile_manager()->GetProfileInfoCache(); 77 g_browser_process->profile_manager()->GetProfileInfoCache();
75 // Populate the current user details. 78 // Populate the current user details.
76 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); 79 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
77 // The profile won't exist in the cache if the current app list profile is 80 // The profile won't exist in the cache if the current app list profile is
78 // being deleted. 81 // being deleted.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 void AppListViewDelegate::OnSigninSuccess() { 228 void AppListViewDelegate::OnSigninSuccess() {
226 OnProfileChanged(); 229 OnProfileChanged();
227 } 230 }
228 231
229 void AppListViewDelegate::Observe( 232 void AppListViewDelegate::Observe(
230 int type, 233 int type,
231 const content::NotificationSource& source, 234 const content::NotificationSource& source,
232 const content::NotificationDetails& details) { 235 const content::NotificationDetails& details) {
233 OnProfileChanged(); 236 OnProfileChanged();
234 } 237 }
238
239 void AppListViewDelegate::OnProfileAdded(const base::FilePath& profile_path) {
240 OnProfileChanged();
tapted 2013/08/15 06:34:31 I don't think we need to do anything here
calamity 2013/08/15 09:16:46 Done.
241 }
242
243 void AppListViewDelegate::OnProfileWillBeRemoved(
244 const base::FilePath& profile_path) {
245 OnProfileChanged();
tapted 2013/08/15 06:34:31 This is currently handled in AppListServiceImpl::O
calamity 2013/08/15 09:16:46 Done.
246 }
247
248 void AppListViewDelegate::OnProfileNameChanged(
249 const base::FilePath& profile_path,
250 const string16& old_profile_name) {
tapted 2013/08/15 06:34:31 nit: base::string16
calamity 2013/08/15 09:16:46 Done.
251 OnProfileChanged();
tapted 2013/08/15 07:15:54 Probably also worth adding before this: if (profi
calamity 2013/08/15 09:16:46 Done.
252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698