Chromium Code Reviews| Index: chrome/browser/ui/webui/options/options_ui.cc |
| diff --git a/chrome/browser/ui/webui/options/options_ui.cc b/chrome/browser/ui/webui/options/options_ui.cc |
| index 559f096dc534726da1c8406137b178d6a459f35c..1ce53a0122aaf0add3fd962e75924fe1e9b4fb60 100644 |
| --- a/chrome/browser/ui/webui/options/options_ui.cc |
| +++ b/chrome/browser/ui/webui/options/options_ui.cc |
| @@ -63,6 +63,7 @@ |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_contents_delegate.h" |
| #include "content/public/browser/web_ui.h" |
| +#include "content/public/browser/web_ui_data_source.h" |
| #include "grit/options_resources.h" |
| #include "grit/theme_resources.h" |
| #include "net/base/escape.h" |
| @@ -115,6 +116,85 @@ namespace { |
| const char kLocalizedStringsFile[] = "strings.js"; |
| const char kOptionsBundleJsFile[] = "options_bundle.js"; |
| +const char kCustomElementsHTMLPath[] = "custom_elements.html"; |
| +const char kCustomElementsJSPath[] = "custom_elements.js"; |
| +const char kPinKeyboardHTMLPath[] = "people_page/pin_keyboard.html"; |
| +const char kPinKeyboardJSPath[] = "people_page/pin_keyboard.js"; |
| + |
| +const char kPasswordPromptDialogHTMLPath[] = |
| + "people_page/password_prompt_dialog.html"; |
| +const char kPasswordPromptDialogJSPath[] = |
| + "people_page/password_prompt_dialog.js"; |
| +const char kLockStateBehaviorHTMLPath[] = |
| + "people_page/lock_state_behavior.html"; |
| +const char kLockStateBehaviorJSPath[] = "people_page/lock_state_behavior.js"; |
| +const char kLockScreenHTMLPath[] = "people_page/lock_screen.html"; |
| +const char kLockScreenJSPath[] = "people_page/lock_screen.js"; |
| +const char kSetupPinHTMLPath[] = "people_page/setup_pin_dialog.html"; |
| +const char kSetupPinJSPath[] = "people_page/setup_pin_dialog.js"; |
| +const char kSettingsRouteHTMLPath[] = "route.html"; |
| +const char kSettingsRouteJSPath[] = "route.js"; |
| +const char kSettingsSharedCSSHTMLPath[] = "settings_shared_css.html"; |
| +const char kSettingsVarsCSSHTMLPath[] = "settings_vars_css.html"; |
| +const char kSettingsPrefsBehaviorHTMLPath[] = "prefs/prefs_behavior.html"; |
| +const char kSettingsPrefsBehaviorJSPath[] = "prefs/prefs_behavior.js"; |
| +const char kSettingsPrefsTypesHTMLPath[] = "prefs/prefs_types.html"; |
| +const char kSettingsPrefsTypesJSPath[] = "prefs/prefs_types.js"; |
| + |
| + |
| +// Creates a WebUIDataSource for chrome://settings-frame |
| +content::WebUIDataSource* CreateOptionsUIDataSource |
| + (const base::DictionaryValue& localized_strings) { |
|
jdufault
2016/08/15 19:21:18
This formatting looks strange. Did you run git cl
xiaoyinh(OOO Sep 11-29)
2016/08/16 17:33:43
This part has been removed. Thanks!
|
| + content::WebUIDataSource* source = |
| + content::WebUIDataSource::Create(chrome::kChromeUISettingsFrameHost); |
| + |
| + source->AddLocalizedStrings(localized_strings); |
|
jdufault
2016/08/15 19:21:18
What changed so that this approach now works? Is t
xiaoyinh(OOO Sep 11-29)
2016/08/16 17:33:43
I just found out that WebUIDataSource is a wrapper
|
| + source->SetJsonPath(kLocalizedStringsFile); |
| + source->SetDefaultResource(IDR_OPTIONS_HTML); |
|
jdufault
2016/08/15 19:21:18
Do you need this?
xiaoyinh(OOO Sep 11-29)
2016/08/16 17:33:43
This part has been removed. Thanks!
|
| + source->AddResourcePath(kOptionsBundleJsFile, IDR_OPTIONS_BUNDLE_JS); |
| + |
| + source->AddResourcePath(kCustomElementsHTMLPath, |
| + IDR_CUSTOM_ELEMENTS_OPTIONS_HTML); |
| + source->AddResourcePath(kCustomElementsJSPath, |
| + IDR_CUSTOM_ELEMENTS_OPTIONS_JS); |
| + source->AddResourcePath(kPinKeyboardHTMLPath, |
| + IDR_OPTIONS_PIN_KEYBOARD_HTML); |
| + source->AddResourcePath(kPinKeyboardJSPath, |
| + IDR_OPTIONS_PIN_KEYBOARD_JS); |
| + source->AddResourcePath(kPasswordPromptDialogHTMLPath, |
| + IDR_OPTIONS_PASSWORD_PROMPT_DIALOG_HTML); |
| + source->AddResourcePath(kPasswordPromptDialogJSPath, |
| + IDR_OPTIONS_PASSWORD_PROMPT_DIALOG_JS); |
| + source->AddResourcePath(kLockStateBehaviorHTMLPath, |
| + IDR_OPTIONS_LOCK_STATE_BEHAVIOR_HTML); |
| + source->AddResourcePath(kLockStateBehaviorJSPath, |
| + IDR_OPTIONS_LOCK_STATE_BEHAVIOR_JS); |
| + source->AddResourcePath(kLockScreenHTMLPath, |
| + IDR_OPTIONS_LOCK_SCREEN_HTML); |
| + source->AddResourcePath(kLockScreenJSPath, |
| + IDR_OPTIONS_LOCK_SCREEN_JS); |
| + source->AddResourcePath(kSetupPinHTMLPath, |
| + IDR_OPTIONS_SETUP_PIN_DIALOG_HTML); |
| + source->AddResourcePath(kSetupPinJSPath, |
| + IDR_OPTIONS_SETUP_PIN_DIALOG_JS); |
| + source->AddResourcePath(kSettingsRouteHTMLPath, |
| + IDR_OPTIONS_ROUTE_HTML); |
| + source->AddResourcePath(kSettingsRouteJSPath, |
| + IDR_OPTIONS_ROUTE_JS); |
| + source->AddResourcePath(kSettingsSharedCSSHTMLPath, |
| + IDR_SETTINGS_SHARED_CSS_HTML); |
| + source->AddResourcePath(kSettingsVarsCSSHTMLPath, |
| + IDR_SETTINGS_VARS_CSS_HTML); |
| + source->AddResourcePath(kSettingsPrefsBehaviorHTMLPath, |
| + IDR_SETTINGS_PREFS_BEHAVIOR_HTML); |
| + source->AddResourcePath(kSettingsPrefsBehaviorJSPath, |
| + IDR_SETTINGS_PREFS_BEHAVIOR_JS); |
| + source->AddResourcePath(kSettingsPrefsTypesHTMLPath, |
| + IDR_SETTINGS_PREFS_TYPES_HTML); |
| + source->AddResourcePath(kSettingsPrefsTypesJSPath, |
| + IDR_SETTINGS_PREFS_TYPES_JS); |
| + return source; |
| +} |
| } // namespace |
| @@ -365,6 +445,13 @@ OptionsUI::OptionsUI(content::WebUI* web_ui) |
| ThemeSource* theme = new ThemeSource(profile); |
| content::URLDataSource::Add(profile, theme); |
| + // Set uo the chrome://settings-frame/source |
|
jdufault
2016/08/15 19:21:18
uo -> up
xiaoyinh(OOO Sep 11-29)
2016/08/16 17:33:43
This part has been removed. Thanks!
|
| + content::WebUIDataSource::Add(profile, |
| + CreateOptionsUIDataSource(*localized_strings)); |
| + |
| + content::WebContents* contents = web_ui->GetWebContents(); |
| + extensions::TabHelper::CreateForWebContents(contents); |
| + |
| #if defined(OS_CHROMEOS) |
| // Set up the chrome://userimage/ source. |
| chromeos::options::UserImageSource* user_image_source = |