| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/dom_ui/new_tab_ui.h" | 7 #include "chrome/browser/dom_ui/new_tab_ui.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 ChromeThread::PostTask( | 617 ChromeThread::PostTask( |
| 618 ChromeThread::IO, FROM_HERE, | 618 ChromeThread::IO, FROM_HERE, |
| 619 NewRunnableMethod( | 619 NewRunnableMethod( |
| 620 &chrome_url_data_manager, | 620 &chrome_url_data_manager, |
| 621 &ChromeURLDataManager::AddDataSource, | 621 &ChromeURLDataManager::AddDataSource, |
| 622 new DOMUIThemeSource(GetProfile()))); | 622 new DOMUIThemeSource(GetProfile()))); |
| 623 } | 623 } |
| 624 | 624 |
| 625 // static | 625 // static |
| 626 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { | 626 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { |
| 627 prefs->RegisterIntegerPref(prefs::kNTPPrefVersion, 0); |
| 628 |
| 627 MostVisitedHandler::RegisterUserPrefs(prefs); | 629 MostVisitedHandler::RegisterUserPrefs(prefs); |
| 628 ShownSectionsHandler::RegisterUserPrefs(prefs); | 630 ShownSectionsHandler::RegisterUserPrefs(prefs); |
| 629 if (NewTabUI::WebResourcesEnabled()) | 631 if (NewTabUI::WebResourcesEnabled()) |
| 630 TipsHandler::RegisterUserPrefs(prefs); | 632 TipsHandler::RegisterUserPrefs(prefs); |
| 633 |
| 634 UpdateUserPrefsVersion(prefs); |
| 635 } |
| 636 |
| 637 // static |
| 638 bool NewTabUI::UpdateUserPrefsVersion(PrefService* prefs) { |
| 639 const int old_pref_version = prefs->GetInteger(prefs::kNTPPrefVersion); |
| 640 if (old_pref_version != current_pref_version()) { |
| 641 MigrateUserPrefs(prefs, old_pref_version, current_pref_version()); |
| 642 prefs->SetInteger(prefs::kNTPPrefVersion, current_pref_version()); |
| 643 return true; |
| 644 } |
| 645 return false; |
| 646 } |
| 647 |
| 648 // static |
| 649 void NewTabUI::MigrateUserPrefs(PrefService* prefs, int old_pref_version, |
| 650 int new_pref_version) { |
| 651 ShownSectionsHandler::MigrateUserPrefs(prefs, old_pref_version, |
| 652 current_pref_version()); |
| 631 } | 653 } |
| 632 | 654 |
| 633 // static | 655 // static |
| 634 bool NewTabUI::WebResourcesEnabled() { | 656 bool NewTabUI::WebResourcesEnabled() { |
| 635 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 657 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 636 return !command_line->HasSwitch(switches::kDisableWebResources); | 658 return !command_line->HasSwitch(switches::kDisableWebResources); |
| 637 } | 659 } |
| 638 | 660 |
| 639 // static | 661 // static |
| 640 bool NewTabUI::FirstRunDisabled() { | 662 bool NewTabUI::FirstRunDisabled() { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 localized_strings.SetString(L"pagedisplaytooltip", | 864 localized_strings.SetString(L"pagedisplaytooltip", |
| 843 l10n_util::GetString(IDS_NEW_TAB_PAGE_DISPLAY_TOOLTIP)); | 865 l10n_util::GetString(IDS_NEW_TAB_PAGE_DISPLAY_TOOLTIP)); |
| 844 localized_strings.SetString(L"firstrunnotification", | 866 localized_strings.SetString(L"firstrunnotification", |
| 845 l10n_util::GetString(IDS_NEW_TAB_FIRST_RUN_NOTIFICATION)); | 867 l10n_util::GetString(IDS_NEW_TAB_FIRST_RUN_NOTIFICATION)); |
| 846 localized_strings.SetString(L"closefirstrunnotification", | 868 localized_strings.SetString(L"closefirstrunnotification", |
| 847 l10n_util::GetString(IDS_NEW_TAB_CLOSE_FIRST_RUN_NOTIFICATION)); | 869 l10n_util::GetString(IDS_NEW_TAB_CLOSE_FIRST_RUN_NOTIFICATION)); |
| 848 localized_strings.SetString(L"makethishomepage", | 870 localized_strings.SetString(L"makethishomepage", |
| 849 l10n_util::GetString(IDS_NEW_TAB_MAKE_THIS_HOMEPAGE)); | 871 l10n_util::GetString(IDS_NEW_TAB_MAKE_THIS_HOMEPAGE)); |
| 850 localized_strings.SetString(L"themelink", | 872 localized_strings.SetString(L"themelink", |
| 851 l10n_util::GetString(IDS_THEMES_GALLERY_URL)); | 873 l10n_util::GetString(IDS_THEMES_GALLERY_URL)); |
| 874 localized_strings.SetString(L"tips", |
| 875 l10n_util::GetString(IDS_NEW_TAB_TIPS)); |
| 876 localized_strings.SetString(L"sync", |
| 877 l10n_util::GetString(IDS_NEW_TAB_SHOW_HIDE_BOOKMARK_SYNC)); |
| 878 |
| 852 // Don't initiate the sync related message passing with the page if the sync | 879 // Don't initiate the sync related message passing with the page if the sync |
| 853 // code is not present. | 880 // code is not present. |
| 854 if (profile_->GetProfileSyncService()) | 881 if (profile_->GetProfileSyncService()) |
| 855 localized_strings.SetString(L"syncispresent", "true"); | 882 localized_strings.SetString(L"syncispresent", "true"); |
| 856 else | 883 else |
| 857 localized_strings.SetString(L"syncispresent", "false"); | 884 localized_strings.SetString(L"syncispresent", "false"); |
| 858 | 885 |
| 859 if (!profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) | 886 if (!profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) |
| 860 localized_strings.SetString(L"showsetashomepage", "true"); | 887 localized_strings.SetString(L"showsetashomepage", "true"); |
| 861 | 888 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 std::string json_html; | 932 std::string json_html; |
| 906 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html); | 933 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html); |
| 907 | 934 |
| 908 static const std::string template_data_placeholder = | 935 static const std::string template_data_placeholder = |
| 909 "<!-- template data placeholder -->"; | 936 "<!-- template data placeholder -->"; |
| 910 ReplaceFirstSubstringAfterOffset(&full_html_, 0, template_data_placeholder, | 937 ReplaceFirstSubstringAfterOffset(&full_html_, 0, template_data_placeholder, |
| 911 json_html); | 938 json_html); |
| 912 | 939 |
| 913 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html_); | 940 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html_); |
| 914 } | 941 } |
| OLD | NEW |