| OLD | NEW |
| 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/new_tab_page_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 CHECK(args->GetDouble(1, &index_double)); | 36 CHECK(args->GetDouble(1, &index_double)); |
| 37 int index = static_cast<int>(index_double); | 37 int index = static_cast<int>(index_double); |
| 38 | 38 |
| 39 PrefService* prefs = web_ui_->GetProfile()->GetPrefs(); | 39 PrefService* prefs = web_ui_->GetProfile()->GetPrefs(); |
| 40 prefs->SetInteger(prefs::kNTPShownPage, page_id | index); | 40 prefs->SetInteger(prefs::kNTPShownPage, page_id | index); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 void NewTabPageHandler::RegisterUserPrefs(PrefService* prefs) { | 44 void NewTabPageHandler::RegisterUserPrefs(PrefService* prefs) { |
| 45 // TODO(estade): should be syncable. | 45 // TODO(estade): should be syncable. |
| 46 prefs->RegisterIntegerPref(prefs::kNTPShownPage, MOST_VISITED_PAGE_ID, | 46 prefs->RegisterIntegerPref(prefs::kNTPShownPage, APPS_PAGE_ID, |
| 47 PrefService::UNSYNCABLE_PREF); | 47 PrefService::UNSYNCABLE_PREF); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // static | 50 // static |
| 51 void NewTabPageHandler::GetLocalizedValues(Profile* profile, | 51 void NewTabPageHandler::GetLocalizedValues(Profile* profile, |
| 52 DictionaryValue* values) { | 52 DictionaryValue* values) { |
| 53 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewTabPage4)) | 53 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewTabPage4)) |
| 54 return; | 54 return; |
| 55 | 55 |
| 56 values->SetInteger("most_visited_page_id", MOST_VISITED_PAGE_ID); | 56 values->SetInteger("most_visited_page_id", MOST_VISITED_PAGE_ID); |
| 57 values->SetInteger("apps_page_id", APPS_PAGE_ID); | 57 values->SetInteger("apps_page_id", APPS_PAGE_ID); |
| 58 values->SetInteger("bookmarks_page_id", BOOKMARKS_PAGE_ID); | 58 values->SetInteger("bookmarks_page_id", BOOKMARKS_PAGE_ID); |
| 59 | 59 |
| 60 // TODO(estade) Should respect shown sections pref (i.e. migrate if it | 60 // TODO(estade) Should respect shown sections pref (i.e. migrate if it |
| 61 // exists). | 61 // exists). |
| 62 PrefService* prefs = profile->GetPrefs(); | 62 PrefService* prefs = profile->GetPrefs(); |
| 63 int shown_page = prefs->GetInteger(prefs::kNTPShownPage); | 63 int shown_page = prefs->GetInteger(prefs::kNTPShownPage); |
| 64 values->SetInteger("shown_page_type", shown_page & ~INDEX_MASK); | 64 values->SetInteger("shown_page_type", shown_page & ~INDEX_MASK); |
| 65 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); | 65 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); |
| 66 } | 66 } |
| OLD | NEW |