OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/start_page_service.h" | 5 #include "chrome/browser/ui/app_list/start_page_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 observers_.RemoveObserver(observer); | 138 observers_.RemoveObserver(observer); |
139 } | 139 } |
140 | 140 |
141 void StartPageService::ToggleSpeechRecognition() { | 141 void StartPageService::ToggleSpeechRecognition() { |
142 speech_button_toggled_manually_ = true; | 142 speech_button_toggled_manually_ = true; |
143 contents_->GetWebUI()->CallJavascriptFunction( | 143 contents_->GetWebUI()->CallJavascriptFunction( |
144 "appList.startPage.toggleSpeechRecognition"); | 144 "appList.startPage.toggleSpeechRecognition"); |
145 } | 145 } |
146 | 146 |
147 content::WebContents* StartPageService::GetStartPageContents() { | 147 content::WebContents* StartPageService::GetStartPageContents() { |
148 return CommandLine::ForCurrentProcess()->HasSwitch( | 148 return (app_list::switches::IsExperimentalAppListEnabled() || |
149 ::switches::kShowAppListStartPage) ? contents_.get() : NULL; | 149 app_list::switches::IsExperimentalAppListEnabled()) |
xiyuan
2014/03/14 17:00:54
A || A is strange. We should just keep one.
calamity
2014/05/07 06:11:52
Done.
| |
150 ? contents_.get() | |
151 : NULL; | |
150 } | 152 } |
151 | 153 |
152 content::WebContents* StartPageService::GetSpeechRecognitionContents() { | 154 content::WebContents* StartPageService::GetSpeechRecognitionContents() { |
155 return app_list::switches::IsVoiceSearchEnabled() ? contents_.get() : NULL; | |
156 } | |
157 | |
158 content::WebContents* StartPageService::GetSpeechRecognitionContents() { | |
xiyuan
2014/03/14 17:00:54
Unintended copy-n-paste?
calamity
2014/05/07 06:11:52
Done.
| |
153 return app_list::switches::IsVoiceSearchEnabled() ? contents_.get() : NULL; | 159 return app_list::switches::IsVoiceSearchEnabled() ? contents_.get() : NULL; |
154 } | 160 } |
155 | 161 |
156 void StartPageService::OnSpeechResult( | 162 void StartPageService::OnSpeechResult( |
157 const base::string16& query, bool is_final) { | 163 const base::string16& query, bool is_final) { |
158 if (is_final) { | 164 if (is_final) { |
159 speech_result_obtained_ = true; | 165 speech_result_obtained_ = true; |
160 RecordAction(UserMetricsAction("AppList_SearchedBySpeech")); | 166 RecordAction(UserMetricsAction("AppList_SearchedBySpeech")); |
161 } | 167 } |
162 FOR_EACH_OBSERVER(StartPageObserver, | 168 FOR_EACH_OBSERVER(StartPageObserver, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 FOR_EACH_OBSERVER(StartPageObserver, | 203 FOR_EACH_OBSERVER(StartPageObserver, |
198 observers_, | 204 observers_, |
199 OnSpeechRecognitionStateChanged(new_state)); | 205 OnSpeechRecognitionStateChanged(new_state)); |
200 } | 206 } |
201 | 207 |
202 void StartPageService::Shutdown() { | 208 void StartPageService::Shutdown() { |
203 contents_.reset(); | 209 contents_.reset(); |
204 } | 210 } |
205 | 211 |
206 } // namespace app_list | 212 } // namespace app_list |
OLD | NEW |