| OLD | NEW |
| 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" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // show the new tab page. | 75 // show the new tab page. |
| 76 top_sites->SyncWithHistory(); | 76 top_sites->SyncWithHistory(); |
| 77 | 77 |
| 78 // Register for notification when TopSites changes so that we can update | 78 // Register for notification when TopSites changes so that we can update |
| 79 // ourself. | 79 // ourself. |
| 80 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED, | 80 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED, |
| 81 content::Source<history::TopSites>(top_sites)); | 81 content::Source<history::TopSites>(top_sites)); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Setup the suggestions sources. | 84 // Setup the suggestions sources. |
| 85 suggestions_combiner_.reset(SuggestionsCombiner::Create(this)); | 85 suggestions_combiner_.reset(SuggestionsCombiner::Create(this, profile)); |
| 86 | 86 |
| 87 // We pre-emptively make a fetch for suggestions so we have the results | 87 // We pre-emptively make a fetch for suggestions so we have the results |
| 88 // sooner. | 88 // sooner. |
| 89 suggestions_combiner_->FetchItems(profile); | 89 suggestions_combiner_->FetchItems(profile); |
| 90 | 90 |
| 91 web_ui()->RegisterMessageCallback("getSuggestions", | 91 web_ui()->RegisterMessageCallback("getSuggestions", |
| 92 base::Bind(&SuggestionsHandler::HandleGetSuggestions, | 92 base::Bind(&SuggestionsHandler::HandleGetSuggestions, |
| 93 base::Unretained(this))); | 93 base::Unretained(this))); |
| 94 // Register ourselves for any suggestions item blacklisting. | 94 // Register ourselves for any suggestions item blacklisting. |
| 95 web_ui()->RegisterMessageCallback("blacklistURLFromSuggestions", | 95 web_ui()->RegisterMessageCallback("blacklistURLFromSuggestions", |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 185 } |
| 186 | 186 |
| 187 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) { | 187 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) { |
| 188 return base::MD5String(url); | 188 return base::MD5String(url); |
| 189 } | 189 } |
| 190 | 190 |
| 191 // static | 191 // static |
| 192 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) { | 192 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) { |
| 193 // TODO(georgey) add user preferences (such as own blacklist) as needed. | 193 // TODO(georgey) add user preferences (such as own blacklist) as needed. |
| 194 } | 194 } |
| OLD | NEW |