Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/options/options_ui.h" | 5 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 #include "chrome/grit/locale_settings.h" | 56 #include "chrome/grit/locale_settings.h" |
| 57 #include "components/omnibox/browser/autocomplete_match.h" | 57 #include "components/omnibox/browser/autocomplete_match.h" |
| 58 #include "components/omnibox/browser/autocomplete_result.h" | 58 #include "components/omnibox/browser/autocomplete_result.h" |
| 59 #include "components/strings/grit/components_strings.h" | 59 #include "components/strings/grit/components_strings.h" |
| 60 #include "content/public/browser/notification_types.h" | 60 #include "content/public/browser/notification_types.h" |
| 61 #include "content/public/browser/render_frame_host.h" | 61 #include "content/public/browser/render_frame_host.h" |
| 62 #include "content/public/browser/url_data_source.h" | 62 #include "content/public/browser/url_data_source.h" |
| 63 #include "content/public/browser/web_contents.h" | 63 #include "content/public/browser/web_contents.h" |
| 64 #include "content/public/browser/web_contents_delegate.h" | 64 #include "content/public/browser/web_contents_delegate.h" |
| 65 #include "content/public/browser/web_ui.h" | 65 #include "content/public/browser/web_ui.h" |
| 66 #include "content/public/browser/web_ui_data_source.h" | |
| 66 #include "grit/options_resources.h" | 67 #include "grit/options_resources.h" |
| 67 #include "grit/theme_resources.h" | 68 #include "grit/theme_resources.h" |
| 68 #include "net/base/escape.h" | 69 #include "net/base/escape.h" |
| 69 #include "ui/base/l10n/l10n_util.h" | 70 #include "ui/base/l10n/l10n_util.h" |
| 70 #include "ui/base/resource/resource_bundle.h" | 71 #include "ui/base/resource/resource_bundle.h" |
| 71 #include "ui/base/webui/jstemplate_builder.h" | 72 #include "ui/base/webui/jstemplate_builder.h" |
| 72 #include "ui/base/webui/web_ui_util.h" | 73 #include "ui/base/webui/web_ui_util.h" |
| 73 #include "url/gurl.h" | 74 #include "url/gurl.h" |
| 74 | 75 |
| 75 #if defined(ENABLE_SUPERVISED_USERS) | 76 #if defined(ENABLE_SUPERVISED_USERS) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 #if BUILDFLAG(ENABLE_GOOGLE_NOW) | 111 #if BUILDFLAG(ENABLE_GOOGLE_NOW) |
| 111 #include "chrome/browser/ui/webui/options/geolocation_options_handler.h" | 112 #include "chrome/browser/ui/webui/options/geolocation_options_handler.h" |
| 112 #endif | 113 #endif |
| 113 | 114 |
| 114 using content::RenderViewHost; | 115 using content::RenderViewHost; |
| 115 | 116 |
| 116 namespace { | 117 namespace { |
| 117 | 118 |
| 118 const char kLocalizedStringsFile[] = "strings.js"; | 119 const char kLocalizedStringsFile[] = "strings.js"; |
| 119 const char kOptionsBundleJsFile[] = "options_bundle.js"; | 120 const char kOptionsBundleJsFile[] = "options_bundle.js"; |
| 121 const char kPinKeyboardHTMLPath[] = "people_page/pin_keyboard.html"; | |
| 122 const char kPinKeyboardJSPath[] = "people_page/pin_keyboard.js"; | |
| 123 | |
| 124 const char kPasswordPromptDialogHTMLPath[] = | |
| 125 "people_page/password_prompt_dialog.html"; | |
| 126 const char kPasswordPromptDialogJSPath[] = | |
| 127 "people_page/password_prompt_dialog.js"; | |
| 128 const char kLockStateBehaviorHTMLPath[] = | |
| 129 "people_page/lock_state_behavior.html"; | |
| 130 const char kLockStateBehaviorJSPath[] = "people_page/lock_state_behavior.js"; | |
| 131 const char kLockScreenHTMLPath[] = "people_page/lock_screen.html"; | |
| 132 const char kLockScreenJSPath[] = "people_page/lock_screen.js"; | |
| 133 const char kSetupPinHTMLPath[] = "people_page/setup_pin_dialog.html"; | |
| 134 const char kSetupPinJSPath[] = "people_page/setup_pin_dialog.js"; | |
| 135 const char kSettingsRouteHTMLPath[] = "route.html"; | |
| 136 const char kSettingsRouteJSPath[] = "route.js"; | |
| 137 const char kSettingsSharedCSSHTMLPath[] = "settings_shared_css.html"; | |
| 138 const char kSettingsVarsCSSHTMLPath[] = "settings_vars_css.html"; | |
| 139 const char kSettingsPrefsBehaviorHTMLPath[] = "prefs/prefs_behavior.html"; | |
| 140 const char kSettingsPrefsBehaviorJSPath[] = "prefs/prefs_behavior.js"; | |
| 141 const char kSettingsPrefsTypesHTMLPath[] = "prefs/prefs_types.html"; | |
| 142 const char kSettingsPrefsTypesJSPath[] = "prefs/prefs_types.js"; | |
| 120 | 143 |
| 121 } // namespace | 144 } // namespace |
| 122 | 145 |
| 123 namespace options { | 146 namespace options { |
| 124 | 147 |
| 125 //////////////////////////////////////////////////////////////////////////////// | 148 //////////////////////////////////////////////////////////////////////////////// |
| 126 // | 149 // |
| 127 // OptionsUIHTMLSource | 150 // OptionsUIHTMLSource |
| 128 // | 151 // |
| 129 //////////////////////////////////////////////////////////////////////////////// | 152 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 | 196 |
| 174 if (path == kLocalizedStringsFile) { | 197 if (path == kLocalizedStringsFile) { |
| 175 // Return dynamically-generated strings from memory. | 198 // Return dynamically-generated strings from memory. |
| 176 std::string strings_js; | 199 std::string strings_js; |
| 177 webui::AppendJsonJS(localized_strings_.get(), &strings_js); | 200 webui::AppendJsonJS(localized_strings_.get(), &strings_js); |
| 178 response_bytes = base::RefCountedString::TakeString(&strings_js); | 201 response_bytes = base::RefCountedString::TakeString(&strings_js); |
| 179 } else if (path == kOptionsBundleJsFile) { | 202 } else if (path == kOptionsBundleJsFile) { |
| 180 // Return (and cache) the options javascript code. | 203 // Return (and cache) the options javascript code. |
| 181 response_bytes = ui::ResourceBundle::GetSharedInstance(). | 204 response_bytes = ui::ResourceBundle::GetSharedInstance(). |
| 182 LoadDataResourceBytes(IDR_OPTIONS_BUNDLE_JS); | 205 LoadDataResourceBytes(IDR_OPTIONS_BUNDLE_JS); |
| 206 } else if (path == kPinKeyboardJSPath) { | |
| 207 response_bytes = | |
| 208 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 209 IDR_OPTIONS_PIN_KEYBOARD_JS); | |
| 210 } else if (path == kPinKeyboardHTMLPath) { | |
| 211 response_bytes = | |
| 212 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 213 IDR_OPTIONS_PIN_KEYBOARD_HTML); | |
| 214 } else if (path == kPasswordPromptDialogJSPath) { | |
| 215 response_bytes = | |
| 216 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 217 IDR_OPTIONS_PASSWORD_PROMPT_DIALOG_JS); | |
| 218 } else if (path == kPasswordPromptDialogHTMLPath) { | |
| 219 response_bytes = | |
|
jdufault
2016/08/11 18:34:11
Ouch! :(
| |
| 220 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 221 IDR_OPTIONS_PASSWORD_PROMPT_DIALOG_HTML); | |
| 222 } else if (path == kSetupPinJSPath) { | |
| 223 response_bytes = | |
| 224 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 225 IDR_OPTIONS_SETUP_PIN_DIALOG_JS); | |
| 226 } else if (path == kSetupPinHTMLPath) { | |
| 227 response_bytes = | |
| 228 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 229 IDR_OPTIONS_SETUP_PIN_DIALOG_HTML); | |
| 230 } else if (path == kLockStateBehaviorJSPath) { | |
| 231 response_bytes = | |
| 232 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 233 IDR_OPTIONS_LOCK_STATE_BEHAVIOR_JS); | |
| 234 } else if (path == kLockStateBehaviorHTMLPath) { | |
| 235 response_bytes = | |
| 236 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 237 IDR_OPTIONS_LOCK_STATE_BEHAVIOR_HTML); | |
| 238 } else if (path == kLockScreenJSPath) { | |
| 239 response_bytes = | |
| 240 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 241 IDR_OPTIONS_LOCK_SCREEN_JS); | |
| 242 } else if (path == kLockScreenHTMLPath) { | |
| 243 response_bytes = | |
| 244 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 245 IDR_OPTIONS_LOCK_SCREEN_HTML); | |
| 246 } else if (path == kSettingsRouteJSPath) { | |
| 247 response_bytes = | |
| 248 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 249 IDR_OPTIONS_ROUTE_JS); | |
| 250 } else if (path == kSettingsRouteHTMLPath) { | |
| 251 response_bytes = | |
| 252 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 253 IDR_OPTIONS_ROUTE_HTML); | |
| 254 } else if (path == kSettingsVarsCSSHTMLPath) { | |
| 255 response_bytes = | |
| 256 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 257 IDR_SETTINGS_VARS_CSS_HTML); | |
| 258 } else if (path == kSettingsSharedCSSHTMLPath) { | |
| 259 response_bytes = | |
| 260 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 261 IDR_SETTINGS_SHARED_CSS_HTML); | |
| 262 } else if (path == kSettingsPrefsBehaviorJSPath) { | |
| 263 response_bytes = | |
| 264 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 265 IDR_SETTINGS_PREFS_BEHAVIOR_JS); | |
| 266 } else if (path == kSettingsPrefsBehaviorHTMLPath) { | |
| 267 response_bytes = | |
| 268 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 269 IDR_SETTINGS_PREFS_BEHAVIOR_HTML); | |
| 270 } else if (path == kSettingsPrefsTypesJSPath) { | |
| 271 response_bytes = | |
| 272 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 273 IDR_SETTINGS_PREFS_TYPES_JS); | |
| 274 } else if (path == kSettingsPrefsTypesHTMLPath) { | |
| 275 response_bytes = | |
| 276 ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | |
| 277 IDR_SETTINGS_PREFS_TYPES_HTML); | |
| 183 } else { | 278 } else { |
| 184 // Return (and cache) the main options html page as the default. | 279 // Return (and cache) the main options html page as the default. |
| 185 response_bytes = ui::ResourceBundle::GetSharedInstance(). | 280 response_bytes = ui::ResourceBundle::GetSharedInstance(). |
| 186 LoadDataResourceBytes(IDR_OPTIONS_HTML); | 281 LoadDataResourceBytes(IDR_OPTIONS_HTML); |
| 187 } | 282 } |
| 188 | 283 |
| 189 callback.Run(response_bytes.get()); | 284 callback.Run(response_bytes.get()); |
| 190 } | 285 } |
| 191 | 286 |
| 192 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const { | 287 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 // Add only if handler's service is enabled. | 582 // Add only if handler's service is enabled. |
| 488 if (handler->IsEnabled()) { | 583 if (handler->IsEnabled()) { |
| 489 // Add handler to the list and also pass the ownership. | 584 // Add handler to the list and also pass the ownership. |
| 490 web_ui()->AddMessageHandler(handler.release()); | 585 web_ui()->AddMessageHandler(handler.release()); |
| 491 handler_raw->GetLocalizedValues(localized_strings); | 586 handler_raw->GetLocalizedValues(localized_strings); |
| 492 handlers_.push_back(handler_raw); | 587 handlers_.push_back(handler_raw); |
| 493 } | 588 } |
| 494 } | 589 } |
| 495 | 590 |
| 496 } // namespace options | 591 } // namespace options |
| OLD | NEW |