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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 const UserMetricsAction& action) { | 128 const UserMetricsAction& action) { |
129 UserMetrics::RecordAction(action, dom_ui_->GetProfile()); | 129 UserMetrics::RecordAction(action, dom_ui_->GetProfile()); |
130 } | 130 } |
131 | 131 |
132 //////////////////////////////////////////////////////////////////////////////// | 132 //////////////////////////////////////////////////////////////////////////////// |
133 // | 133 // |
134 // OptionsUI | 134 // OptionsUI |
135 // | 135 // |
136 //////////////////////////////////////////////////////////////////////////////// | 136 //////////////////////////////////////////////////////////////////////////////// |
137 | 137 |
138 OptionsUI::OptionsUI(TabContents* contents) : DOMUI(contents) { | 138 OptionsUI::OptionsUI(TabContents* contents) |
| 139 : DOMUI(contents), initialized_handlers_(false) { |
139 DictionaryValue* localized_strings = new DictionaryValue(); | 140 DictionaryValue* localized_strings = new DictionaryValue(); |
140 | 141 |
141 #if defined(OS_CHROMEOS) | 142 #if defined(OS_CHROMEOS) |
142 AddOptionsPageUIHandler(localized_strings, | 143 AddOptionsPageUIHandler(localized_strings, |
143 new chromeos::CoreChromeOSOptionsHandler()); | 144 new chromeos::CoreChromeOSOptionsHandler()); |
144 #else | 145 #else |
145 AddOptionsPageUIHandler(localized_strings, new CoreOptionsHandler()); | 146 AddOptionsPageUIHandler(localized_strings, new CoreOptionsHandler()); |
146 #endif | 147 #endif |
147 | 148 |
148 AddOptionsPageUIHandler(localized_strings, new AddStartupPageHandler()); | 149 AddOptionsPageUIHandler(localized_strings, new AddStartupPageHandler()); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 252 |
252 // static | 253 // static |
253 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { | 254 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { |
254 return ResourceBundle::GetSharedInstance(). | 255 return ResourceBundle::GetSharedInstance(). |
255 LoadDataResourceBytes(IDR_SETTINGS_FAVICON); | 256 LoadDataResourceBytes(IDR_SETTINGS_FAVICON); |
256 } | 257 } |
257 | 258 |
258 void OptionsUI::InitializeHandlers() { | 259 void OptionsUI::InitializeHandlers() { |
259 DCHECK(!GetProfile()->IsOffTheRecord()); | 260 DCHECK(!GetProfile()->IsOffTheRecord()); |
260 | 261 |
| 262 // The reinitialize call from DidBecomeActiveForReusedRenderView end up being |
| 263 // delivered after a new web page DOM has been brought up in an existing |
| 264 // renderer (due to IPC delays), causing this method to be called twice. If |
| 265 // that happens, ignore the second call. |
| 266 if (initialized_handlers_) |
| 267 return; |
| 268 initialized_handlers_ = true; |
| 269 |
261 std::vector<DOMMessageHandler*>::iterator iter; | 270 std::vector<DOMMessageHandler*>::iterator iter; |
262 // Skip over the generic handler. | 271 // Skip over the generic handler. |
263 for (iter = handlers_.begin() + 1; iter != handlers_.end(); ++iter) { | 272 for (iter = handlers_.begin() + 1; iter != handlers_.end(); ++iter) { |
264 (static_cast<OptionsPageUIHandler*>(*iter))->Initialize(); | 273 (static_cast<OptionsPageUIHandler*>(*iter))->Initialize(); |
265 } | 274 } |
266 } | 275 } |
267 | 276 |
268 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, | 277 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, |
269 OptionsPageUIHandler* handler_raw) { | 278 OptionsPageUIHandler* handler_raw) { |
270 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); | 279 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); |
271 DCHECK(handler.get()); | 280 DCHECK(handler.get()); |
272 // Add only if handler's service is enabled. | 281 // Add only if handler's service is enabled. |
273 if (handler->IsEnabled()) { | 282 if (handler->IsEnabled()) { |
274 handler->GetLocalizedValues(localized_strings); | 283 handler->GetLocalizedValues(localized_strings); |
275 // Add handler to the list and also pass the ownership. | 284 // Add handler to the list and also pass the ownership. |
276 AddMessageHandler(handler.release()->Attach(this)); | 285 AddMessageHandler(handler.release()->Attach(this)); |
277 } | 286 } |
278 } | 287 } |
OLD | NEW |