| 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/new_tab_page_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 "ExtendedNewTabPage.TimeToClickRecentlyClosed", delta); | 165 "ExtendedNewTabPage.TimeToClickRecentlyClosed", delta); |
| 166 } else { | 166 } else { |
| 167 NOTREACHED(); | 167 NOTREACHED(); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 // static | 171 // static |
| 172 void NewTabPageHandler::RegisterProfilePrefs( | 172 void NewTabPageHandler::RegisterProfilePrefs( |
| 173 user_prefs::PrefRegistrySyncable* registry) { | 173 user_prefs::PrefRegistrySyncable* registry) { |
| 174 // TODO(estade): should be syncable. | 174 // TODO(estade): should be syncable. |
| 175 registry->RegisterIntegerPref( | 175 registry->RegisterIntegerPref(prefs::kNtpShownPage, APPS_PAGE_ID); |
| 176 prefs::kNtpShownPage, | |
| 177 APPS_PAGE_ID, | |
| 178 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 179 } | 176 } |
| 180 | 177 |
| 181 // static | 178 // static |
| 182 void NewTabPageHandler::GetLocalizedValues(Profile* profile, | 179 void NewTabPageHandler::GetLocalizedValues(Profile* profile, |
| 183 base::DictionaryValue* values) { | 180 base::DictionaryValue* values) { |
| 184 values->SetInteger("most_visited_page_id", MOST_VISITED_PAGE_ID); | 181 values->SetInteger("most_visited_page_id", MOST_VISITED_PAGE_ID); |
| 185 values->SetInteger("apps_page_id", APPS_PAGE_ID); | 182 values->SetInteger("apps_page_id", APPS_PAGE_ID); |
| 186 values->SetInteger("suggestions_page_id", SUGGESTIONS_PAGE_ID); | 183 values->SetInteger("suggestions_page_id", SUGGESTIONS_PAGE_ID); |
| 187 | 184 |
| 188 PrefService* prefs = profile->GetPrefs(); | 185 PrefService* prefs = profile->GetPrefs(); |
| 189 int shown_page = prefs->GetInteger(prefs::kNtpShownPage); | 186 int shown_page = prefs->GetInteger(prefs::kNtpShownPage); |
| 190 values->SetInteger("shown_page_type", shown_page & ~INDEX_MASK); | 187 values->SetInteger("shown_page_type", shown_page & ~INDEX_MASK); |
| 191 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); | 188 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); |
| 192 } | 189 } |
| 193 | 190 |
| 194 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { | 191 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { |
| 195 content::NotificationService* service = | 192 content::NotificationService* service = |
| 196 content::NotificationService::current(); | 193 content::NotificationService::current(); |
| 197 service->Notify(notification_type, | 194 service->Notify(notification_type, |
| 198 content::Source<NewTabPageHandler>(this), | 195 content::Source<NewTabPageHandler>(this), |
| 199 content::NotificationService::NoDetails()); | 196 content::NotificationService::NoDetails()); |
| 200 } | 197 } |
| OLD | NEW |