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

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: re-upload 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
xiyuan 2014/01/30 00:27:45 nit: nuke one empty line
Jun Mukai 2014/01/30 00:33:24 Done.
103 // Hotword listening is on by default in ChromeOS right now. Here shouldn't
104 // use the current state in the webui because it will be changed to 'hotword
105 // listening' state from 'ready' after the view is initialized.
106 speech_ui_.reset(new app_list::SpeechUIModel(
107 #if defined(OS_CHROMEOS)
108 app_list::switches::IsVoiceSearchEnabled() ?
109 app_list::SPEECH_RECOGNITION_HOTWORD_LISTENING :
xiyuan 2014/01/30 00:27:45 nit: 2 more space indent here and the value on lin
Jun Mukai 2014/01/30 00:33:24 Done.
110 #endif
111 app_list::SPEECH_RECOGNITION_OFF));
100 } 112 }
101 113
102 AppListViewDelegate::~AppListViewDelegate() { 114 AppListViewDelegate::~AppListViewDelegate() {
103 app_list::StartPageService* service = 115 app_list::StartPageService* service =
104 app_list::StartPageService::Get(profile_); 116 app_list::StartPageService::Get(profile_);
105 if (service) 117 if (service)
106 service->RemoveObserver(this); 118 service->RemoveObserver(this);
107 g_browser_process-> 119 g_browser_process->
108 profile_manager()->GetProfileInfoCache().RemoveObserver(this); 120 profile_manager()->GetProfileInfoCache().RemoveObserver(this);
109 } 121 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 182
171 app_list::AppListModel* AppListViewDelegate::GetModel() { 183 app_list::AppListModel* AppListViewDelegate::GetModel() {
172 return model_; 184 return model_;
173 } 185 }
174 186
175 app_list::SigninDelegate* AppListViewDelegate::GetSigninDelegate() { 187 app_list::SigninDelegate* AppListViewDelegate::GetSigninDelegate() {
176 return &signin_delegate_; 188 return &signin_delegate_;
177 } 189 }
178 190
179 app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() { 191 app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() {
180 return &speech_ui_; 192 return speech_ui_.get();
181 } 193 }
182 194
183 void AppListViewDelegate::GetShortcutPathForApp( 195 void AppListViewDelegate::GetShortcutPathForApp(
184 const std::string& app_id, 196 const std::string& app_id,
185 const base::Callback<void(const base::FilePath&)>& callback) { 197 const base::Callback<void(const base::FilePath&)>& callback) {
186 #if defined(OS_WIN) 198 #if defined(OS_WIN)
187 ExtensionService* service = profile_->GetExtensionService(); 199 ExtensionService* service = profile_->GetExtensionService();
188 DCHECK(service); 200 DCHECK(service);
189 const extensions::Extension* extension = 201 const extensions::Extension* extension =
190 service->GetInstalledExtension(app_id); 202 service->GetInstalledExtension(app_id);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 service->ToggleSpeechRecognition(); 315 service->ToggleSpeechRecognition();
304 } 316 }
305 317
306 void AppListViewDelegate::ShowForProfileByPath( 318 void AppListViewDelegate::ShowForProfileByPath(
307 const base::FilePath& profile_path) { 319 const base::FilePath& profile_path) {
308 controller_->ShowForProfileByPath(profile_path); 320 controller_->ShowForProfileByPath(profile_path);
309 } 321 }
310 322
311 void AppListViewDelegate::OnSpeechResult(const base::string16& result, 323 void AppListViewDelegate::OnSpeechResult(const base::string16& result,
312 bool is_final) { 324 bool is_final) {
313 speech_ui_.SetSpeechResult(result, is_final); 325 speech_ui_->SetSpeechResult(result, is_final);
314 if (is_final) { 326 if (is_final) {
315 auto_launch_timeout_ = base::TimeDelta::FromSeconds( 327 auto_launch_timeout_ = base::TimeDelta::FromSeconds(
316 kAutoLaunchDefaultTimeoutSec); 328 kAutoLaunchDefaultTimeoutSec);
317 model_->search_box()->SetText(result); 329 model_->search_box()->SetText(result);
318 } 330 }
319 } 331 }
320 332
321 void AppListViewDelegate::OnSpeechSoundLevelChanged(int16 level) { 333 void AppListViewDelegate::OnSpeechSoundLevelChanged(int16 level) {
322 speech_ui_.UpdateSoundLevel(level); 334 speech_ui_->UpdateSoundLevel(level);
323 } 335 }
324 336
325 void AppListViewDelegate::OnSpeechRecognitionStateChanged( 337 void AppListViewDelegate::OnSpeechRecognitionStateChanged(
326 app_list::SpeechRecognitionState new_state) { 338 app_list::SpeechRecognitionState new_state) {
327 speech_ui_.SetSpeechRecognitionState(new_state); 339 speech_ui_->SetSpeechRecognitionState(new_state);
328 } 340 }
329 341
330 void AppListViewDelegate::Observe( 342 void AppListViewDelegate::Observe(
331 int type, 343 int type,
332 const content::NotificationSource& source, 344 const content::NotificationSource& source,
333 const content::NotificationDetails& details) { 345 const content::NotificationDetails& details) {
334 OnProfileChanged(); 346 OnProfileChanged();
335 } 347 }
336 348
337 void AppListViewDelegate::OnProfileAdded(const base::FilePath& profile_path) { 349 void AppListViewDelegate::OnProfileAdded(const base::FilePath& profile_path) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 386
375 void AppListViewDelegate::AddObserver( 387 void AppListViewDelegate::AddObserver(
376 app_list::AppListViewDelegateObserver* observer) { 388 app_list::AppListViewDelegateObserver* observer) {
377 observers_.AddObserver(observer); 389 observers_.AddObserver(observer);
378 } 390 }
379 391
380 void AppListViewDelegate::RemoveObserver( 392 void AppListViewDelegate::RemoveObserver(
381 app_list::AppListViewDelegateObserver* observer) { 393 app_list::AppListViewDelegateObserver* observer) {
382 observers_.RemoveObserver(observer); 394 observers_.RemoveObserver(observer);
383 } 395 }
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