Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/browser/ui/app_list/search/search_controller.cc

Issue 15342003: app_list: Add web store search. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase and address nits in #3 Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string_util.h" 13 #include "base/string_util.h"
14 #include "chrome/browser/ui/app_list/search/app_search_provider.h" 14 #include "chrome/browser/ui/app_list/search/app_search_provider.h"
15 #include "chrome/browser/ui/app_list/search/chrome_search_result.h" 15 #include "chrome/browser/ui/app_list/search/chrome_search_result.h"
16 #include "chrome/browser/ui/app_list/search/omnibox_provider.h" 16 #include "chrome/browser/ui/app_list/search/omnibox_provider.h"
17 #include "chrome/browser/ui/app_list/search/search_provider.h" 17 #include "chrome/browser/ui/app_list/search/search_provider.h"
18 #include "chrome/browser/ui/app_list/search/webstore_provider.h"
18 #include "content/public/browser/user_metrics.h" 19 #include "content/public/browser/user_metrics.h"
19 #include "ui/app_list/search_box_model.h" 20 #include "ui/app_list/search_box_model.h"
20 21
21 namespace app_list { 22 namespace app_list {
22 23
23 SearchController::SearchController(Profile* profile, 24 SearchController::SearchController(Profile* profile,
24 SearchBoxModel* search_box, 25 SearchBoxModel* search_box,
25 AppListModel::SearchResults* results, 26 AppListModel::SearchResults* results,
26 AppListControllerDelegate* list_controller) 27 AppListControllerDelegate* list_controller)
27 : profile_(profile), 28 : profile_(profile),
28 search_box_(search_box), 29 search_box_(search_box),
29 list_controller_(list_controller), 30 list_controller_(list_controller),
30 dispatching_query_(false), 31 dispatching_query_(false),
31 mixer_(new Mixer(results)) { 32 mixer_(new Mixer(results)) {
32 Init(); 33 Init();
33 } 34 }
34 35
35 SearchController::~SearchController() {} 36 SearchController::~SearchController() {}
36 37
37 void SearchController::Init() { 38 void SearchController::Init() {
38 mixer_->Init(); 39 mixer_->Init();
39 40
40 AddProvider(Mixer::MAIN_GROUP, 41 AddProvider(Mixer::MAIN_GROUP, scoped_ptr<SearchProvider>(
41 scoped_ptr<SearchProvider>( 42 new AppSearchProvider(profile_, list_controller_)).Pass());
42 new AppSearchProvider(profile_, list_controller_)).Pass()); 43 AddProvider(Mixer::OMNIBOX_GROUP, scoped_ptr<SearchProvider>(
43 AddProvider(Mixer::OMNIBOX_GROUP, 44 new OmniboxProvider(profile_)).Pass());
44 scoped_ptr<SearchProvider>(new OmniboxProvider(profile_)).Pass()); 45 AddProvider(Mixer::WEBSTORE_GROUP, scoped_ptr<SearchProvider>(
45 46 new WebstoreProvider(profile_)).Pass());
46 // TODO(xiyuan): Add providers.
47 } 47 }
48 48
49 void SearchController::Start() { 49 void SearchController::Start() {
50 Stop(); 50 Stop();
51 51
52 string16 query; 52 string16 query;
53 TrimWhitespace(search_box_->text(), TRIM_ALL, &query); 53 TrimWhitespace(search_box_->text(), TRIM_ALL, &query);
54 54
55 dispatching_query_ = true; 55 dispatching_query_ = true;
56 for (Providers::iterator it = providers_.begin(); 56 for (Providers::iterator it = providers_.begin();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 void SearchController::OnResultsChanged() { 108 void SearchController::OnResultsChanged() {
109 if (dispatching_query_) 109 if (dispatching_query_)
110 return; 110 return;
111 111
112 mixer_->MixAndPublish(); 112 mixer_->MixAndPublish();
113 } 113 }
114 114
115 } // namespace app_list 115 } // namespace app_list
OLDNEW
« no previous file with comments | « chrome/browser/safe_json_parser.cc ('k') | chrome/browser/ui/app_list/search/search_webstore_result.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698