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/options2/options_ui.h" | 5 #include "chrome/browser/ui/webui/options2/options_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 using content::RenderViewHost; | 92 using content::RenderViewHost; |
93 | 93 |
94 namespace { | 94 namespace { |
95 | 95 |
96 const char kLocalizedStringsFile[] = "strings.js"; | 96 const char kLocalizedStringsFile[] = "strings.js"; |
97 const char kOptionsBundleJsFile[] = "options_bundle.js"; | 97 const char kOptionsBundleJsFile[] = "options_bundle.js"; |
98 | 98 |
99 } // namespace | 99 } // namespace |
100 | 100 |
101 namespace options2 { | 101 namespace options { |
102 | 102 |
103 //////////////////////////////////////////////////////////////////////////////// | 103 //////////////////////////////////////////////////////////////////////////////// |
104 // | 104 // |
105 // OptionsUIHTMLSource | 105 // OptionsUIHTMLSource |
106 // | 106 // |
107 //////////////////////////////////////////////////////////////////////////////// | 107 //////////////////////////////////////////////////////////////////////////////// |
108 | 108 |
109 class OptionsUIHTMLSource : public ChromeURLDataManager::DataSource { | 109 class OptionsUIHTMLSource : public ChromeURLDataManager::DataSource { |
110 public: | 110 public: |
111 // The constructor takes over ownership of |localized_strings|. | 111 // The constructor takes over ownership of |localized_strings|. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // | 211 // |
212 //////////////////////////////////////////////////////////////////////////////// | 212 //////////////////////////////////////////////////////////////////////////////// |
213 | 213 |
214 OptionsUI::OptionsUI(content::WebUI* web_ui) | 214 OptionsUI::OptionsUI(content::WebUI* web_ui) |
215 : WebUIController(web_ui), | 215 : WebUIController(web_ui), |
216 initialized_handlers_(false) { | 216 initialized_handlers_(false) { |
217 DictionaryValue* localized_strings = new DictionaryValue(); | 217 DictionaryValue* localized_strings = new DictionaryValue(); |
218 | 218 |
219 CoreOptionsHandler* core_handler; | 219 CoreOptionsHandler* core_handler; |
220 #if defined(OS_CHROMEOS) | 220 #if defined(OS_CHROMEOS) |
221 core_handler = new chromeos::options2::CoreChromeOSOptionsHandler(); | 221 core_handler = new chromeos::options::CoreChromeOSOptionsHandler(); |
222 #else | 222 #else |
223 core_handler = new CoreOptionsHandler(); | 223 core_handler = new CoreOptionsHandler(); |
224 #endif | 224 #endif |
225 core_handler->set_handlers_host(this); | 225 core_handler->set_handlers_host(this); |
226 AddOptionsPageUIHandler(localized_strings, core_handler); | 226 AddOptionsPageUIHandler(localized_strings, core_handler); |
227 | 227 |
228 AddOptionsPageUIHandler(localized_strings, new AutofillOptionsHandler()); | 228 AddOptionsPageUIHandler(localized_strings, new AutofillOptionsHandler()); |
229 | 229 |
230 BrowserOptionsHandler* browser_options_handler = new BrowserOptionsHandler(); | 230 BrowserOptionsHandler* browser_options_handler = new BrowserOptionsHandler(); |
231 AddOptionsPageUIHandler(localized_strings, browser_options_handler); | 231 AddOptionsPageUIHandler(localized_strings, browser_options_handler); |
232 | 232 |
233 AddOptionsPageUIHandler(localized_strings, new ClearBrowserDataHandler()); | 233 AddOptionsPageUIHandler(localized_strings, new ClearBrowserDataHandler()); |
234 AddOptionsPageUIHandler(localized_strings, new ContentSettingsHandler()); | 234 AddOptionsPageUIHandler(localized_strings, new ContentSettingsHandler()); |
235 AddOptionsPageUIHandler(localized_strings, new CookiesViewHandler()); | 235 AddOptionsPageUIHandler(localized_strings, new CookiesViewHandler()); |
236 AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler()); | 236 AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler()); |
237 AddOptionsPageUIHandler(localized_strings, new HomePageOverlayHandler()); | 237 AddOptionsPageUIHandler(localized_strings, new HomePageOverlayHandler()); |
238 AddOptionsPageUIHandler(localized_strings, new MediaGalleriesHandler()); | 238 AddOptionsPageUIHandler(localized_strings, new MediaGalleriesHandler()); |
239 AddOptionsPageUIHandler(localized_strings, new WebIntentsSettingsHandler()); | 239 AddOptionsPageUIHandler(localized_strings, new WebIntentsSettingsHandler()); |
240 #if defined(OS_CHROMEOS) | 240 #if defined(OS_CHROMEOS) |
241 AddOptionsPageUIHandler(localized_strings, | 241 AddOptionsPageUIHandler(localized_strings, |
242 new chromeos::options2::CrosLanguageOptionsHandler()); | 242 new chromeos::options::CrosLanguageOptionsHandler()); |
243 #else | 243 #else |
244 AddOptionsPageUIHandler(localized_strings, new LanguageOptionsHandler()); | 244 AddOptionsPageUIHandler(localized_strings, new LanguageOptionsHandler()); |
245 #endif | 245 #endif |
246 AddOptionsPageUIHandler(localized_strings, new ManageProfileHandler()); | 246 AddOptionsPageUIHandler(localized_strings, new ManageProfileHandler()); |
247 AddOptionsPageUIHandler(localized_strings, new PasswordManagerHandler()); | 247 AddOptionsPageUIHandler(localized_strings, new PasswordManagerHandler()); |
248 AddOptionsPageUIHandler(localized_strings, new SearchEngineManagerHandler()); | 248 AddOptionsPageUIHandler(localized_strings, new SearchEngineManagerHandler()); |
249 AddOptionsPageUIHandler(localized_strings, new ImportDataHandler()); | 249 AddOptionsPageUIHandler(localized_strings, new ImportDataHandler()); |
250 AddOptionsPageUIHandler(localized_strings, new StartupPagesHandler()); | 250 AddOptionsPageUIHandler(localized_strings, new StartupPagesHandler()); |
251 AddOptionsPageUIHandler(localized_strings, new OptionsSyncSetupHandler( | 251 AddOptionsPageUIHandler(localized_strings, new OptionsSyncSetupHandler( |
252 g_browser_process->profile_manager())); | 252 g_browser_process->profile_manager())); |
253 #if defined(OS_CHROMEOS) | 253 #if defined(OS_CHROMEOS) |
254 AddOptionsPageUIHandler(localized_strings, | 254 AddOptionsPageUIHandler(localized_strings, |
255 new chromeos::options2::AccountsOptionsHandler()); | 255 new chromeos::options::AccountsOptionsHandler()); |
256 AddOptionsPageUIHandler(localized_strings, | 256 AddOptionsPageUIHandler(localized_strings, |
257 new chromeos::options2::BluetoothOptionsHandler()); | 257 new chromeos::options::BluetoothOptionsHandler()); |
258 AddOptionsPageUIHandler(localized_strings, | 258 AddOptionsPageUIHandler(localized_strings, |
259 new chromeos::options2::DisplayOptionsHandler()); | 259 new chromeos::options::DisplayOptionsHandler()); |
260 AddOptionsPageUIHandler(localized_strings, new InternetOptionsHandler()); | 260 AddOptionsPageUIHandler(localized_strings, new InternetOptionsHandler()); |
261 AddOptionsPageUIHandler(localized_strings, | 261 AddOptionsPageUIHandler(localized_strings, |
262 new chromeos::options2::LanguageChewingHandler()); | 262 new chromeos::options::LanguageChewingHandler()); |
263 AddOptionsPageUIHandler(localized_strings, | 263 AddOptionsPageUIHandler(localized_strings, |
264 new chromeos::options2::KeyboardHandler()); | 264 new chromeos::options::KeyboardHandler()); |
265 AddOptionsPageUIHandler(localized_strings, | 265 AddOptionsPageUIHandler(localized_strings, |
266 new chromeos::options2::LanguageHangulHandler()); | 266 new chromeos::options::LanguageHangulHandler()); |
267 AddOptionsPageUIHandler(localized_strings, | 267 AddOptionsPageUIHandler(localized_strings, |
268 new chromeos::options2::LanguageMozcHandler()); | 268 new chromeos::options::LanguageMozcHandler()); |
269 AddOptionsPageUIHandler(localized_strings, | 269 AddOptionsPageUIHandler(localized_strings, |
270 new chromeos::options2::LanguagePinyinHandler()); | 270 new chromeos::options::LanguagePinyinHandler()); |
271 | 271 |
272 chromeos::options2::PointerHandler* pointer_handler = | 272 chromeos::options::PointerHandler* pointer_handler = |
273 new chromeos::options2::PointerHandler(); | 273 new chromeos::options::PointerHandler(); |
274 AddOptionsPageUIHandler(localized_strings, pointer_handler); | 274 AddOptionsPageUIHandler(localized_strings, pointer_handler); |
275 | 275 |
276 AddOptionsPageUIHandler(localized_strings, | 276 AddOptionsPageUIHandler(localized_strings, |
277 new chromeos::options2::ProxyHandler()); | 277 new chromeos::options::ProxyHandler()); |
278 AddOptionsPageUIHandler( | 278 AddOptionsPageUIHandler( |
279 localized_strings, | 279 localized_strings, |
280 new chromeos::options2::ChangePictureOptionsHandler()); | 280 new chromeos::options::ChangePictureOptionsHandler()); |
281 AddOptionsPageUIHandler(localized_strings, | 281 AddOptionsPageUIHandler(localized_strings, |
282 new chromeos::options2::StatsOptionsHandler()); | 282 new chromeos::options::StatsOptionsHandler()); |
283 #endif | 283 #endif |
284 #if defined(OS_CHROMEOS) && defined(USE_ASH) | 284 #if defined(OS_CHROMEOS) && defined(USE_ASH) |
285 AddOptionsPageUIHandler( | 285 AddOptionsPageUIHandler( |
286 localized_strings, | 286 localized_strings, |
287 new chromeos::options2::SetWallpaperOptionsHandler()); | 287 new chromeos::options::SetWallpaperOptionsHandler()); |
288 #endif | 288 #endif |
289 #if defined(USE_NSS) | 289 #if defined(USE_NSS) |
290 AddOptionsPageUIHandler(localized_strings, new CertificateManagerHandler()); | 290 AddOptionsPageUIHandler(localized_strings, new CertificateManagerHandler()); |
291 #endif | 291 #endif |
292 AddOptionsPageUIHandler(localized_strings, new HandlerOptionsHandler()); | 292 AddOptionsPageUIHandler(localized_strings, new HandlerOptionsHandler()); |
293 | 293 |
294 // |localized_strings| ownership is taken over by this constructor. | 294 // |localized_strings| ownership is taken over by this constructor. |
295 OptionsUIHTMLSource* html_source = | 295 OptionsUIHTMLSource* html_source = |
296 new OptionsUIHTMLSource(localized_strings); | 296 new OptionsUIHTMLSource(localized_strings); |
297 | 297 |
298 // Set up the chrome://settings-frame/ source. | 298 // Set up the chrome://settings-frame/ source. |
299 Profile* profile = Profile::FromWebUI(web_ui); | 299 Profile* profile = Profile::FromWebUI(web_ui); |
300 ChromeURLDataManager::AddDataSource(profile, html_source); | 300 ChromeURLDataManager::AddDataSource(profile, html_source); |
301 | 301 |
302 // Set up the chrome://theme/ source. | 302 // Set up the chrome://theme/ source. |
303 ThemeSource* theme = new ThemeSource(profile); | 303 ThemeSource* theme = new ThemeSource(profile); |
304 ChromeURLDataManager::AddDataSource(profile, theme); | 304 ChromeURLDataManager::AddDataSource(profile, theme); |
305 | 305 |
306 #if defined(OS_CHROMEOS) | 306 #if defined(OS_CHROMEOS) |
307 // Set up the chrome://userimage/ source. | 307 // Set up the chrome://userimage/ source. |
308 chromeos::options2::UserImageSource* user_image_source = | 308 chromeos::options::UserImageSource* user_image_source = |
309 new chromeos::options2::UserImageSource(); | 309 new chromeos::options::UserImageSource(); |
310 ChromeURLDataManager::AddDataSource(profile, user_image_source); | 310 ChromeURLDataManager::AddDataSource(profile, user_image_source); |
311 | 311 |
312 // Set up the chrome://wallpaper-thumb/ source. | 312 // Set up the chrome://wallpaper-thumb/ source. |
313 chromeos::options2::WallpaperThumbnailSource* wallpaper_thumbnail_source = | 313 chromeos::options::WallpaperThumbnailSource* wallpaper_thumbnail_source = |
314 new chromeos::options2::WallpaperThumbnailSource(); | 314 new chromeos::options::WallpaperThumbnailSource(); |
315 ChromeURLDataManager::AddDataSource(profile, wallpaper_thumbnail_source); | 315 ChromeURLDataManager::AddDataSource(profile, wallpaper_thumbnail_source); |
316 | 316 |
317 pointer_device_observer_.reset( | 317 pointer_device_observer_.reset( |
318 new chromeos::system::PointerDeviceObserver()); | 318 new chromeos::system::PointerDeviceObserver()); |
319 pointer_device_observer_->AddObserver(browser_options_handler); | 319 pointer_device_observer_->AddObserver(browser_options_handler); |
320 pointer_device_observer_->AddObserver(pointer_handler); | 320 pointer_device_observer_->AddObserver(pointer_handler); |
321 #endif | 321 #endif |
322 } | 322 } |
323 | 323 |
324 OptionsUI::~OptionsUI() { | 324 OptionsUI::~OptionsUI() { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 DCHECK(handler.get()); | 386 DCHECK(handler.get()); |
387 // Add only if handler's service is enabled. | 387 // Add only if handler's service is enabled. |
388 if (handler->IsEnabled()) { | 388 if (handler->IsEnabled()) { |
389 // Add handler to the list and also pass the ownership. | 389 // Add handler to the list and also pass the ownership. |
390 web_ui()->AddMessageHandler(handler.release()); | 390 web_ui()->AddMessageHandler(handler.release()); |
391 handler_raw->GetLocalizedValues(localized_strings); | 391 handler_raw->GetLocalizedValues(localized_strings); |
392 handlers_.push_back(handler_raw); | 392 handlers_.push_back(handler_raw); |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 } // namespace options2 | 396 } // namespace options |
OLD | NEW |