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..d0f71aa6b461a4aca0c2566abff846def46cb395 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" |
| @@ -116,6 +117,28 @@ namespace { |
| const char kLocalizedStringsFile[] = "strings.js"; |
| const char kOptionsBundleJsFile[] = "options_bundle.js"; |
| +const char kPinKeyboardHTMLPath[] = "people_page/pin_keyboard.html"; |
|
xiyuan
2016/08/16 18:19:47
nit: constexpr char... here and other places
xiaoyinh(OOO Sep 11-29)
2016/08/17 20:52:11
Done.
|
| +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_stub.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"; |
| + |
| } // namespace |
| namespace options { |
| @@ -143,9 +166,11 @@ class OptionsUIHTMLSource : public content::URLDataSource { |
| private: |
| ~OptionsUIHTMLSource() override; |
| + void CreateDataSourceMap(); |
| // Localized strings collection. |
| std::unique_ptr<base::DictionaryValue> localized_strings_; |
| + std::map<std::string, int> path_to_idr_map_; |
| DISALLOW_COPY_AND_ASSIGN(OptionsUIHTMLSource); |
| }; |
| @@ -154,6 +179,7 @@ OptionsUIHTMLSource::OptionsUIHTMLSource( |
| base::DictionaryValue* localized_strings) { |
| DCHECK(localized_strings); |
| localized_strings_.reset(localized_strings); |
| + CreateDataSourceMap(); |
| } |
| std::string OptionsUIHTMLSource::GetSource() const { |
| @@ -169,6 +195,9 @@ void OptionsUIHTMLSource::StartDataRequest( |
| const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
| webui::SetLoadTimeDataDefaults(app_locale, localized_strings_.get()); |
| + std::map<std::string, int>::iterator result; |
| + result = path_to_idr_map_.find(path); |
| + |
| if (path == kLocalizedStringsFile) { |
| // Return dynamically-generated strings from memory. |
| std::string strings_js; |
| @@ -178,6 +207,10 @@ void OptionsUIHTMLSource::StartDataRequest( |
| // Return (and cache) the options javascript code. |
| response_bytes = ui::ResourceBundle::GetSharedInstance(). |
| LoadDataResourceBytes(IDR_OPTIONS_BUNDLE_JS); |
| + } else if (result != path_to_idr_map_.end()) { |
| + response_bytes = |
| + ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
| + result->second); |
| } else { |
| // Return (and cache) the main options html page as the default. |
| response_bytes = ui::ResourceBundle::GetSharedInstance(). |
| @@ -200,6 +233,33 @@ bool OptionsUIHTMLSource::ShouldDenyXFrameOptions() const { |
| OptionsUIHTMLSource::~OptionsUIHTMLSource() {} |
| +void OptionsUIHTMLSource::CreateDataSourceMap() { |
| + path_to_idr_map_[kPinKeyboardHTMLPath] = IDR_OPTIONS_PIN_KEYBOARD_HTML; |
|
xiyuan
2016/08/16 18:19:47
If we include these resources only for chormeos, t
xiaoyinh(OOO Sep 11-29)
2016/08/17 20:52:11
Done.
|
| + path_to_idr_map_[kPinKeyboardJSPath] = IDR_OPTIONS_PIN_KEYBOARD_JS; |
| + path_to_idr_map_[kPasswordPromptDialogHTMLPath] = |
| + IDR_OPTIONS_PASSWORD_PROMPT_DIALOG_HTML; |
| + path_to_idr_map_[kPasswordPromptDialogJSPath] = |
| + IDR_OPTIONS_PASSWORD_PROMPT_DIALOG_JS; |
| + path_to_idr_map_[kLockStateBehaviorHTMLPath] = |
| + IDR_OPTIONS_LOCK_STATE_BEHAVIOR_HTML; |
| + path_to_idr_map_[kLockStateBehaviorJSPath] = |
| + IDR_OPTIONS_LOCK_STATE_BEHAVIOR_JS; |
| + path_to_idr_map_[kLockScreenHTMLPath] = IDR_OPTIONS_LOCK_SCREEN_HTML; |
| + path_to_idr_map_[kLockScreenJSPath] = IDR_OPTIONS_LOCK_SCREEN_JS; |
| + path_to_idr_map_[kSetupPinHTMLPath] = IDR_OPTIONS_SETUP_PIN_DIALOG_HTML; |
| + path_to_idr_map_[kSetupPinJSPath] = IDR_OPTIONS_SETUP_PIN_DIALOG_JS; |
| + path_to_idr_map_[kSettingsRouteHTMLPath] = IDR_OPTIONS_ROUTE_HTML; |
| + path_to_idr_map_[kSettingsRouteJSPath] = IDR_OPTIONS_ROUTE_JS; |
| + path_to_idr_map_[kSettingsSharedCSSHTMLPath] = IDR_SETTINGS_SHARED_CSS_HTML; |
| + path_to_idr_map_[kSettingsVarsCSSHTMLPath] = IDR_SETTINGS_VARS_CSS_HTML; |
| + path_to_idr_map_[kSettingsPrefsBehaviorHTMLPath] = |
| + IDR_SETTINGS_PREFS_BEHAVIOR_HTML; |
| + path_to_idr_map_[kSettingsPrefsBehaviorJSPath] = |
| + IDR_SETTINGS_PREFS_BEHAVIOR_JS; |
| + path_to_idr_map_[kSettingsPrefsTypesHTMLPath] = IDR_SETTINGS_PREFS_TYPES_HTML; |
| + path_to_idr_map_[kSettingsPrefsTypesJSPath] = IDR_SETTINGS_PREFS_TYPES_JS; |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // |
| // OptionsPageUIHandler |