OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_controller.h" | 5 #include "chrome/browser/ui/app_list/search/search_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/app_list/search/app_search_provider.h" | 17 #include "chrome/browser/ui/app_list/search/app_search_provider.h" |
18 #include "chrome/browser/ui/app_list/search/chrome_search_result.h" | 18 #include "chrome/browser/ui/app_list/search/chrome_search_result.h" |
19 #include "chrome/browser/ui/app_list/search/history.h" | 19 #include "chrome/browser/ui/app_list/search/history.h" |
20 #include "chrome/browser/ui/app_list/search/history_factory.h" | 20 #include "chrome/browser/ui/app_list/search/history_factory.h" |
21 #include "chrome/browser/ui/app_list/search/omnibox_provider.h" | 21 #include "chrome/browser/ui/app_list/search/omnibox_provider.h" |
22 #include "chrome/browser/ui/app_list/search/people/people_provider.h" | 22 #include "chrome/browser/ui/app_list/search/people/people_provider.h" |
23 #include "chrome/browser/ui/app_list/search/search_provider.h" | 23 #include "chrome/browser/ui/app_list/search/search_provider.h" |
24 #include "chrome/browser/ui/app_list/search/webstore/webstore_provider.h" | 24 #include "chrome/browser/ui/app_list/search/webstore/webstore_provider.h" |
| 25 #include "chrome/browser/ui/app_list/start_page_service.h" |
25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
26 #include "content/public/browser/user_metrics.h" | 27 #include "content/public/browser/user_metrics.h" |
27 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
28 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
29 #include "ui/app_list/search_box_model.h" | 30 #include "ui/app_list/search_box_model.h" |
30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
32 | 33 |
33 namespace { | 34 namespace { |
34 const char kAppListSearchResultOpenTypeHistogram[] = | 35 const char kAppListSearchResultOpenTypeHistogram[] = |
(...skipping 11 matching lines...) Expand all Loading... |
46 list_controller_(list_controller), | 47 list_controller_(list_controller), |
47 dispatching_query_(false), | 48 dispatching_query_(false), |
48 mixer_(new Mixer(results)), | 49 mixer_(new Mixer(results)), |
49 history_(HistoryFactory::GetForBrowserContext(profile)) { | 50 history_(HistoryFactory::GetForBrowserContext(profile)) { |
50 Init(); | 51 Init(); |
51 } | 52 } |
52 | 53 |
53 SearchController::~SearchController() {} | 54 SearchController::~SearchController() {} |
54 | 55 |
55 void SearchController::Init() { | 56 void SearchController::Init() { |
| 57 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
56 search_box_->SetHintText( | 58 search_box_->SetHintText( |
57 l10n_util::GetStringUTF16(IDS_SEARCH_BOX_HINT)); | 59 l10n_util::GetStringUTF16(IDS_SEARCH_BOX_HINT)); |
58 search_box_->SetIcon(*ui::ResourceBundle::GetSharedInstance(). | 60 search_box_->SetIcon(*bundle.GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)); |
59 GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)); | 61 if (StartPageService::Get(profile_)) { |
| 62 search_box_->SetRightButton(scoped_ptr<SearchBoxModel::RightButtonProperty>( |
| 63 new SearchBoxModel::RightButtonProperty( |
| 64 // Right now provides the same image for both state. |
| 65 // TODO(mukai, jennschen): Replace them by the real images. |
| 66 *bundle.GetImageSkiaNamed(IDR_OMNIBOX_MIC_SEARCH), |
| 67 *bundle.GetImageSkiaNamed(IDR_OMNIBOX_MIC_SEARCH), |
| 68 l10n_util::GetStringUTF16(IDS_APP_LIST_START_SPEECH_RECOGNITION), |
| 69 l10n_util::GetStringUTF16(IDS_APP_LIST_STOP_SPEECH_RECOGNITION)))); |
| 70 } |
60 | 71 |
61 mixer_->Init(); | 72 mixer_->Init(); |
62 | 73 |
63 AddProvider(Mixer::MAIN_GROUP, scoped_ptr<SearchProvider>( | 74 AddProvider(Mixer::MAIN_GROUP, scoped_ptr<SearchProvider>( |
64 new AppSearchProvider(profile_, list_controller_)).Pass()); | 75 new AppSearchProvider(profile_, list_controller_)).Pass()); |
65 AddProvider(Mixer::OMNIBOX_GROUP, scoped_ptr<SearchProvider>( | 76 AddProvider(Mixer::OMNIBOX_GROUP, scoped_ptr<SearchProvider>( |
66 new OmniboxProvider(profile_)).Pass()); | 77 new OmniboxProvider(profile_)).Pass()); |
67 AddProvider(Mixer::WEBSTORE_GROUP, scoped_ptr<SearchProvider>( | 78 AddProvider(Mixer::WEBSTORE_GROUP, scoped_ptr<SearchProvider>( |
68 new WebstoreProvider(profile_, list_controller_)).Pass()); | 79 new WebstoreProvider(profile_, list_controller_)).Pass()); |
69 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 80 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 KnownResults known_results; | 159 KnownResults known_results; |
149 if (history_ && history_->IsReady()) { | 160 if (history_ && history_->IsReady()) { |
150 history_->GetKnownResults(UTF16ToUTF8(search_box_->text())) | 161 history_->GetKnownResults(UTF16ToUTF8(search_box_->text())) |
151 ->swap(known_results); | 162 ->swap(known_results); |
152 } | 163 } |
153 | 164 |
154 mixer_->MixAndPublish(known_results); | 165 mixer_->MixAndPublish(known_results); |
155 } | 166 } |
156 | 167 |
157 } // namespace app_list | 168 } // namespace app_list |
OLD | NEW |