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