Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / app_list / search / search_resource_manager.cc
blob439c94ac0df3eb268e95aaa72e023094c5bcd3d5
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/app_list/search/search_resource_manager.h"
7 #include "chrome/browser/ui/app_list/start_page_service.h"
8 #include "grit/components_scaled_resources.h"
9 #include "grit/generated_resources.h"
10 #include "grit/theme_resources.h"
11 #include "ui/app_list/search_box_model.h"
12 #include "ui/app_list/speech_ui_model.h"
13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h"
16 namespace app_list {
18 namespace {
20 scoped_ptr<SearchBoxModel::SpeechButtonProperty> CreateNewProperty(
21 SpeechRecognitionState state) {
22 if (state == SPEECH_RECOGNITION_OFF)
23 return nullptr;
25 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
26 return make_scoped_ptr(new SearchBoxModel::SpeechButtonProperty(
27 *bundle.GetImageSkiaNamed(IDR_APP_LIST_MIC_HOTWORD_ON),
28 l10n_util::GetStringUTF16(IDS_APP_LIST_HOTWORD_LISTENING),
29 *bundle.GetImageSkiaNamed(IDR_APP_LIST_MIC_HOTWORD_OFF),
30 l10n_util::GetStringUTF16(IDS_APP_LIST_START_SPEECH_RECOGNITION),
31 l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH)));
34 } // namespace
36 SearchResourceManager::SearchResourceManager(Profile* profile,
37 SearchBoxModel* search_box,
38 SpeechUIModel* speech_ui)
39 : search_box_(search_box),
40 speech_ui_(speech_ui) {
41 speech_ui_->AddObserver(this);
43 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
44 search_box_->SetIcon(*bundle.GetImageSkiaNamed(IDR_OMNIBOX_SEARCH));
45 search_box_->SetAccessibleName(
46 l10n_util::GetStringUTF16(IDS_SEARCH_BOX_HINT));
47 OnSpeechRecognitionStateChanged(speech_ui_->state());
50 SearchResourceManager::~SearchResourceManager() {
51 speech_ui_->RemoveObserver(this);
54 void SearchResourceManager::OnSpeechRecognitionStateChanged(
55 SpeechRecognitionState new_state) {
56 search_box_->SetHintText(l10n_util::GetStringUTF16(
57 (new_state == SPEECH_RECOGNITION_HOTWORD_LISTENING) ?
58 IDS_SEARCH_BOX_HOTWORD_HINT : IDS_SEARCH_BOX_HINT));
59 search_box_->SetSpeechRecognitionButton(CreateNewProperty(new_state));
62 } // namespace app_list