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

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

Issue 149753002: Enables the 'hotword not listening' icon in the search box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix breaks Created 6 years, 10 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 16 matching lines...) Expand all
27 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 27 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
28 #include "chrome/browser/ui/web_applications/web_app_ui.h" 28 #include "chrome/browser/ui/web_applications/web_app_ui.h"
29 #include "chrome/browser/web_applications/web_app.h" 29 #include "chrome/browser/web_applications/web_app.h"
30 #include "chrome/common/extensions/extension_constants.h" 30 #include "chrome/common/extensions/extension_constants.h"
31 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
32 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
33 #include "content/public/browser/notification_service.h" 33 #include "content/public/browser/notification_service.h"
34 #include "content/public/browser/notification_source.h" 34 #include "content/public/browser/notification_source.h"
35 #include "content/public/browser/page_navigator.h" 35 #include "content/public/browser/page_navigator.h"
36 #include "content/public/browser/user_metrics.h" 36 #include "content/public/browser/user_metrics.h"
37 #include "ui/app_list/app_list_switches.h"
37 #include "ui/app_list/app_list_view_delegate_observer.h" 38 #include "ui/app_list/app_list_view_delegate_observer.h"
38 #include "ui/app_list/search_box_model.h" 39 #include "ui/app_list/search_box_model.h"
39 #include "ui/app_list/speech_ui_model.h" 40 #include "ui/app_list/speech_ui_model.h"
40 41
41 #if defined(USE_ASH) 42 #if defined(USE_ASH)
42 #include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h" 43 #include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h"
43 #endif 44 #endif
44 45
45 #if defined(OS_WIN) 46 #if defined(OS_WIN)
46 #include "chrome/browser/web_applications/web_app_win.h" 47 #include "chrome/browser/web_applications/web_app_win.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 profile_(profile), 91 profile_(profile),
91 model_(NULL) { 92 model_(NULL) {
92 CHECK(controller_); 93 CHECK(controller_);
93 RegisterForNotifications(); 94 RegisterForNotifications();
94 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this); 95 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
95 OnProfileChanged(); // sets model_ 96 OnProfileChanged(); // sets model_
96 app_list::StartPageService* service = 97 app_list::StartPageService* service =
97 app_list::StartPageService::Get(profile_); 98 app_list::StartPageService::Get(profile_);
98 if (service) 99 if (service)
99 service->AddObserver(this); 100 service->AddObserver(this);
101
102 // Hotword listening is on by default in ChromeOS right now. Here shouldn't
103 // use the current state in the webui because it will be changed to 'hotword
104 // listening' state from 'ready' after the view is initialized.
105 speech_ui_.reset(new app_list::SpeechUIModel(
106 #if defined(OS_CHROMEOS)
107 app_list::switches::IsVoiceSearchEnabled() ?
108 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING :
109 #endif
110 app_list::SPEECH_RECOGNITION_OFF));
100 } 111 }
101 112
102 AppListViewDelegate::~AppListViewDelegate() { 113 AppListViewDelegate::~AppListViewDelegate() {
103 app_list::StartPageService* service = 114 app_list::StartPageService* service =
104 app_list::StartPageService::Get(profile_); 115 app_list::StartPageService::Get(profile_);
105 if (service) 116 if (service)
106 service->RemoveObserver(this); 117 service->RemoveObserver(this);
107 g_browser_process-> 118 g_browser_process->
108 profile_manager()->GetProfileInfoCache().RemoveObserver(this); 119 profile_manager()->GetProfileInfoCache().RemoveObserver(this);
109 } 120 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 181
171 app_list::AppListModel* AppListViewDelegate::GetModel() { 182 app_list::AppListModel* AppListViewDelegate::GetModel() {
172 return model_; 183 return model_;
173 } 184 }
174 185
175 app_list::SigninDelegate* AppListViewDelegate::GetSigninDelegate() { 186 app_list::SigninDelegate* AppListViewDelegate::GetSigninDelegate() {
176 return &signin_delegate_; 187 return &signin_delegate_;
177 } 188 }
178 189
179 app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() { 190 app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() {
180 return &speech_ui_; 191 return speech_ui_.get();
181 } 192 }
182 193
183 void AppListViewDelegate::GetShortcutPathForApp( 194 void AppListViewDelegate::GetShortcutPathForApp(
184 const std::string& app_id, 195 const std::string& app_id,
185 const base::Callback<void(const base::FilePath&)>& callback) { 196 const base::Callback<void(const base::FilePath&)>& callback) {
186 #if defined(OS_WIN) 197 #if defined(OS_WIN)
187 ExtensionService* service = profile_->GetExtensionService(); 198 ExtensionService* service = profile_->GetExtensionService();
188 DCHECK(service); 199 DCHECK(service);
189 const extensions::Extension* extension = 200 const extensions::Extension* extension =
190 service->GetInstalledExtension(app_id); 201 service->GetInstalledExtension(app_id);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 service->ToggleSpeechRecognition(); 314 service->ToggleSpeechRecognition();
304 } 315 }
305 316
306 void AppListViewDelegate::ShowForProfileByPath( 317 void AppListViewDelegate::ShowForProfileByPath(
307 const base::FilePath& profile_path) { 318 const base::FilePath& profile_path) {
308 controller_->ShowForProfileByPath(profile_path); 319 controller_->ShowForProfileByPath(profile_path);
309 } 320 }
310 321
311 void AppListViewDelegate::OnSpeechResult(const base::string16& result, 322 void AppListViewDelegate::OnSpeechResult(const base::string16& result,
312 bool is_final) { 323 bool is_final) {
313 speech_ui_.SetSpeechResult(result, is_final); 324 speech_ui_->SetSpeechResult(result, is_final);
314 if (is_final) { 325 if (is_final) {
315 auto_launch_timeout_ = base::TimeDelta::FromSeconds( 326 auto_launch_timeout_ = base::TimeDelta::FromSeconds(
316 kAutoLaunchDefaultTimeoutSec); 327 kAutoLaunchDefaultTimeoutSec);
317 model_->search_box()->SetText(result); 328 model_->search_box()->SetText(result);
318 } 329 }
319 } 330 }
320 331
321 void AppListViewDelegate::OnSpeechSoundLevelChanged(int16 level) { 332 void AppListViewDelegate::OnSpeechSoundLevelChanged(int16 level) {
322 speech_ui_.UpdateSoundLevel(level); 333 speech_ui_->UpdateSoundLevel(level);
323 } 334 }
324 335
325 void AppListViewDelegate::OnSpeechRecognitionStateChanged( 336 void AppListViewDelegate::OnSpeechRecognitionStateChanged(
326 app_list::SpeechRecognitionState new_state) { 337 app_list::SpeechRecognitionState new_state) {
327 speech_ui_.SetSpeechRecognitionState(new_state); 338 speech_ui_->SetSpeechRecognitionState(new_state);
328 } 339 }
329 340
330 void AppListViewDelegate::Observe( 341 void AppListViewDelegate::Observe(
331 int type, 342 int type,
332 const content::NotificationSource& source, 343 const content::NotificationSource& source,
333 const content::NotificationDetails& details) { 344 const content::NotificationDetails& details) {
334 OnProfileChanged(); 345 OnProfileChanged();
335 } 346 }
336 347
337 void AppListViewDelegate::OnProfileAdded(const base::FilePath& profile_path) { 348 void AppListViewDelegate::OnProfileAdded(const base::FilePath& profile_path) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 385
375 void AppListViewDelegate::AddObserver( 386 void AppListViewDelegate::AddObserver(
376 app_list::AppListViewDelegateObserver* observer) { 387 app_list::AppListViewDelegateObserver* observer) {
377 observers_.AddObserver(observer); 388 observers_.AddObserver(observer);
378 } 389 }
379 390
380 void AppListViewDelegate::RemoveObserver( 391 void AppListViewDelegate::RemoveObserver(
381 app_list::AppListViewDelegateObserver* observer) { 392 app_list::AppListViewDelegateObserver* observer) {
382 observers_.RemoveObserver(observer); 393 observers_.RemoveObserver(observer);
383 } 394 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_view_delegate.h ('k') | chrome/browser/ui/app_list/search/search_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698