OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/most_visited_handler.h" | 5 #include "chrome/browser/dom_ui/most_visited_handler.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 void MostVisitedHandler::HandleGetMostVisited(const ListValue* args) { | 120 void MostVisitedHandler::HandleGetMostVisited(const ListValue* args) { |
121 if (!got_first_most_visited_request_) { | 121 if (!got_first_most_visited_request_) { |
122 // If our intial data is already here, return it. | 122 // If our intial data is already here, return it. |
123 SendPagesValue(); | 123 SendPagesValue(); |
124 got_first_most_visited_request_ = true; | 124 got_first_most_visited_request_ = true; |
125 } else { | 125 } else { |
126 StartQueryForMostVisited(); | 126 StartQueryForMostVisited(); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 // Set a DictionaryValue |dict| from a MostVisitedURL. | |
131 void SetDictionaryValue(const history::MostVisitedURL& url, | |
132 DictionaryValue& dict) { | |
133 NewTabUI::SetURLTitleAndDirection(&dict, url.title, url.url); | |
134 dict.SetString("url", url.url.spec()); | |
135 dict.SetString("faviconUrl", url.favicon_url.spec()); | |
136 // TODO(Nik): Need thumbnailUrl? | |
137 // TODO(Nik): Add pinned and blacklisted URLs. | |
138 dict.SetBoolean("pinned", false); | |
139 } | |
140 | |
141 void MostVisitedHandler::SendPagesValue() { | 130 void MostVisitedHandler::SendPagesValue() { |
142 if (pages_value_.get()) { | 131 if (pages_value_.get()) { |
143 FundamentalValue first_run(IsFirstRun()); | 132 FundamentalValue first_run(IsFirstRun()); |
144 dom_ui_->CallJavascriptFunction(L"mostVisitedPages", | 133 dom_ui_->CallJavascriptFunction(L"mostVisitedPages", |
145 *(pages_value_.get()), first_run); | 134 *(pages_value_.get()), first_run); |
146 pages_value_.reset(); | 135 pages_value_.reset(); |
147 } | 136 } |
148 } | 137 } |
149 | 138 |
150 void MostVisitedHandler::StartQueryForMostVisited() { | 139 void MostVisitedHandler::StartQueryForMostVisited() { |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 | 521 |
533 std::string MostVisitedHandler::GetDictionaryKeyForURL(const std::string& url) { | 522 std::string MostVisitedHandler::GetDictionaryKeyForURL(const std::string& url) { |
534 return MD5String(url); | 523 return MD5String(url); |
535 } | 524 } |
536 | 525 |
537 // static | 526 // static |
538 void MostVisitedHandler::RegisterUserPrefs(PrefService* prefs) { | 527 void MostVisitedHandler::RegisterUserPrefs(PrefService* prefs) { |
539 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedURLsBlacklist); | 528 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedURLsBlacklist); |
540 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedPinnedURLs); | 529 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedPinnedURLs); |
541 } | 530 } |
OLD | NEW |