OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/webui/voice_search_ui.h" | 5 #include "chrome/browser/ui/webui/voice_search_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // Callback for the "requestVoiceSearchInfo" message. No arguments. | 156 // Callback for the "requestVoiceSearchInfo" message. No arguments. |
157 void HandleRequestVoiceSearchInfo(const base::ListValue* args) { | 157 void HandleRequestVoiceSearchInfo(const base::ListValue* args) { |
158 PopulatePageInformation(); | 158 PopulatePageInformation(); |
159 } | 159 } |
160 | 160 |
161 void ReturnVoiceSearchInfo(std::unique_ptr<base::ListValue> info) { | 161 void ReturnVoiceSearchInfo(std::unique_ptr<base::ListValue> info) { |
162 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 162 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
163 DCHECK(info); | 163 DCHECK(info); |
164 base::DictionaryValue voiceSearchInfo; | 164 base::DictionaryValue voiceSearchInfo; |
165 voiceSearchInfo.Set("voiceSearchInfo", info.release()); | 165 voiceSearchInfo.Set("voiceSearchInfo", info.release()); |
166 web_ui()->CallJavascriptFunction("returnVoiceSearchInfo", voiceSearchInfo); | 166 web_ui()->CallJavascriptFunctionUnsafe("returnVoiceSearchInfo", |
| 167 voiceSearchInfo); |
167 } | 168 } |
168 | 169 |
169 // Fill in the data to be displayed on the page. | 170 // Fill in the data to be displayed on the page. |
170 void PopulatePageInformation() { | 171 void PopulatePageInformation() { |
171 // Store Key-Value pairs of about-information. | 172 // Store Key-Value pairs of about-information. |
172 std::unique_ptr<base::ListValue> list(new base::ListValue()); | 173 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
173 | 174 |
174 // Populate information. | 175 // Populate information. |
175 AddOperatingSystemInfo(list.get()); | 176 AddOperatingSystemInfo(list.get()); |
176 AddAudioInfo(list.get()); | 177 AddAudioInfo(list.get()); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 VoiceSearchUI::VoiceSearchUI(content::WebUI* web_ui) | 435 VoiceSearchUI::VoiceSearchUI(content::WebUI* web_ui) |
435 : content::WebUIController(web_ui) { | 436 : content::WebUIController(web_ui) { |
436 Profile* profile = Profile::FromWebUI(web_ui); | 437 Profile* profile = Profile::FromWebUI(web_ui); |
437 web_ui->AddMessageHandler(new VoiceSearchDomHandler(profile)); | 438 web_ui->AddMessageHandler(new VoiceSearchDomHandler(profile)); |
438 | 439 |
439 // Set up the about:voicesearch source. | 440 // Set up the about:voicesearch source. |
440 content::WebUIDataSource::Add(profile, CreateVoiceSearchUiHtmlSource()); | 441 content::WebUIDataSource::Add(profile, CreateVoiceSearchUiHtmlSource()); |
441 } | 442 } |
442 | 443 |
443 VoiceSearchUI::~VoiceSearchUI() {} | 444 VoiceSearchUI::~VoiceSearchUI() {} |
OLD | NEW |