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

Side by Side Diff: chrome/browser/search/suggestions/suggestions_source.h

Issue 1887403002: Create a WebUIController for chrome://suggestions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move SuggestionsSource Created 4 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2014 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_SEARCH_SUGGESTIONS_SUGGESTIONS_SOURCE_H_
6 #define CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SOURCE_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
14 #include "components/suggestions/proto/suggestions.pb.h"
15 #include "content/public/browser/url_data_source.h"
16 #include "url/gurl.h"
17
18 class Profile;
19 class SkBitmap;
20
21 namespace suggestions {
22
23 // SuggestionsSource renders a webpage to list SuggestionsService data.
24 class SuggestionsSource : public content::URLDataSource {
25 public:
26 explicit SuggestionsSource(Profile* profile);
27
28 // content::URLDataSource implementation.
29 std::string GetSource() const override;
30 void StartDataRequest(
31 const std::string& path,
32 int render_process_id,
33 int render_frame_id,
34 const content::URLDataSource::GotDataCallback& callback) override;
35 std::string GetMimeType(const std::string& path) const override;
36 base::MessageLoop* MessageLoopForRequestPath(
37 const std::string& path) const override;
38
39 private:
40 ~SuggestionsSource() override;
41
42 // Container for the state of a request.
43 struct RequestContext {
44 RequestContext(
45 bool is_refresh_in,
46 const suggestions::SuggestionsProfile& suggestions_profile_in,
47 const content::URLDataSource::GotDataCallback& callback_in);
48 ~RequestContext();
49
50 const bool is_refresh;
51 const suggestions::SuggestionsProfile suggestions_profile;
52 const content::URLDataSource::GotDataCallback callback;
53 std::map<GURL, std::string> base64_encoded_pngs;
54 };
55
56 // Callback for responses from each Thumbnail request.
57 void OnThumbnailAvailable(RequestContext* context, base::Closure barrier,
58 const GURL& url, const SkBitmap* bitmap);
59
60 // Callback for when all requests are complete. Renders the output webpage and
61 // passes the result to the original caller.
62 void OnThumbnailsFetched(RequestContext* context);
63
64 // Only used when servicing requests on the UI thread.
65 Profile* const profile_;
66
67 // For callbacks may be run after destruction.
68 base::WeakPtrFactory<SuggestionsSource> weak_ptr_factory_;
69
70 DISALLOW_COPY_AND_ASSIGN(SuggestionsSource);
71 };
72
73 } // namespace suggestions
74
75 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SOURCE_H_
OLDNEW
« no previous file with comments | « chrome/browser/search/instant_service.cc ('k') | chrome/browser/search/suggestions/suggestions_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698