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

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: 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 "ui/app_list/search_box_model.h" 19 #include "ui/app_list/search_box_model.h"
19 20
20 namespace app_list { 21 namespace app_list {
21 22
22 SearchController::SearchController(Profile* profile, 23 SearchController::SearchController(Profile* profile,
23 SearchBoxModel* search_box, 24 SearchBoxModel* search_box,
24 AppListModel::SearchResults* results, 25 AppListModel::SearchResults* results,
25 AppListControllerDelegate* list_controller) 26 AppListControllerDelegate* list_controller)
26 : profile_(profile), 27 : profile_(profile),
27 search_box_(search_box), 28 search_box_(search_box),
28 list_controller_(list_controller), 29 list_controller_(list_controller),
29 dispatching_query_(false), 30 dispatching_query_(false),
30 mixer_(new Mixer(results)) { 31 mixer_(new Mixer(results)) {
31 Init(); 32 Init();
32 } 33 }
33 34
34 SearchController::~SearchController() {} 35 SearchController::~SearchController() {}
35 36
36 void SearchController::Init() { 37 void SearchController::Init() {
37 mixer_->Init(); 38 mixer_->Init();
38 39
39 AddProvider(Mixer::MAIN_GROUP, 40 AddProvider(Mixer::MAIN_GROUP, scoped_ptr<SearchProvider>(
James Cook 2013/05/20 14:39:34 I really like this approach of having a generic li
40 scoped_ptr<SearchProvider>( 41 new AppSearchProvider(profile_, list_controller_)).Pass());
41 new AppSearchProvider(profile_, list_controller_)).Pass()); 42 AddProvider(Mixer::OMNIBOX_GROUP, scoped_ptr<SearchProvider>(
42 AddProvider(Mixer::OMNIBOX_GROUP, 43 new OmniboxProvider(profile_)).Pass());
43 scoped_ptr<SearchProvider>(new OmniboxProvider(profile_)).Pass()); 44 AddProvider(Mixer::WEBSTORE_GROUP, scoped_ptr<SearchProvider>(
44 45 new WebstoreProvider(profile_)).Pass());
45 // TODO(xiyuan): Add providers.
46 } 46 }
47 47
48 void SearchController::Start() { 48 void SearchController::Start() {
49 Stop(); 49 Stop();
50 50
51 string16 query; 51 string16 query;
52 TrimWhitespace(search_box_->text(), TRIM_ALL, &query); 52 TrimWhitespace(search_box_->text(), TRIM_ALL, &query);
53 53
54 dispatching_query_ = true; 54 dispatching_query_ = true;
55 for (Providers::iterator it = providers_.begin(); 55 for (Providers::iterator it = providers_.begin();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 103
104 void SearchController::OnResultsChanged() { 104 void SearchController::OnResultsChanged() {
105 if (dispatching_query_) 105 if (dispatching_query_)
106 return; 106 return;
107 107
108 mixer_->MixAndPublish(); 108 mixer_->MixAndPublish();
109 } 109 }
110 110
111 } // namespace app_list 111 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698