| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/dom_ui/options/options_ui.h" | 5 #include "chrome/browser/dom_ui/options/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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 #endif | 186 #endif |
| 187 #if defined(USE_NSS) | 187 #if defined(USE_NSS) |
| 188 AddOptionsPageUIHandler(localized_strings, new CertificateManagerHandler()); | 188 AddOptionsPageUIHandler(localized_strings, new CertificateManagerHandler()); |
| 189 #endif | 189 #endif |
| 190 | 190 |
| 191 // |localized_strings| ownership is taken over by this constructor. | 191 // |localized_strings| ownership is taken over by this constructor. |
| 192 OptionsUIHTMLSource* html_source = | 192 OptionsUIHTMLSource* html_source = |
| 193 new OptionsUIHTMLSource(localized_strings); | 193 new OptionsUIHTMLSource(localized_strings); |
| 194 | 194 |
| 195 // Set up the chrome://settings/ source. | 195 // Set up the chrome://settings/ source. |
| 196 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 196 BrowserThread::PostTask( |
| 197 BrowserThread::IO, FROM_HERE, |
| 198 NewRunnableMethod( |
| 199 ChromeURLDataManager::GetInstance(), |
| 200 &ChromeURLDataManager::AddDataSource, |
| 201 make_scoped_refptr(html_source))); |
| 197 | 202 |
| 198 // Set up the chrome://theme/ source. | 203 // Set up the chrome://theme/ source. |
| 199 WebUIThemeSource* theme = new WebUIThemeSource(contents->profile()); | 204 WebUIThemeSource* theme = new WebUIThemeSource(GetProfile()); |
| 200 contents->profile()->GetChromeURLDataManager()->AddDataSource(theme); | 205 BrowserThread::PostTask( |
| 206 BrowserThread::IO, FROM_HERE, |
| 207 NewRunnableMethod( |
| 208 ChromeURLDataManager::GetInstance(), |
| 209 &ChromeURLDataManager::AddDataSource, |
| 210 make_scoped_refptr(theme))); |
| 201 | 211 |
| 202 // Initialize the chrome://about/ source in case the user clicks the credits | 212 // Initialize the chrome://about/ source in case the user clicks the credits |
| 203 // link. | 213 // link. |
| 204 InitializeAboutDataSource(contents->profile()); | 214 InitializeAboutDataSource(); |
| 205 } | 215 } |
| 206 | 216 |
| 207 OptionsUI::~OptionsUI() { | 217 OptionsUI::~OptionsUI() { |
| 208 // Uninitialize all registered handlers. The base class owns them and it will | 218 // Uninitialize all registered handlers. The base class owns them and it will |
| 209 // eventually delete them. Skip over the generic handler. | 219 // eventually delete them. Skip over the generic handler. |
| 210 for (std::vector<WebUIMessageHandler*>::iterator iter = handlers_.begin() + 1; | 220 for (std::vector<WebUIMessageHandler*>::iterator iter = handlers_.begin() + 1; |
| 211 iter != handlers_.end(); | 221 iter != handlers_.end(); |
| 212 ++iter) { | 222 ++iter) { |
| 213 static_cast<OptionsPageUIHandler*>(*iter)->Uninitialize(); | 223 static_cast<OptionsPageUIHandler*>(*iter)->Uninitialize(); |
| 214 } | 224 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 OptionsPageUIHandler* handler_raw) { | 279 OptionsPageUIHandler* handler_raw) { |
| 270 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); | 280 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); |
| 271 DCHECK(handler.get()); | 281 DCHECK(handler.get()); |
| 272 // Add only if handler's service is enabled. | 282 // Add only if handler's service is enabled. |
| 273 if (handler->IsEnabled()) { | 283 if (handler->IsEnabled()) { |
| 274 handler->GetLocalizedValues(localized_strings); | 284 handler->GetLocalizedValues(localized_strings); |
| 275 // Add handler to the list and also pass the ownership. | 285 // Add handler to the list and also pass the ownership. |
| 276 AddMessageHandler(handler.release()->Attach(this)); | 286 AddMessageHandler(handler.release()->Attach(this)); |
| 277 } | 287 } |
| 278 } | 288 } |
| OLD | NEW |