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" | |
8 #include "chrome/common/pref_names.h" | 7 #include "chrome/common/pref_names.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
11 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
12 #include "chrome/common/chrome_switches.h" | |
13 #include "content/common/notification_service.h" | 12 #include "content/common/notification_service.h" |
14 | 13 |
15 void NewTabPageHandler::RegisterMessages() { | 14 void NewTabPageHandler::RegisterMessages() { |
16 web_ui_->RegisterMessageCallback("closePromo", NewCallback( | 15 web_ui_->RegisterMessageCallback("closePromo", NewCallback( |
17 this, &NewTabPageHandler::HandleClosePromo)); | 16 this, &NewTabPageHandler::HandleClosePromo)); |
18 web_ui_->RegisterMessageCallback("pageSelected", NewCallback( | 17 web_ui_->RegisterMessageCallback("pageSelected", NewCallback( |
19 this, &NewTabPageHandler::HandlePageSelected)); | 18 this, &NewTabPageHandler::HandlePageSelected)); |
20 } | 19 } |
21 | 20 |
22 void NewTabPageHandler::HandleClosePromo(const ListValue* args) { | 21 void NewTabPageHandler::HandleClosePromo(const ListValue* args) { |
(...skipping 20 matching lines...) Expand all Loading... |
43 // static | 42 // static |
44 void NewTabPageHandler::RegisterUserPrefs(PrefService* prefs) { | 43 void NewTabPageHandler::RegisterUserPrefs(PrefService* prefs) { |
45 // TODO(estade): should be syncable. | 44 // TODO(estade): should be syncable. |
46 prefs->RegisterIntegerPref(prefs::kNTPShownPage, APPS_PAGE_ID, | 45 prefs->RegisterIntegerPref(prefs::kNTPShownPage, APPS_PAGE_ID, |
47 PrefService::UNSYNCABLE_PREF); | 46 PrefService::UNSYNCABLE_PREF); |
48 } | 47 } |
49 | 48 |
50 // static | 49 // static |
51 void NewTabPageHandler::GetLocalizedValues(Profile* profile, | 50 void NewTabPageHandler::GetLocalizedValues(Profile* profile, |
52 DictionaryValue* values) { | 51 DictionaryValue* values) { |
53 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewTabPage4)) | 52 if (!NewTabUI::Ntp4Enabled()) |
54 return; | 53 return; |
55 | 54 |
56 values->SetInteger("most_visited_page_id", MOST_VISITED_PAGE_ID); | 55 values->SetInteger("most_visited_page_id", MOST_VISITED_PAGE_ID); |
57 values->SetInteger("apps_page_id", APPS_PAGE_ID); | 56 values->SetInteger("apps_page_id", APPS_PAGE_ID); |
58 values->SetInteger("bookmarks_page_id", BOOKMARKS_PAGE_ID); | 57 values->SetInteger("bookmarks_page_id", BOOKMARKS_PAGE_ID); |
59 | 58 |
60 // TODO(estade) Should respect shown sections pref (i.e. migrate if it | |
61 // exists). | |
62 PrefService* prefs = profile->GetPrefs(); | 59 PrefService* prefs = profile->GetPrefs(); |
63 int shown_page = prefs->GetInteger(prefs::kNTPShownPage); | 60 int shown_page = prefs->GetInteger(prefs::kNTPShownPage); |
64 values->SetInteger("shown_page_type", shown_page & ~INDEX_MASK); | 61 values->SetInteger("shown_page_type", shown_page & ~INDEX_MASK); |
65 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); | 62 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); |
66 } | 63 } |
OLD | NEW |