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

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: 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..e8f9ede7a431e50d97c2e57fd47b7bd6cbc8610e
--- /dev/null
+++ b/chrome/browser/ui/app_list/search/webstore_search_fetcher.h
@@ -0,0 +1,61 @@
+// 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();
+
+ void Start(const std::string& query, const std::string& hl);
James Cook 2013/05/20 14:39:34 What is "hl"?
xiyuan 2013/05/20 16:56:31 hl = host language. Added a comment to make it cle
+ 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> json_parser_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