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