| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 &ChromeURLDataManager::AddDataSource, | 207 &ChromeURLDataManager::AddDataSource, |
| 208 make_scoped_refptr(theme))); | 208 make_scoped_refptr(theme))); |
| 209 | 209 |
| 210 // Initialize the chrome://about/ source in case the user clicks the credits | 210 // Initialize the chrome://about/ source in case the user clicks the credits |
| 211 // link. | 211 // link. |
| 212 InitializeAboutDataSource(); | 212 InitializeAboutDataSource(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 OptionsUI::~OptionsUI() { | 215 OptionsUI::~OptionsUI() { |
| 216 // Uninitialize all registered handlers. The base class owns them and it will | 216 // Uninitialize all registered handlers. The base class owns them and it will |
| 217 // eventually delete them. | 217 // eventually delete them. Skip over the generic handler. |
| 218 for (std::vector<DOMMessageHandler*>::iterator iter = handlers_.begin(); | 218 for (std::vector<DOMMessageHandler*>::iterator iter = handlers_.begin() + 1; |
| 219 iter != handlers_.end(); | 219 iter != handlers_.end(); |
| 220 ++iter) { | 220 ++iter) { |
| 221 static_cast<OptionsPageUIHandler*>(*iter)->Uninitialize(); | 221 static_cast<OptionsPageUIHandler*>(*iter)->Uninitialize(); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 // Override. | 225 // Override. |
| 226 void OptionsUI::RenderViewCreated(RenderViewHost* render_view_host) { | 226 void OptionsUI::RenderViewCreated(RenderViewHost* render_view_host) { |
| 227 std::string command_line_string; | 227 std::string command_line_string; |
| 228 | 228 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 252 // static | 252 // static |
| 253 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { | 253 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { |
| 254 return ResourceBundle::GetSharedInstance(). | 254 return ResourceBundle::GetSharedInstance(). |
| 255 LoadDataResourceBytes(IDR_SETTINGS_FAVICON); | 255 LoadDataResourceBytes(IDR_SETTINGS_FAVICON); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void OptionsUI::InitializeHandlers() { | 258 void OptionsUI::InitializeHandlers() { |
| 259 DCHECK(!GetProfile()->IsOffTheRecord()); | 259 DCHECK(!GetProfile()->IsOffTheRecord()); |
| 260 | 260 |
| 261 std::vector<DOMMessageHandler*>::iterator iter; | 261 std::vector<DOMMessageHandler*>::iterator iter; |
| 262 for (iter = handlers_.begin(); iter != handlers_.end(); ++iter) { | 262 // Skip over the generic handler. |
| 263 for (iter = handlers_.begin() + 1; iter != handlers_.end(); ++iter) { |
| 263 (static_cast<OptionsPageUIHandler*>(*iter))->Initialize(); | 264 (static_cast<OptionsPageUIHandler*>(*iter))->Initialize(); |
| 264 } | 265 } |
| 265 } | 266 } |
| 266 | 267 |
| 267 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, | 268 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, |
| 268 OptionsPageUIHandler* handler_raw) { | 269 OptionsPageUIHandler* handler_raw) { |
| 269 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); | 270 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); |
| 270 DCHECK(handler.get()); | 271 DCHECK(handler.get()); |
| 271 // Add only if handler's service is enabled. | 272 // Add only if handler's service is enabled. |
| 272 if (handler->IsEnabled()) { | 273 if (handler->IsEnabled()) { |
| 273 handler->GetLocalizedValues(localized_strings); | 274 handler->GetLocalizedValues(localized_strings); |
| 274 // Add handler to the list and also pass the ownership. | 275 // Add handler to the list and also pass the ownership. |
| 275 AddMessageHandler(handler.release()->Attach(this)); | 276 AddMessageHandler(handler.release()->Attach(this)); |
| 276 } | 277 } |
| 277 } | 278 } |
| OLD | NEW |