| 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/app_list/search/search_resource_manager.h" | 5 #include "chrome/browser/ui/app_list/search/search_resource_manager.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/ui/app_list/start_page_service.h" | 8 #include "chrome/browser/ui/app_list/start_page_service.h" |
| 9 #include "grit/components_scaled_resources.h" | 9 #include "grit/components_scaled_resources.h" |
| 10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| 11 #include "grit/theme_resources.h" | 11 #include "grit/theme_resources.h" |
| 12 #include "ui/app_list/search_box_model.h" | 12 #include "ui/app_list/search_box_model.h" |
| 13 #include "ui/app_list/speech_ui_model.h" | 13 #include "ui/app_list/speech_ui_model.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 16 | 16 |
| 17 namespace app_list { | 17 namespace app_list { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 std::unique_ptr<SearchBoxModel::SpeechButtonProperty> CreateNewProperty( | 21 std::unique_ptr<SearchBoxModel::SpeechButtonProperty> CreateNewProperty( |
| 22 SpeechRecognitionState state) { | 22 SpeechRecognitionState state) { |
| 23 if (state == SPEECH_RECOGNITION_OFF) | 23 if (state == SPEECH_RECOGNITION_OFF) |
| 24 return nullptr; | 24 return nullptr; |
| 25 | 25 |
| 26 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 26 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 27 return base::WrapUnique(new SearchBoxModel::SpeechButtonProperty( | 27 return base::MakeUnique<SearchBoxModel::SpeechButtonProperty>( |
| 28 *bundle.GetImageSkiaNamed(IDR_APP_LIST_MIC_HOTWORD_ON), | 28 *bundle.GetImageSkiaNamed(IDR_APP_LIST_MIC_HOTWORD_ON), |
| 29 l10n_util::GetStringUTF16(IDS_APP_LIST_HOTWORD_LISTENING), | 29 l10n_util::GetStringUTF16(IDS_APP_LIST_HOTWORD_LISTENING), |
| 30 *bundle.GetImageSkiaNamed(IDR_APP_LIST_MIC_HOTWORD_OFF), | 30 *bundle.GetImageSkiaNamed(IDR_APP_LIST_MIC_HOTWORD_OFF), |
| 31 l10n_util::GetStringUTF16(IDS_APP_LIST_START_SPEECH_RECOGNITION), | 31 l10n_util::GetStringUTF16(IDS_APP_LIST_START_SPEECH_RECOGNITION), |
| 32 l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH))); | 32 l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 SearchResourceManager::SearchResourceManager(Profile* profile, | 37 SearchResourceManager::SearchResourceManager(Profile* profile, |
| 38 SearchBoxModel* search_box, | 38 SearchBoxModel* search_box, |
| 39 SpeechUIModel* speech_ui) | 39 SpeechUIModel* speech_ui) |
| 40 : search_box_(search_box), | 40 : search_box_(search_box), |
| 41 speech_ui_(speech_ui) { | 41 speech_ui_(speech_ui) { |
| 42 speech_ui_->AddObserver(this); | 42 speech_ui_->AddObserver(this); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 54 | 54 |
| 55 void SearchResourceManager::OnSpeechRecognitionStateChanged( | 55 void SearchResourceManager::OnSpeechRecognitionStateChanged( |
| 56 SpeechRecognitionState new_state) { | 56 SpeechRecognitionState new_state) { |
| 57 search_box_->SetHintText(l10n_util::GetStringUTF16( | 57 search_box_->SetHintText(l10n_util::GetStringUTF16( |
| 58 (new_state == SPEECH_RECOGNITION_HOTWORD_LISTENING) ? | 58 (new_state == SPEECH_RECOGNITION_HOTWORD_LISTENING) ? |
| 59 IDS_SEARCH_BOX_HOTWORD_HINT : IDS_SEARCH_BOX_HINT)); | 59 IDS_SEARCH_BOX_HOTWORD_HINT : IDS_SEARCH_BOX_HINT)); |
| 60 search_box_->SetSpeechRecognitionButton(CreateNewProperty(new_state)); | 60 search_box_->SetSpeechRecognitionButton(CreateNewProperty(new_state)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace app_list | 63 } // namespace app_list |
| OLD | NEW |