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

Side by Side Diff: chrome/browser/ui/webui/ntp/suggestions_page_handler.cc

Issue 10825020: Moved Discovery out of the Suggested Page (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moving Discovery from the Suggestions Page Created 8 years, 4 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
« no previous file with comments | « chrome/browser/ui/webui/ntp/suggestions_combiner.cc ('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/ntp/suggestions_page_handler.h" 5 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/md5.h" 12 #include "base/md5.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/browser/history/page_usage_data.h" 18 #include "chrome/browser/history/page_usage_data.h"
19 #include "chrome/browser/history/top_sites.h" 19 #include "chrome/browser/history/top_sites.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 21 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
22 #include "chrome/browser/ui/webui/favicon_source.h" 22 #include "chrome/browser/ui/webui/favicon_source.h"
23 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h" 23 #include "chrome/browser/ui/webui/ntp/suggestions_combiner.h"
24 #include "chrome/browser/ui/webui/ntp/ntp_stats.h" 24 #include "chrome/browser/ui/webui/ntp/ntp_stats.h"
25 #include "chrome/browser/ui/webui/ntp/suggestions_source_top_sites.h"
25 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 26 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
26 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
27 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
28 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/navigation_controller.h" 30 #include "content/public/browser/navigation_controller.h"
30 #include "content/public/browser/navigation_entry.h" 31 #include "content/public/browser/navigation_entry.h"
31 #include "content/public/browser/notification_source.h" 32 #include "content/public/browser/notification_source.h"
32 #include "content/public/browser/user_metrics.h" 33 #include "content/public/browser/user_metrics.h"
33 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
34 #include "content/public/browser/web_ui.h" 35 #include "content/public/browser/web_ui.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // show the new tab page. 76 // show the new tab page.
76 top_sites->SyncWithHistory(); 77 top_sites->SyncWithHistory();
77 78
78 // Register for notification when TopSites changes so that we can update 79 // Register for notification when TopSites changes so that we can update
79 // ourself. 80 // ourself.
80 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED, 81 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED,
81 content::Source<history::TopSites>(top_sites)); 82 content::Source<history::TopSites>(top_sites));
82 } 83 }
83 84
84 // Setup the suggestions sources. 85 // Setup the suggestions sources.
85 suggestions_combiner_.reset(SuggestionsCombiner::Create(this, profile)); 86 SuggestionsCombiner* combiner = new SuggestionsCombiner(this, profile);
87 combiner->AddSource(new SuggestionsSourceTopSites());
88 suggestions_combiner_.reset(combiner);
86 89
87 // We pre-emptively make a fetch for suggestions so we have the results 90 // We pre-emptively make a fetch for suggestions so we have the results
88 // sooner. 91 // sooner.
89 suggestions_combiner_->FetchItems(profile); 92 suggestions_combiner_->FetchItems(profile);
90 93
91 web_ui()->RegisterMessageCallback("getSuggestions", 94 web_ui()->RegisterMessageCallback("getSuggestions",
92 base::Bind(&SuggestionsHandler::HandleGetSuggestions, 95 base::Bind(&SuggestionsHandler::HandleGetSuggestions,
93 base::Unretained(this))); 96 base::Unretained(this)));
94 // Register ourselves for any suggestions item blacklisting. 97 // Register ourselves for any suggestions item blacklisting.
95 web_ui()->RegisterMessageCallback("blacklistURLFromSuggestions", 98 web_ui()->RegisterMessageCallback("blacklistURLFromSuggestions",
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 188 }
186 189
187 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) { 190 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) {
188 return base::MD5String(url); 191 return base::MD5String(url);
189 } 192 }
190 193
191 // static 194 // static
192 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) { 195 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) {
193 // TODO(georgey) add user preferences (such as own blacklist) as needed. 196 // TODO(georgey) add user preferences (such as own blacklist) as needed.
194 } 197 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/suggestions_combiner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698