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

Unified Diff: chrome/browser/ui/app_list/search/webstore_search_fetcher.h

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/search/webstore_search_fetcher.h
diff --git a/chrome/browser/ui/app_list/search/webstore_search_fetcher.h b/chrome/browser/ui/app_list/search/webstore_search_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..442c196ca18a65af07b2fea4a1460722d6988455
--- /dev/null
+++ b/chrome/browser/ui/app_list/search/webstore_search_fetcher.h
@@ -0,0 +1,62 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_SEARCH_FETCHER_H_
+#define CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_SEARCH_FETCHER_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "net/url_request/url_fetcher_delegate.h"
+
+namespace base {
+class DictionaryValue;
+class Value;
+}
+
+namespace net {
+class URLFetcher;
+class URLRequestContextGetter;
+}
+
+namespace app_list {
+
+// A class to fetch web store search result.
+class WebstoreSearchFetcher : public net::URLFetcherDelegate {
+ public:
+ // Callback to pass back the parsed json dictionary returned from the server.
+ // Invoked with NULL if there is an error.
+ typedef base::Callback<void(scoped_ptr<base::DictionaryValue>)> Callback;
+
+ WebstoreSearchFetcher(const Callback& callback,
+ net::URLRequestContextGetter* context_getter);
+ virtual ~WebstoreSearchFetcher();
+
+ // Starts to fetch results for the given |query| and the language code |hl|.
+ void Start(const std::string& query, const std::string& hl);
+ void Stop();
+
+ private:
+ // Callbacks for SafeJsonParser.
+ void OnJsonParseSuccess(scoped_ptr<base::Value> parsed_json);
+ void OnJsonParseError(const std::string& error);
+
+ // net::URLFetcherDelegate overrides:
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
+ Callback callback_;
+ net::URLRequestContextGetter* context_getter_;
+
+ scoped_ptr<net::URLFetcher> fetcher_;
+ base::WeakPtrFactory<WebstoreSearchFetcher> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebstoreSearchFetcher);
+};
+
+} // namespace app_list
+
+#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_WEBSTORE_SEARCH_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698