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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
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 <vector> 7 #include <vector>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 23 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
24 #include "chrome/browser/ui/app_list/search/search_controller.h" 24 #include "chrome/browser/ui/app_list/search/search_controller.h"
25 #include "chrome/browser/ui/app_list/start_page_service.h" 25 #include "chrome/browser/ui/app_list/start_page_service.h"
26 #include "chrome/browser/ui/browser_finder.h" 26 #include "chrome/browser/ui/browser_finder.h"
27 #include "chrome/browser/ui/chrome_pages.h" 27 #include "chrome/browser/ui/chrome_pages.h"
28 #include "chrome/browser/ui/host_desktop.h" 28 #include "chrome/browser/ui/host_desktop.h"
29 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 29 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
30 #include "chrome/browser/web_applications/web_app.h" 30 #include "chrome/browser/web_applications/web_app.h"
31 #include "chrome/common/extensions/extension_constants.h" 31 #include "chrome/common/extensions/extension_constants.h"
32 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
33 #include "components/signin/core/browser/signin_manager.h"
33 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/page_navigator.h" 35 #include "content/public/browser/page_navigator.h"
35 #include "content/public/browser/user_metrics.h" 36 #include "content/public/browser/user_metrics.h"
36 #include "grit/theme_resources.h" 37 #include "grit/theme_resources.h"
37 #include "ui/app_list/app_list_switches.h" 38 #include "ui/app_list/app_list_switches.h"
38 #include "ui/app_list/app_list_view_delegate_observer.h" 39 #include "ui/app_list/app_list_view_delegate_observer.h"
39 #include "ui/app_list/search_box_model.h" 40 #include "ui/app_list/search_box_model.h"
40 #include "ui/app_list/speech_ui_model.h" 41 #include "ui/app_list/speech_ui_model.h"
41 #include "ui/base/resource/resource_bundle.h" 42 #include "ui/base/resource/resource_bundle.h"
42 43
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 user.profile_path = profile_info.GetPathOfProfileAtIndex(i); 97 user.profile_path = profile_info.GetPathOfProfileAtIndex(i);
97 user.active = active_profile_path == user.profile_path; 98 user.active = active_profile_path == user.profile_path;
98 users->push_back(user); 99 users->push_back(user);
99 } 100 }
100 } 101 }
101 102
102 } // namespace 103 } // namespace
103 104
104 AppListViewDelegate::AppListViewDelegate(Profile* profile, 105 AppListViewDelegate::AppListViewDelegate(Profile* profile,
105 AppListControllerDelegate* controller) 106 AppListControllerDelegate* controller)
106 : controller_(controller), profile_(profile), model_(NULL) { 107 : controller_(controller),
108 profile_(profile),
109 model_(NULL),
110 scoped_observer_(this) {
107 CHECK(controller_); 111 CHECK(controller_);
112 SigninManagerFactory::GetInstance()->AddObserver(this);
tapted 2014/06/20 07:58:59 nit: Maybe we need a comment here about why we're
benwells 2014/06/20 08:57:12 Done.
108 113
114 // Start observing all already-created SigninManagers.
109 ProfileManager* profile_manager = g_browser_process->profile_manager(); 115 ProfileManager* profile_manager = g_browser_process->profile_manager();
116 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles();
117 for (std::vector<Profile*>::iterator i = profiles.begin();
118 i != profiles.end();
119 ++i) {
120 SigninManagerBase* manager =
121 SigninManagerFactory::GetForProfileIfExists(*i);
122 if (manager) {
123 DCHECK(!scoped_observer_.IsObserving(manager));
124 scoped_observer_.Add(manager);
125 }
126 }
127
110 profile_manager->GetProfileInfoCache().AddObserver(this); 128 profile_manager->GetProfileInfoCache().AddObserver(this);
111 129
112 app_list::StartPageService* service = 130 app_list::StartPageService* service =
113 app_list::StartPageService::Get(profile_); 131 app_list::StartPageService::Get(profile_);
114 speech_ui_.reset(new app_list::SpeechUIModel( 132 speech_ui_.reset(new app_list::SpeechUIModel(
115 service ? service->state() : app_list::SPEECH_RECOGNITION_OFF)); 133 service ? service->state() : app_list::SPEECH_RECOGNITION_OFF));
116 134
117 #if defined(GOOGLE_CHROME_BUILD) 135 #if defined(GOOGLE_CHROME_BUILD)
118 speech_ui_->set_logo( 136 speech_ui_->set_logo(
119 *ui::ResourceBundle::GetSharedInstance(). 137 *ui::ResourceBundle::GetSharedInstance().
120 GetImageSkiaNamed(IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH)); 138 GetImageSkiaNamed(IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH));
121 #endif 139 #endif
122 140
123 OnProfileChanged(); // sets model_ 141 OnProfileChanged(); // sets model_
124 if (service) 142 if (service)
125 service->AddObserver(this); 143 service->AddObserver(this);
126 } 144 }
127 145
128 AppListViewDelegate::~AppListViewDelegate() { 146 AppListViewDelegate::~AppListViewDelegate() {
129 app_list::StartPageService* service = 147 app_list::StartPageService* service =
130 app_list::StartPageService::Get(profile_); 148 app_list::StartPageService::Get(profile_);
131 if (service) 149 if (service)
132 service->RemoveObserver(this); 150 service->RemoveObserver(this);
133 g_browser_process-> 151 g_browser_process->
134 profile_manager()->GetProfileInfoCache().RemoveObserver(this); 152 profile_manager()->GetProfileInfoCache().RemoveObserver(this);
135 153
154 SigninManagerFactory* factory = SigninManagerFactory::GetInstance();
155 if (factory)
156 factory->RemoveObserver(this);
157
136 // Ensure search controller is released prior to speech_ui_. 158 // Ensure search controller is released prior to speech_ui_.
137 search_controller_.reset(); 159 search_controller_.reset();
138 } 160 }
139 161
140 void AppListViewDelegate::OnHotwordStateChanged(bool started) { 162 void AppListViewDelegate::OnHotwordStateChanged(bool started) {
141 if (started) { 163 if (started) {
142 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_READY) { 164 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_READY) {
143 OnSpeechRecognitionStateChanged( 165 OnSpeechRecognitionStateChanged(
144 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING); 166 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING);
145 } 167 }
146 } else { 168 } else {
147 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING) 169 if (speech_ui_->state() == app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING)
148 OnSpeechRecognitionStateChanged(app_list::SPEECH_RECOGNITION_READY); 170 OnSpeechRecognitionStateChanged(app_list::SPEECH_RECOGNITION_READY);
149 } 171 }
150 } 172 }
151 173
152 void AppListViewDelegate::OnHotwordRecognized() { 174 void AppListViewDelegate::OnHotwordRecognized() {
153 DCHECK_EQ(app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING, 175 DCHECK_EQ(app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING,
154 speech_ui_->state()); 176 speech_ui_->state());
155 ToggleSpeechRecognition(); 177 ToggleSpeechRecognition();
156 } 178 }
157 179
180 void AppListViewDelegate::SigninManagerCreated(SigninManagerBase* manager) {
181 scoped_observer_.Add(manager);
182 }
183
184 void AppListViewDelegate::SigninManagerShutdown(SigninManagerBase* manager) {
185 if (scoped_observer_.IsObserving(manager))
186 scoped_observer_.Remove(manager);
187 }
188
189 void AppListViewDelegate::GoogleSigninFailed(
190 const GoogleServiceAuthError& error) {
191 OnProfileChanged();
192 }
193
194 void AppListViewDelegate::GoogleSigninSucceeded(const std::string& username,
195 const std::string& password) {
196 OnProfileChanged();
197 }
198
199 void AppListViewDelegate::GoogleSignedOut(const std::string& username) {
200 OnProfileChanged();
201 }
202
158 void AppListViewDelegate::OnProfileChanged() { 203 void AppListViewDelegate::OnProfileChanged() {
159 model_ = app_list::AppListSyncableServiceFactory::GetForProfile( 204 model_ = app_list::AppListSyncableServiceFactory::GetForProfile(
160 profile_)->model(); 205 profile_)->model();
161 206
162 search_controller_.reset(new app_list::SearchController( 207 search_controller_.reset(new app_list::SearchController(
163 profile_, model_->search_box(), model_->results(), 208 profile_, model_->search_box(), model_->results(),
164 speech_ui_.get(), controller_)); 209 speech_ui_.get(), controller_));
165 210
166 #if defined(USE_ASH) 211 #if defined(USE_ASH)
167 app_sync_ui_state_watcher_.reset(new AppSyncUIStateWatcher(profile_, model_)); 212 app_sync_ui_state_watcher_.reset(new AppSyncUIStateWatcher(profile_, model_));
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 492
448 void AppListViewDelegate::AddObserver( 493 void AppListViewDelegate::AddObserver(
449 app_list::AppListViewDelegateObserver* observer) { 494 app_list::AppListViewDelegateObserver* observer) {
450 observers_.AddObserver(observer); 495 observers_.AddObserver(observer);
451 } 496 }
452 497
453 void AppListViewDelegate::RemoveObserver( 498 void AppListViewDelegate::RemoveObserver(
454 app_list::AppListViewDelegateObserver* observer) { 499 app_list::AppListViewDelegateObserver* observer) {
455 observers_.RemoveObserver(observer); 500 observers_.RemoveObserver(observer);
456 } 501 }
OLDNEW
« 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