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

Side by Side Diff: chrome/browser/ui/webui/suggestions_internals/suggestions_internals_ui_handler.cc

Issue 10438004: Hooking the discovery API to the NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added OWNERS for experimental discovery api. Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/suggestions_internals/suggestions_internals_ui_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/suggestions_internals/suggestions_internals_ui _handler.h" 5 #include "chrome/browser/ui/webui/suggestions_internals/suggestions_internals_ui _handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 10 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
11 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h" 11 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h"
12 #include "content/public/browser/web_ui.h" 12 #include "content/public/browser/web_ui.h"
13 13
14 namespace { 14 namespace {
15 15
16 const size_t kSuggestionsCount = 100; 16 const size_t kSuggestionsCount = 100;
17 17
18 } // namespace 18 } // namespace
19 19
20 SuggestionsInternalsUIHandler::SuggestionsInternalsUIHandler(Profile* profile) { 20 SuggestionsInternalsUIHandler::SuggestionsInternalsUIHandler(Profile* profile)
21 } 21 : profile_(profile) {}
22 22
23 SuggestionsInternalsUIHandler::~SuggestionsInternalsUIHandler() {} 23 SuggestionsInternalsUIHandler::~SuggestionsInternalsUIHandler() {}
24 24
25 void SuggestionsInternalsUIHandler::OnSuggestionsReady() { 25 void SuggestionsInternalsUIHandler::OnSuggestionsReady() {
26 if (suggestions_combiner_->GetPageValues()) { 26 if (suggestions_combiner_->GetPageValues()) {
27 web_ui()->CallJavascriptFunction("suggestionsInternals.setSuggestions", 27 web_ui()->CallJavascriptFunction("suggestionsInternals.setSuggestions",
28 *suggestions_combiner_->GetPageValues()); 28 *suggestions_combiner_->GetPageValues());
29 } 29 }
30 } 30 }
31 31
32 void SuggestionsInternalsUIHandler::RegisterMessages() { 32 void SuggestionsInternalsUIHandler::RegisterMessages() {
33 // Setup the suggestions sources. 33 // Setup the suggestions sources.
34 suggestions_combiner_.reset(SuggestionsCombiner::Create(this)); 34 suggestions_combiner_.reset(SuggestionsCombiner::Create(this, profile_));
35 suggestions_combiner_->SetSuggestionsCount(kSuggestionsCount); 35 suggestions_combiner_->SetSuggestionsCount(kSuggestionsCount);
36 36
37 web_ui()->RegisterMessageCallback("getSuggestions", 37 web_ui()->RegisterMessageCallback("getSuggestions",
38 base::Bind(&SuggestionsInternalsUIHandler::HandleGetSuggestions, 38 base::Bind(&SuggestionsInternalsUIHandler::HandleGetSuggestions,
39 base::Unretained(this))); 39 base::Unretained(this)));
40 } 40 }
41 41
42 void SuggestionsInternalsUIHandler::HandleGetSuggestions( 42 void SuggestionsInternalsUIHandler::HandleGetSuggestions(
43 const base::ListValue* one_element_input_string) { 43 const base::ListValue* one_element_input_string) {
44 suggestions_combiner_->FetchItems(Profile::FromWebUI(web_ui())); 44 suggestions_combiner_->FetchItems(Profile::FromWebUI(web_ui()));
45 } 45 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/suggestions_internals/suggestions_internals_ui_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698