| 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/extensions/api/hotword_private/hotword_private_api.h" | 5 #include "chrome/browser/extensions/api/hotword_private/hotword_private_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | |
| 10 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 11 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/search/hotword_audio_history_handler.h" | 13 #include "chrome/browser/search/hotword_audio_history_handler.h" |
| 14 #include "chrome/browser/search/hotword_client.h" | 14 #include "chrome/browser/search/hotword_client.h" |
| 15 #include "chrome/browser/search/hotword_service.h" | 15 #include "chrome/browser/search/hotword_service.h" |
| 16 #include "chrome/browser/search/hotword_service_factory.h" | 16 #include "chrome/browser/search/hotword_service_factory.h" |
| 17 #include "chrome/browser/ui/app_list/app_list_service.h" | 17 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
| 21 #include "content/public/browser/speech_recognition_session_preamble.h" | 21 #include "content/public/browser/speech_recognition_session_preamble.h" |
| 22 #include "extensions/browser/event_router.h" | 22 #include "extensions/browser/event_router.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/webui/web_ui_util.h" |
| 24 | 25 |
| 25 namespace extensions { | 26 namespace extensions { |
| 26 | 27 |
| 27 namespace hotword_private_constants { | 28 namespace hotword_private_constants { |
| 28 const char kHotwordServiceUnavailable[] = "Hotword Service is unavailable."; | 29 const char kHotwordServiceUnavailable[] = "Hotword Service is unavailable."; |
| 29 const char kHotwordEventServiceUnavailable[] = | 30 const char kHotwordEventServiceUnavailable[] = |
| 30 "Hotword Private Event Service is unavailable."; | 31 "Hotword Private Event Service is unavailable."; |
| 31 } // hotword_private_constants | 32 } // hotword_private_constants |
| 32 | 33 |
| 33 namespace OnEnabledChanged = | 34 namespace OnEnabledChanged = |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 "finishedAudioHistory", | 379 "finishedAudioHistory", |
| 379 l10n_util::GetStringUTF16( | 380 l10n_util::GetStringUTF16( |
| 380 IDS_HOTWORD_OPT_IN_FINISHED_AUDIO_HISTORY)); | 381 IDS_HOTWORD_OPT_IN_FINISHED_AUDIO_HISTORY)); |
| 381 localized_strings->SetString( | 382 localized_strings->SetString( |
| 382 "finish", | 383 "finish", |
| 383 l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_FINISH)); | 384 l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_FINISH)); |
| 384 localized_strings->SetString( | 385 localized_strings->SetString( |
| 385 "finishedWait", | 386 "finishedWait", |
| 386 l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_FINISHED_WAIT)); | 387 l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_FINISHED_WAIT)); |
| 387 | 388 |
| 388 localized_strings->SetString("textdirection", | 389 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
| 389 base::i18n::IsRTL() ? "rtl" : "ltr"); | 390 webui::SetLoadTimeDataDefaults(app_locale, localized_strings); |
| 390 | 391 |
| 391 SetResult(localized_strings); | 392 SetResult(localized_strings); |
| 392 return true; | 393 return true; |
| 393 } | 394 } |
| 394 | 395 |
| 395 bool HotwordPrivateSetAudioHistoryEnabledFunction::RunAsync() { | 396 bool HotwordPrivateSetAudioHistoryEnabledFunction::RunAsync() { |
| 396 scoped_ptr<api::hotword_private::SetAudioHistoryEnabled::Params> params( | 397 scoped_ptr<api::hotword_private::SetAudioHistoryEnabled::Params> params( |
| 397 api::hotword_private::SetAudioHistoryEnabled::Params::Create(*args_)); | 398 api::hotword_private::SetAudioHistoryEnabled::Params::Create(*args_)); |
| 398 EXTENSION_FUNCTION_VALIDATE(params.get()); | 399 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 399 | 400 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 void HotwordPrivateGetAudioHistoryEnabledFunction::SetResultAndSendResponse( | 440 void HotwordPrivateGetAudioHistoryEnabledFunction::SetResultAndSendResponse( |
| 440 bool success, bool new_enabled_value) { | 441 bool success, bool new_enabled_value) { |
| 441 api::hotword_private::AudioHistoryState result; | 442 api::hotword_private::AudioHistoryState result; |
| 442 result.success = success; | 443 result.success = success; |
| 443 result.enabled = new_enabled_value; | 444 result.enabled = new_enabled_value; |
| 444 SetResult(result.ToValue().release()); | 445 SetResult(result.ToValue().release()); |
| 445 SendResponse(true); | 446 SendResponse(true); |
| 446 } | 447 } |
| 447 | 448 |
| 448 } // namespace extensions | 449 } // namespace extensions |
| OLD | NEW |