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

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

Issue 1141843004: NTP Zombie Code Slayer II: Suggestions Page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: and remove urls Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/suggestions_internals/suggestions_internals_ui _handler.h"
6
7 #include "base/bind.h"
8 #include "base/values.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h"
11 #include "content/public/browser/web_ui.h"
12
13 namespace {
14
15 const size_t kSuggestionsCount = 100;
16
17 } // namespace
18
19 SuggestionsInternalsUIHandler::SuggestionsInternalsUIHandler(Profile* profile)
20 : profile_(profile) {}
21
22 SuggestionsInternalsUIHandler::~SuggestionsInternalsUIHandler() {}
23
24 void SuggestionsInternalsUIHandler::OnSuggestionsReady() {
25 if (suggestions_combiner_->GetPageValues()) {
26 web_ui()->CallJavascriptFunction("suggestionsInternals.setSuggestions",
27 *suggestions_combiner_->GetPageValues());
28 }
29 }
30
31 void SuggestionsInternalsUIHandler::RegisterMessages() {
32 // Setup the suggestions sources.
33 suggestions_combiner_.reset(new SuggestionsCombiner(this, profile_));
34 suggestions_combiner_->SetSuggestionsCount(kSuggestionsCount);
35 suggestions_combiner_->EnableDebug(true);
36
37 web_ui()->RegisterMessageCallback("getSuggestions",
38 base::Bind(&SuggestionsInternalsUIHandler::HandleGetSuggestions,
39 base::Unretained(this)));
40 }
41
42 void SuggestionsInternalsUIHandler::HandleGetSuggestions(
43 const base::ListValue* one_element_input_string) {
44 suggestions_combiner_->FetchItems(Profile::FromWebUI(web_ui()));
45 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/suggestions_internals/suggestions_internals_ui_handler.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698