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