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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_WEBSTORE_PROVIDER_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_WEBSTORE_PROVIDER_H_ 7 8 #include "base/basictypes.h" 9 #include "base/callback_forward.h" 10 #include "base/memory/scoped_ptr.h" 11 #include "chrome/browser/ui/app_list/search/common/webservice_search_provider.h" 12 13 class AppListControllerDelegate; 14 15 namespace base { 16 class DictionaryValue; 17 } 18 19 namespace app_list { 20 21 namespace test { 22 class WebstoreProviderTest; 23 } 24 25 class ChromeSearchResult; 26 class JSONResponseFetcher; 27 28 // WebstoreProvider fetches search results from the web store server. 29 // A "Search in web store" result will be returned if the server does not 30 // return any results. 31 class WebstoreProvider : public WebserviceSearchProvider{ 32 public: 33 WebstoreProvider(Profile* profile, AppListControllerDelegate* controller); 34 virtual ~WebstoreProvider(); 35 36 // SearchProvider overrides: 37 virtual void Start(const base::string16& query) OVERRIDE; 38 virtual void Stop() OVERRIDE; 39 40 private: 41 friend class app_list::test::WebstoreProviderTest; 42 43 // Start the search request with |query_|. 44 void StartQuery(); 45 46 void OnWebstoreSearchFetched(scoped_ptr<base::DictionaryValue> json); 47 void ProcessWebstoreSearchResults(const base::DictionaryValue* json); 48 scoped_ptr<ChromeSearchResult> CreateResult( 49 const base::DictionaryValue& dict); 50 51 void set_webstore_search_fetched_callback(const base::Closure& callback) { 52 webstore_search_fetched_callback_ = callback; 53 } 54 55 AppListControllerDelegate* controller_; 56 scoped_ptr<JSONResponseFetcher> webstore_search_; 57 base::Closure webstore_search_fetched_callback_; 58 59 // The current query. 60 std::string query_; 61 62 DISALLOW_COPY_AND_ASSIGN(WebstoreProvider); 63 }; 64 65 } // namespace app_list 66 67 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_WEBSTORE_PROVIDER_H_ 68