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

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

Issue 7661009: base: Add Is* functions to Value class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tony review Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/most_visited_handler.h" 5 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // having a map from the index to the item but the number of items is limited 228 // having a map from the index to the item but the number of items is limited
229 // to the number of items the most visited section is showing on the NTP so 229 // to the number of items the most visited section is showing on the NTP so
230 // this will be fast enough for now. 230 // this will be fast enough for now.
231 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs(); 231 PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs();
232 const DictionaryValue* pinned_urls = 232 const DictionaryValue* pinned_urls =
233 prefs->GetDictionary(prefs::kNTPMostVisitedPinnedURLs); 233 prefs->GetDictionary(prefs::kNTPMostVisitedPinnedURLs);
234 for (DictionaryValue::key_iterator it = pinned_urls->begin_keys(); 234 for (DictionaryValue::key_iterator it = pinned_urls->begin_keys();
235 it != pinned_urls->end_keys(); ++it) { 235 it != pinned_urls->end_keys(); ++it) {
236 Value* value; 236 Value* value;
237 if (pinned_urls->GetWithoutPathExpansion(*it, &value)) { 237 if (pinned_urls->GetWithoutPathExpansion(*it, &value)) {
238 if (!value->IsType(DictionaryValue::TYPE_DICTIONARY)) { 238 if (!value->IsDictionary()) {
239 // Moved on to TopSites and now going back. 239 // Moved on to TopSites and now going back.
240 DictionaryPrefUpdate update(prefs, prefs::kNTPMostVisitedPinnedURLs); 240 DictionaryPrefUpdate update(prefs, prefs::kNTPMostVisitedPinnedURLs);
241 update.Get()->Clear(); 241 update.Get()->Clear();
242 return false; 242 return false;
243 } 243 }
244 244
245 int dict_index; 245 int dict_index;
246 const DictionaryValue* dict = static_cast<DictionaryValue*>(value); 246 const DictionaryValue* dict = static_cast<DictionaryValue*>(value);
247 if (dict->GetInteger("index", &dict_index) && dict_index == index) { 247 if (dict->GetInteger("index", &dict_index) && dict_index == index) {
248 // The favicon and thumbnail URLs may be empty. 248 // The favicon and thumbnail URLs may be empty.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 return base::MD5String(url); 332 return base::MD5String(url);
333 } 333 }
334 334
335 // static 335 // static
336 void MostVisitedHandler::RegisterUserPrefs(PrefService* prefs) { 336 void MostVisitedHandler::RegisterUserPrefs(PrefService* prefs) {
337 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedURLsBlacklist, 337 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedURLsBlacklist,
338 PrefService::UNSYNCABLE_PREF); 338 PrefService::UNSYNCABLE_PREF);
339 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedPinnedURLs, 339 prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedPinnedURLs,
340 PrefService::UNSYNCABLE_PREF); 340 PrefService::UNSYNCABLE_PREF);
341 } 341 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698