| 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 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 results->SetString("value", value); | 79 results->SetString("value", value); |
| 80 list->Append(results.release()); | 80 list->Append(results.release()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void AddPair(base::ListValue* list, | 83 void AddPair(base::ListValue* list, |
| 84 const base::StringPiece& key, | 84 const base::StringPiece& key, |
| 85 const base::StringPiece& value) { | 85 const base::StringPiece& value) { |
| 86 AddPair16(list, UTF8ToUTF16(key), UTF8ToUTF16(value)); | 86 AddPair16(list, UTF8ToUTF16(key), UTF8ToUTF16(value)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void AddPairBool(base::ListValue* list, |
| 90 const base::StringPiece& key, |
| 91 bool value) { |
| 92 AddPair(list, key, value ? "Yes" : "No"); |
| 93 } |
| 94 |
| 89 // Generate an empty data-pair which acts as a line break. | 95 // Generate an empty data-pair which acts as a line break. |
| 90 void AddLineBreak(base::ListValue* list) { | 96 void AddLineBreak(base::ListValue* list) { |
| 91 AddPair(list, "", ""); | 97 AddPair(list, "", ""); |
| 92 } | 98 } |
| 93 | 99 |
| 94 void AddSharedModulePlatformsOnFileThread(base::ListValue* list, | 100 void AddSharedModulePlatformsOnFileThread(base::ListValue* list, |
| 95 const base::FilePath& path, | 101 const base::FilePath& path, |
| 96 base::Closure callback) { | 102 base::Closure callback) { |
| 97 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 103 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 98 | 104 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 plugin_prefs->IsPluginEnabled(info)) { | 270 plugin_prefs->IsPluginEnabled(info)) { |
| 265 nacl_enabled = "Yes"; | 271 nacl_enabled = "Yes"; |
| 266 } | 272 } |
| 267 } | 273 } |
| 268 #endif | 274 #endif |
| 269 | 275 |
| 270 AddPair(list, "NaCl Enabled", nacl_enabled); | 276 AddPair(list, "NaCl Enabled", nacl_enabled); |
| 271 | 277 |
| 272 HotwordService* hotword_service = | 278 HotwordService* hotword_service = |
| 273 HotwordServiceFactory::GetForProfile(profile_); | 279 HotwordServiceFactory::GetForProfile(profile_); |
| 274 AddPair(list, "Microphone Present", | 280 AddPairBool(list, "Microphone Present", |
| 275 hotword_service && hotword_service->microphone_available() ? "Yes" | 281 hotword_service && hotword_service->microphone_available()); |
| 276 : "No"); | |
| 277 | 282 |
| 278 std::string audio_capture = "No"; | 283 AddPairBool(list, "Audio Capture Allowed", |
| 279 if (profile_->GetPrefs()->GetBoolean(prefs::kAudioCaptureAllowed)) | 284 profile_->GetPrefs()->GetBoolean(prefs::kAudioCaptureAllowed)); |
| 280 audio_capture = "Yes"; | |
| 281 AddPair(list, "Audio Capture Allowed", audio_capture); | |
| 282 | 285 |
| 283 AddLineBreak(list); | 286 AddLineBreak(list); |
| 284 } | 287 } |
| 285 | 288 |
| 286 // Adds information regarding languages to the list. | 289 // Adds information regarding languages to the list. |
| 287 void AddLanguageInfo(base::ListValue* list) { | 290 void AddLanguageInfo(base::ListValue* list) { |
| 288 std::string locale = | 291 std::string locale = |
| 289 #if defined(OS_CHROMEOS) | 292 #if defined(OS_CHROMEOS) |
| 290 // On ChromeOS locale is per-profile. | 293 // On ChromeOS locale is per-profile. |
| 291 profile_->GetPrefs()->GetString(prefs::kApplicationLocale); | 294 profile_->GetPrefs()->GetString(prefs::kApplicationLocale); |
| 292 #else | 295 #else |
| 293 g_browser_process->GetApplicationLocale(); | 296 g_browser_process->GetApplicationLocale(); |
| 294 #endif | 297 #endif |
| 295 AddPair(list, "Current Language", locale); | 298 AddPair(list, "Current Language", locale); |
| 296 | 299 |
| 297 AddPair(list, | 300 AddPair(list, |
| 298 "Hotword Previous Language", | 301 "Hotword Previous Language", |
| 299 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); | 302 profile_->GetPrefs()->GetString(prefs::kHotwordPreviousLanguage)); |
| 300 | 303 |
| 301 AddLineBreak(list); | 304 AddLineBreak(list); |
| 302 } | 305 } |
| 303 | 306 |
| 304 // Adds information specific to the hotword configuration to the list. | 307 // Adds information specific to the hotword configuration to the list. |
| 305 void AddHotwordInfo(base::ListValue* list) { | 308 void AddHotwordInfo(base::ListValue* list) { |
| 306 HotwordService* hotword_service = | 309 HotwordService* hotword_service = |
| 307 HotwordServiceFactory::GetForProfile(profile_); | 310 HotwordServiceFactory::GetForProfile(profile_); |
| 308 std::string hotword_allowed = "No"; | 311 AddPairBool(list, "Hotword Module Installable", |
| 309 if (hotword_service && hotword_service->IsHotwordAllowed()) | 312 hotword_service && hotword_service->IsHotwordAllowed()); |
| 310 hotword_allowed = "Yes"; | |
| 311 AddPair(list, "Hotword Module Installable", hotword_allowed); | |
| 312 | 313 |
| 313 std::string search_enabled = "No"; | 314 AddPairBool(list, "Hotword Search Enabled", |
| 314 if (profile_->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled)) | 315 profile_->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled)); |
| 315 search_enabled = "Yes"; | |
| 316 AddPair(list, "Hotword Search Enabled", search_enabled); | |
| 317 | 316 |
| 318 std::string always_on_search_enabled = "No"; | 317 AddPairBool( |
| 319 if (profile_->GetPrefs()->GetBoolean(prefs::kHotwordAlwaysOnSearchEnabled)) | 318 list, "Always-on Hotword Search Enabled", |
| 320 always_on_search_enabled = "Yes"; | 319 profile_->GetPrefs()->GetBoolean(prefs::kHotwordAlwaysOnSearchEnabled)); |
| 321 AddPair(list, "Always-on Hotword Search Enabled", always_on_search_enabled); | |
| 322 | 320 |
| 323 std::string audio_logging_enabled = "No"; | 321 AddPairBool(list, "Hotword Audio Logging Enabled", |
| 324 if (hotword_service && hotword_service->IsOptedIntoAudioLogging()) | 322 hotword_service && hotword_service->IsOptedIntoAudioLogging()); |
| 325 audio_logging_enabled = "Yes"; | |
| 326 AddPair(list, "Hotword Audio Logging Enabled", audio_logging_enabled); | |
| 327 | 323 |
| 328 AddLineBreak(list); | 324 AddLineBreak(list); |
| 329 } | 325 } |
| 330 | 326 |
| 331 // Adds information specific to an extension to the list. | 327 // Adds information specific to an extension to the list. |
| 332 void AddExtensionInfo(const std::string& extension_id, | 328 void AddExtensionInfo(const std::string& extension_id, |
| 333 const std::string& name_prefix, | 329 const std::string& name_prefix, |
| 334 base::ListValue* list) { | 330 base::ListValue* list) { |
| 335 DCHECK(!name_prefix.empty()); | 331 DCHECK(!name_prefix.empty()); |
| 336 std::string version("undefined"); | 332 std::string version("undefined"); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 VoiceSearchUI::VoiceSearchUI(content::WebUI* web_ui) | 434 VoiceSearchUI::VoiceSearchUI(content::WebUI* web_ui) |
| 439 : content::WebUIController(web_ui) { | 435 : content::WebUIController(web_ui) { |
| 440 Profile* profile = Profile::FromWebUI(web_ui); | 436 Profile* profile = Profile::FromWebUI(web_ui); |
| 441 web_ui->AddMessageHandler(new VoiceSearchDomHandler(profile)); | 437 web_ui->AddMessageHandler(new VoiceSearchDomHandler(profile)); |
| 442 | 438 |
| 443 // Set up the about:voicesearch source. | 439 // Set up the about:voicesearch source. |
| 444 content::WebUIDataSource::Add(profile, CreateVoiceSearchUiHtmlSource()); | 440 content::WebUIDataSource::Add(profile, CreateVoiceSearchUiHtmlSource()); |
| 445 } | 441 } |
| 446 | 442 |
| 447 VoiceSearchUI::~VoiceSearchUI() {} | 443 VoiceSearchUI::~VoiceSearchUI() {} |
| OLD | NEW |