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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 #if BUILDFLAG(ENABLE_GOOGLE_NOW) | 109 #if BUILDFLAG(ENABLE_GOOGLE_NOW) |
| 109 #include "chrome/browser/ui/webui/options/geolocation_options_handler.h" | 110 #include "chrome/browser/ui/webui/options/geolocation_options_handler.h" |
| 110 #endif | 111 #endif |
| 111 | 112 |
| 112 using content::RenderViewHost; | 113 using content::RenderViewHost; |
| 113 | 114 |
| 114 namespace { | 115 namespace { |
| 115 | 116 |
| 116 const char kLocalizedStringsFile[] = "strings.js"; | 117 const char kLocalizedStringsFile[] = "strings.js"; |
| 117 const char kOptionsBundleJsFile[] = "options_bundle.js"; | 118 const char kOptionsBundleJsFile[] = "options_bundle.js"; |
| 119 const char kCustomElementsHTMLPath[] = "custom_elements.html"; | |
| 120 const char kCustomElementsJSPath[] = "custom_elements.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"; | |
| 143 | |
| 144 | |
| 145 // Creates a WebUIDataSource for chrome://settings-frame | |
| 146 content::WebUIDataSource* CreateOptionsUIDataSource | |
| 147 (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!
| |
| 148 content::WebUIDataSource* source = | |
| 149 content::WebUIDataSource::Create(chrome::kChromeUISettingsFrameHost); | |
| 150 | |
| 151 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
| |
| 152 source->SetJsonPath(kLocalizedStringsFile); | |
| 153 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!
| |
| 154 source->AddResourcePath(kOptionsBundleJsFile, IDR_OPTIONS_BUNDLE_JS); | |
| 155 | |
| 156 source->AddResourcePath(kCustomElementsHTMLPath, | |
| 157 IDR_CUSTOM_ELEMENTS_OPTIONS_HTML); | |
| 158 source->AddResourcePath(kCustomElementsJSPath, | |
| 159 IDR_CUSTOM_ELEMENTS_OPTIONS_JS); | |
| 160 source->AddResourcePath(kPinKeyboardHTMLPath, | |
| 161 IDR_OPTIONS_PIN_KEYBOARD_HTML); | |
| 162 source->AddResourcePath(kPinKeyboardJSPath, | |
| 163 IDR_OPTIONS_PIN_KEYBOARD_JS); | |
| 164 source->AddResourcePath(kPasswordPromptDialogHTMLPath, | |
| 165 IDR_OPTIONS_PASSWORD_PROMPT_DIALOG_HTML); | |
| 166 source->AddResourcePath(kPasswordPromptDialogJSPath, | |
| 167 IDR_OPTIONS_PASSWORD_PROMPT_DIALOG_JS); | |
| 168 source->AddResourcePath(kLockStateBehaviorHTMLPath, | |
| 169 IDR_OPTIONS_LOCK_STATE_BEHAVIOR_HTML); | |
| 170 source->AddResourcePath(kLockStateBehaviorJSPath, | |
| 171 IDR_OPTIONS_LOCK_STATE_BEHAVIOR_JS); | |
| 172 source->AddResourcePath(kLockScreenHTMLPath, | |
| 173 IDR_OPTIONS_LOCK_SCREEN_HTML); | |
| 174 source->AddResourcePath(kLockScreenJSPath, | |
| 175 IDR_OPTIONS_LOCK_SCREEN_JS); | |
| 176 source->AddResourcePath(kSetupPinHTMLPath, | |
| 177 IDR_OPTIONS_SETUP_PIN_DIALOG_HTML); | |
| 178 source->AddResourcePath(kSetupPinJSPath, | |
| 179 IDR_OPTIONS_SETUP_PIN_DIALOG_JS); | |
| 180 source->AddResourcePath(kSettingsRouteHTMLPath, | |
| 181 IDR_OPTIONS_ROUTE_HTML); | |
| 182 source->AddResourcePath(kSettingsRouteJSPath, | |
| 183 IDR_OPTIONS_ROUTE_JS); | |
| 184 source->AddResourcePath(kSettingsSharedCSSHTMLPath, | |
| 185 IDR_SETTINGS_SHARED_CSS_HTML); | |
| 186 source->AddResourcePath(kSettingsVarsCSSHTMLPath, | |
| 187 IDR_SETTINGS_VARS_CSS_HTML); | |
| 188 source->AddResourcePath(kSettingsPrefsBehaviorHTMLPath, | |
| 189 IDR_SETTINGS_PREFS_BEHAVIOR_HTML); | |
| 190 source->AddResourcePath(kSettingsPrefsBehaviorJSPath, | |
| 191 IDR_SETTINGS_PREFS_BEHAVIOR_JS); | |
| 192 source->AddResourcePath(kSettingsPrefsTypesHTMLPath, | |
| 193 IDR_SETTINGS_PREFS_TYPES_HTML); | |
| 194 source->AddResourcePath(kSettingsPrefsTypesJSPath, | |
| 195 IDR_SETTINGS_PREFS_TYPES_JS); | |
| 196 return source; | |
| 197 } | |
| 118 | 198 |
| 119 } // namespace | 199 } // namespace |
| 120 | 200 |
| 121 namespace options { | 201 namespace options { |
| 122 | 202 |
| 123 //////////////////////////////////////////////////////////////////////////////// | 203 //////////////////////////////////////////////////////////////////////////////// |
| 124 // | 204 // |
| 125 // OptionsUIHTMLSource | 205 // OptionsUIHTMLSource |
| 126 // | 206 // |
| 127 //////////////////////////////////////////////////////////////////////////////// | 207 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 new OptionsUIHTMLSource(localized_strings); | 438 new OptionsUIHTMLSource(localized_strings); |
| 359 | 439 |
| 360 // Set up the chrome://settings-frame/ source. | 440 // Set up the chrome://settings-frame/ source. |
| 361 Profile* profile = Profile::FromWebUI(web_ui); | 441 Profile* profile = Profile::FromWebUI(web_ui); |
| 362 content::URLDataSource::Add(profile, html_source); | 442 content::URLDataSource::Add(profile, html_source); |
| 363 | 443 |
| 364 // Set up the chrome://theme/ source. | 444 // Set up the chrome://theme/ source. |
| 365 ThemeSource* theme = new ThemeSource(profile); | 445 ThemeSource* theme = new ThemeSource(profile); |
| 366 content::URLDataSource::Add(profile, theme); | 446 content::URLDataSource::Add(profile, theme); |
| 367 | 447 |
| 448 // 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!
| |
| 449 content::WebUIDataSource::Add(profile, | |
| 450 CreateOptionsUIDataSource(*localized_strings)); | |
| 451 | |
| 452 content::WebContents* contents = web_ui->GetWebContents(); | |
| 453 extensions::TabHelper::CreateForWebContents(contents); | |
| 454 | |
| 368 #if defined(OS_CHROMEOS) | 455 #if defined(OS_CHROMEOS) |
| 369 // Set up the chrome://userimage/ source. | 456 // Set up the chrome://userimage/ source. |
| 370 chromeos::options::UserImageSource* user_image_source = | 457 chromeos::options::UserImageSource* user_image_source = |
| 371 new chromeos::options::UserImageSource(); | 458 new chromeos::options::UserImageSource(); |
| 372 content::URLDataSource::Add(profile, user_image_source); | 459 content::URLDataSource::Add(profile, user_image_source); |
| 373 | 460 |
| 374 pointer_device_observer_.reset( | 461 pointer_device_observer_.reset( |
| 375 new chromeos::system::PointerDeviceObserver()); | 462 new chromeos::system::PointerDeviceObserver()); |
| 376 pointer_device_observer_->AddObserver(browser_options_handler); | 463 pointer_device_observer_->AddObserver(browser_options_handler); |
| 377 pointer_device_observer_->AddObserver(pointer_handler); | 464 pointer_device_observer_->AddObserver(pointer_handler); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 // Add only if handler's service is enabled. | 565 // Add only if handler's service is enabled. |
| 479 if (handler->IsEnabled()) { | 566 if (handler->IsEnabled()) { |
| 480 // Add handler to the list and also pass the ownership. | 567 // Add handler to the list and also pass the ownership. |
| 481 web_ui()->AddMessageHandler(handler.release()); | 568 web_ui()->AddMessageHandler(handler.release()); |
| 482 handler_raw->GetLocalizedValues(localized_strings); | 569 handler_raw->GetLocalizedValues(localized_strings); |
| 483 handlers_.push_back(handler_raw); | 570 handlers_.push_back(handler_raw); |
| 484 } | 571 } |
| 485 } | 572 } |
| 486 | 573 |
| 487 } // namespace options | 574 } // namespace options |
| OLD | NEW |