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

Unified Diff: chrome/browser/ui/app_list/app_list_view_delegate.cc

Issue 405353003: Merge 278990 "Put back sign in / sign out / new user handling in..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/app_list_view_delegate.cc
===================================================================
--- chrome/browser/ui/app_list/app_list_view_delegate.cc (revision 284629)
+++ chrome/browser/ui/app_list/app_list_view_delegate.cc (working copy)
@@ -30,6 +30,7 @@
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/url_constants.h"
+#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/user_metrics.h"
@@ -103,10 +104,30 @@
AppListViewDelegate::AppListViewDelegate(Profile* profile,
AppListControllerDelegate* controller)
- : controller_(controller), profile_(profile), model_(NULL) {
+ : controller_(controller),
+ profile_(profile),
+ model_(NULL),
+ scoped_observer_(this) {
CHECK(controller_);
+ // The SigninManagerFactor and the SigninManagers are observed to keep the
+ // profile switcher menu up to date, with the correct list of profiles and the
+ // correct email address (or none for signed out users) for each.
+ SigninManagerFactory::GetInstance()->AddObserver(this);
+ // Start observing all already-created SigninManagers.
ProfileManager* profile_manager = g_browser_process->profile_manager();
+ std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles();
+ for (std::vector<Profile*>::iterator i = profiles.begin();
+ i != profiles.end();
+ ++i) {
+ SigninManagerBase* manager =
+ SigninManagerFactory::GetForProfileIfExists(*i);
+ if (manager) {
+ DCHECK(!scoped_observer_.IsObserving(manager));
+ scoped_observer_.Add(manager);
+ }
+ }
+
profile_manager->GetProfileInfoCache().AddObserver(this);
app_list::StartPageService* service =
@@ -133,6 +154,10 @@
g_browser_process->
profile_manager()->GetProfileInfoCache().RemoveObserver(this);
+ SigninManagerFactory* factory = SigninManagerFactory::GetInstance();
+ if (factory)
+ factory->RemoveObserver(this);
+
// Ensure search controller is released prior to speech_ui_.
search_controller_.reset();
}
@@ -155,6 +180,29 @@
ToggleSpeechRecognition();
}
+void AppListViewDelegate::SigninManagerCreated(SigninManagerBase* manager) {
+ scoped_observer_.Add(manager);
+}
+
+void AppListViewDelegate::SigninManagerShutdown(SigninManagerBase* manager) {
+ if (scoped_observer_.IsObserving(manager))
+ scoped_observer_.Remove(manager);
+}
+
+void AppListViewDelegate::GoogleSigninFailed(
+ const GoogleServiceAuthError& error) {
+ OnProfileChanged();
+}
+
+void AppListViewDelegate::GoogleSigninSucceeded(const std::string& username,
+ const std::string& password) {
+ OnProfileChanged();
+}
+
+void AppListViewDelegate::GoogleSignedOut(const std::string& username) {
+ OnProfileChanged();
+}
+
void AppListViewDelegate::OnProfileChanged() {
model_ = app_list::AppListSyncableServiceFactory::GetForProfile(
profile_)->model();
« no previous file with comments | « chrome/browser/ui/app_list/app_list_view_delegate.h ('k') | chrome/browser/ui/app_list/test/chrome_app_list_test_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698