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

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

Issue 347993002: Put back sign in / sign out / new user handling in the App Launcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comment Created 6 years, 6 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
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 a67672b81ac0eddc3f2b92fb3decbdfa99201ae8..960f117f235739ad991010f9f14f6a3823f425f5 100644
--- a/chrome/browser/ui/app_list/app_list_view_delegate.cc
+++ b/chrome/browser/ui/app_list/app_list_view_delegate.cc
@@ -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 @@ void PopulateUsers(const ProfileInfoCache& profile_info,
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 @@ AppListViewDelegate::~AppListViewDelegate() {
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 @@ void AppListViewDelegate::OnHotwordRecognized() {
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