OLD | NEW |
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 "apps/custom_launcher_page_contents.h" | 9 #include "apps/custom_launcher_page_contents.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 ++i) { | 166 ++i) { |
167 SigninManagerBase* manager = | 167 SigninManagerBase* manager = |
168 SigninManagerFactory::GetForProfileIfExists(*i); | 168 SigninManagerFactory::GetForProfileIfExists(*i); |
169 if (manager) { | 169 if (manager) { |
170 DCHECK(!scoped_observer_.IsObserving(manager)); | 170 DCHECK(!scoped_observer_.IsObserving(manager)); |
171 scoped_observer_.Add(manager); | 171 scoped_observer_.Add(manager); |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 profile_manager->GetProfileInfoCache().AddObserver(this); | 175 profile_manager->GetProfileInfoCache().AddObserver(this); |
| 176 speech_ui_.reset(new app_list::SpeechUIModel); |
| 177 |
| 178 #if defined(GOOGLE_CHROME_BUILD) |
| 179 speech_ui_->set_logo( |
| 180 *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 181 IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH)); |
| 182 #endif |
176 SetProfile(profile); | 183 SetProfile(profile); |
177 } | 184 } |
178 | 185 |
179 AppListViewDelegate::~AppListViewDelegate() { | 186 AppListViewDelegate::~AppListViewDelegate() { |
180 SetProfile(NULL); | 187 SetProfile(NULL); |
181 g_browser_process->profile_manager()->GetProfileInfoCache().RemoveObserver( | 188 g_browser_process->profile_manager()->GetProfileInfoCache().RemoveObserver( |
182 this); | 189 this); |
183 | 190 |
184 SigninManagerFactory* factory = SigninManagerFactory::GetInstance(); | 191 SigninManagerFactory* factory = SigninManagerFactory::GetInstance(); |
185 if (factory) | 192 if (factory) |
186 factory->RemoveObserver(this); | 193 factory->RemoveObserver(this); |
187 } | 194 } |
188 | 195 |
189 void AppListViewDelegate::SetProfile(Profile* new_profile) { | 196 void AppListViewDelegate::SetProfile(Profile* new_profile) { |
190 if (profile_) { | 197 if (profile_) { |
191 // Note: |search_controller_| has a reference to |speech_ui_| so must be | 198 // Note: |search_controller_| has a reference to |speech_ui_| so must be |
192 // destroyed first. | 199 // destroyed first. |
193 search_controller_.reset(); | 200 search_controller_.reset(); |
194 speech_ui_.reset(); | |
195 custom_page_contents_.clear(); | 201 custom_page_contents_.clear(); |
196 app_list::StartPageService* start_page_service = | 202 app_list::StartPageService* start_page_service = |
197 app_list::StartPageService::Get(profile_); | 203 app_list::StartPageService::Get(profile_); |
198 if (start_page_service) | 204 if (start_page_service) |
199 start_page_service->RemoveObserver(this); | 205 start_page_service->RemoveObserver(this); |
200 #if defined(USE_ASH) | 206 #if defined(USE_ASH) |
201 app_sync_ui_state_watcher_.reset(); | 207 app_sync_ui_state_watcher_.reset(); |
202 #endif | 208 #endif |
203 model_ = NULL; | 209 model_ = NULL; |
204 } | 210 } |
205 | 211 |
206 profile_ = new_profile; | 212 profile_ = new_profile; |
207 if (!profile_) | 213 if (!profile_) { |
| 214 speech_ui_->SetSpeechRecognitionState(app_list::SPEECH_RECOGNITION_OFF); |
208 return; | 215 return; |
| 216 } |
209 | 217 |
210 model_ = | 218 model_ = |
211 app_list::AppListSyncableServiceFactory::GetForProfile(profile_)->model(); | 219 app_list::AppListSyncableServiceFactory::GetForProfile(profile_)->model(); |
212 | 220 |
213 #if defined(USE_ASH) | 221 #if defined(USE_ASH) |
214 app_sync_ui_state_watcher_.reset(new AppSyncUIStateWatcher(profile_, model_)); | 222 app_sync_ui_state_watcher_.reset(new AppSyncUIStateWatcher(profile_, model_)); |
215 #endif | 223 #endif |
216 | 224 |
217 SetUpSearchUI(); | 225 SetUpSearchUI(); |
218 SetUpProfileSwitcher(); | 226 SetUpProfileSwitcher(); |
219 SetUpCustomLauncherPages(); | 227 SetUpCustomLauncherPages(); |
220 | 228 |
221 // Clear search query. | 229 // Clear search query. |
222 model_->search_box()->SetText(base::string16()); | 230 model_->search_box()->SetText(base::string16()); |
223 } | 231 } |
224 | 232 |
225 void AppListViewDelegate::SetUpSearchUI() { | 233 void AppListViewDelegate::SetUpSearchUI() { |
226 app_list::StartPageService* start_page_service = | 234 app_list::StartPageService* start_page_service = |
227 app_list::StartPageService::Get(profile_); | 235 app_list::StartPageService::Get(profile_); |
228 if (start_page_service) | 236 if (start_page_service) |
229 start_page_service->AddObserver(this); | 237 start_page_service->AddObserver(this); |
230 | 238 |
231 speech_ui_.reset(new app_list::SpeechUIModel( | 239 speech_ui_->SetSpeechRecognitionState(start_page_service |
232 start_page_service ? start_page_service->state() | 240 ? start_page_service->state() |
233 : app_list::SPEECH_RECOGNITION_OFF)); | 241 : app_list::SPEECH_RECOGNITION_OFF); |
234 | |
235 #if defined(GOOGLE_CHROME_BUILD) | |
236 speech_ui_->set_logo( | |
237 *ui::ResourceBundle::GetSharedInstance(). | |
238 GetImageSkiaNamed(IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH)); | |
239 #endif | |
240 | 242 |
241 search_controller_.reset(new app_list::SearchController(profile_, | 243 search_controller_.reset(new app_list::SearchController(profile_, |
242 model_->search_box(), | 244 model_->search_box(), |
243 model_->results(), | 245 model_->results(), |
244 speech_ui_.get(), | 246 speech_ui_.get(), |
245 controller_)); | 247 controller_)); |
246 } | 248 } |
247 | 249 |
248 void AppListViewDelegate::SetUpProfileSwitcher() { | 250 void AppListViewDelegate::SetUpProfileSwitcher() { |
249 // Don't populate the app list users if we are on the ash desktop. | 251 // Don't populate the app list users if we are on the ash desktop. |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 | 616 |
615 void AppListViewDelegate::AddObserver( | 617 void AppListViewDelegate::AddObserver( |
616 app_list::AppListViewDelegateObserver* observer) { | 618 app_list::AppListViewDelegateObserver* observer) { |
617 observers_.AddObserver(observer); | 619 observers_.AddObserver(observer); |
618 } | 620 } |
619 | 621 |
620 void AppListViewDelegate::RemoveObserver( | 622 void AppListViewDelegate::RemoveObserver( |
621 app_list::AppListViewDelegateObserver* observer) { | 623 app_list::AppListViewDelegateObserver* observer) { |
622 observers_.RemoveObserver(observer); | 624 observers_.RemoveObserver(observer); |
623 } | 625 } |
OLD | NEW |