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

Side by Side Diff: chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc

Issue 2477453002: MD Settings: Sync route paths in JavaScript to URL constants in C++ (Closed)
Patch Set: fix js compile Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/resources/settings/route.js ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/settings/md_settings_localized_strings_provide r.h" 5 #include "chrome/browser/ui/webui/settings/md_settings_localized_strings_provide r.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/i18n/number_formatting.h" 10 #include "base/i18n/number_formatting.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // Note that settings.html contains a <script> tag which imports a script of 49 // Note that settings.html contains a <script> tag which imports a script of
50 // the following name. These names must be kept in sync. 50 // the following name. These names must be kept in sync.
51 const char kLocalizedStringsFile[] = "strings.js"; 51 const char kLocalizedStringsFile[] = "strings.js";
52 52
53 struct LocalizedString { 53 struct LocalizedString {
54 const char* name; 54 const char* name;
55 int id; 55 int id;
56 }; 56 };
57 57
58 struct PathConstant {
59 const char* name;
60 const char* path;
61 };
62
58 void AddLocalizedStringsBulk(content::WebUIDataSource* html_source, 63 void AddLocalizedStringsBulk(content::WebUIDataSource* html_source,
59 LocalizedString localized_strings[], 64 LocalizedString localized_strings[],
60 size_t num_strings) { 65 size_t num_strings) {
61 for (size_t i = 0; i < num_strings; i++) { 66 for (size_t i = 0; i < num_strings; i++) {
62 html_source->AddLocalizedString(localized_strings[i].name, 67 html_source->AddLocalizedString(localized_strings[i].name,
63 localized_strings[i].id); 68 localized_strings[i].id);
64 } 69 }
65 } 70 }
66 71
67 void AddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) { 72 void AddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) {
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 "manageAddressesUrl", 983 "manageAddressesUrl",
979 autofill::payments::GetManageAddressesUrl(0).spec()); 984 autofill::payments::GetManageAddressesUrl(0).spec());
980 html_source->AddString( 985 html_source->AddString(
981 "manageCreditCardsUrl", 986 "manageCreditCardsUrl",
982 autofill::payments::GetManageInstrumentsUrl(0).spec()); 987 autofill::payments::GetManageInstrumentsUrl(0).spec());
983 988
984 AddLocalizedStringsBulk(html_source, localized_strings, 989 AddLocalizedStringsBulk(html_source, localized_strings,
985 arraysize(localized_strings)); 990 arraysize(localized_strings));
986 } 991 }
987 992
993 void AddPaths(content::WebUIDataSource* html_source) {
994 PathConstant path_constants[] = {
995 {"accessibilityPath", chrome::kAccessibilitySubPage},
996 {"autofillPath", chrome::kAutofillSubPage},
997 {"clearBrowserDataPath", chrome::kClearBrowserDataSubPage},
998 {"contentPath", chrome::kContentSettingsSubPage},
999 {"handlersPath", chrome::kHandlerSettingsSubPage},
1000 {"languagesPath", chrome::kLanguageOptionsSubPage},
1001 {"manageProfilePath", chrome::kManageProfileSubPage},
1002 {"passwordsPath", chrome::kPasswordManagerSubPage},
1003 {"resetProfileSettingsPath", chrome::kResetProfileSettingsSubPage},
1004 {"searchEnginesPath", chrome::kSearchEnginesSubPage},
1005 {"signOutPath", chrome::kSignOutSubPage},
1006 {"syncSetupPath", chrome::kSyncSetupSubPage},
1007 {"triggeredResetProfileSettingsPath",
1008 chrome::kTriggeredResetProfileSettingsSubPage},
1009 #if defined(OS_CHROMEOS)
1010 {"bluetoothPath", chrome::kBluetoothSubPage},
1011 {"dateTimePath", chrome::kDateTimeSubPage},
1012 {"internetPath", chrome::kInternetOptionsSubPage},
1013 #endif
1014 };
1015
1016 for (size_t i = 0; i < arraysize(path_constants); i++) {
1017 html_source->AddString(path_constants[i].name,
1018 std::string("/") + path_constants[i].path);
1019 }
1020 }
1021
988 void AddPeopleStrings(content::WebUIDataSource* html_source) { 1022 void AddPeopleStrings(content::WebUIDataSource* html_source) {
989 LocalizedString localized_strings[] = { 1023 LocalizedString localized_strings[] = {
990 {"peoplePageTitle", IDS_SETTINGS_PEOPLE}, 1024 {"peoplePageTitle", IDS_SETTINGS_PEOPLE},
991 {"manageOtherPeople", IDS_SETTINGS_PEOPLE_MANAGE_OTHER_PEOPLE}, 1025 {"manageOtherPeople", IDS_SETTINGS_PEOPLE_MANAGE_OTHER_PEOPLE},
992 {"manageOtherPeopleDescription", 1026 {"manageOtherPeopleDescription",
993 IDS_SETTINGS_PEOPLE_MANAGE_OTHER_PEOPLE_DESCRIPTION}, 1027 IDS_SETTINGS_PEOPLE_MANAGE_OTHER_PEOPLE_DESCRIPTION},
994 {"manageSupervisedUsers", IDS_SETTINGS_PEOPLE_MANAGE_SUPERVISED_USERS}, 1028 {"manageSupervisedUsers", IDS_SETTINGS_PEOPLE_MANAGE_SUPERVISED_USERS},
995 {"manageSupervisedUsersDescription", 1029 {"manageSupervisedUsersDescription",
996 IDS_SETTINGS_PEOPLE_MANAGE_SUPERVISED_USERS_DESCRIPTION}, 1030 IDS_SETTINGS_PEOPLE_MANAGE_SUPERVISED_USERS_DESCRIPTION},
997 #if defined(OS_CHROMEOS) 1031 #if defined(OS_CHROMEOS)
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 AddEasyUnlockStrings(html_source); 1779 AddEasyUnlockStrings(html_source);
1746 AddInternetStrings(html_source); 1780 AddInternetStrings(html_source);
1747 AddCrNetworkStrings(html_source); 1781 AddCrNetworkStrings(html_source);
1748 #endif 1782 #endif
1749 AddLanguagesStrings(html_source); 1783 AddLanguagesStrings(html_source);
1750 #if defined(OS_CHROMEOS) 1784 #if defined(OS_CHROMEOS)
1751 AddMultiProfilesStrings(html_source, profile); 1785 AddMultiProfilesStrings(html_source, profile);
1752 #endif 1786 #endif
1753 AddOnStartupStrings(html_source); 1787 AddOnStartupStrings(html_source);
1754 AddPasswordsAndFormsStrings(html_source); 1788 AddPasswordsAndFormsStrings(html_source);
1789 AddPaths(html_source);
1755 AddPeopleStrings(html_source); 1790 AddPeopleStrings(html_source);
1756 AddPrintingStrings(html_source); 1791 AddPrintingStrings(html_source);
1757 AddPrivacyStrings(html_source); 1792 AddPrivacyStrings(html_source);
1758 AddResetStrings(html_source); 1793 AddResetStrings(html_source);
1759 AddSearchEnginesStrings(html_source); 1794 AddSearchEnginesStrings(html_source);
1760 AddSearchInSettingsStrings(html_source); 1795 AddSearchInSettingsStrings(html_source);
1761 AddSearchStrings(html_source); 1796 AddSearchStrings(html_source);
1762 AddSiteSettingsStrings(html_source, profile); 1797 AddSiteSettingsStrings(html_source, profile);
1763 #if !defined(OS_CHROMEOS) 1798 #if !defined(OS_CHROMEOS)
1764 AddSystemStrings(html_source); 1799 AddSystemStrings(html_source);
1765 #endif 1800 #endif
1766 AddUsersStrings(html_source); 1801 AddUsersStrings(html_source);
1767 AddWebContentStrings(html_source); 1802 AddWebContentStrings(html_source);
1768 1803
1769 policy_indicator::AddLocalizedStrings(html_source); 1804 policy_indicator::AddLocalizedStrings(html_source);
1770 1805
1771 html_source->SetJsonPath(kLocalizedStringsFile); 1806 html_source->SetJsonPath(kLocalizedStringsFile);
1772 } 1807 }
1773 1808
1774 } // namespace settings 1809 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/route.js ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698