Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: chrome/browser/ui/webui/options2/options_ui2.cc

Issue 9693032: [uber page] Split up initialization of handlers from initialization of webui pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: code shuffling Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/webui/options2/options_ui2.h" 5 #include "chrome/browser/ui/webui/options2/options_ui2.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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 304 }
305 305
306 void OptionsUI::InitializeHandlers() { 306 void OptionsUI::InitializeHandlers() {
307 Profile* profile = Profile::FromWebUI(web_ui()); 307 Profile* profile = Profile::FromWebUI(web_ui());
308 DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession()); 308 DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession());
309 309
310 // The reinitialize call from DidBecomeActiveForReusedRenderView end up being 310 // The reinitialize call from DidBecomeActiveForReusedRenderView end up being
311 // delivered after a new web page DOM has been brought up in an existing 311 // delivered after a new web page DOM has been brought up in an existing
312 // renderer (due to IPC delays), causing this method to be called twice. If 312 // renderer (due to IPC delays), causing this method to be called twice. If
313 // that happens, ignore the second call. 313 // that happens, ignore the second call.
314 if (initialized_handlers_) 314 if (!initialized_handlers_) {
315 return; 315 for (size_t i = 0; i < handlers_.size(); ++i)
316 initialized_handlers_ = true; 316 handlers_[i]->InitializeHandler();
317 initialized_handlers_ = true;
318 }
317 319
320 // Always initialize the page as when handlers are left over we still need to
321 // do various things like show/hide sections and send data to the Javascript.
318 for (size_t i = 0; i < handlers_.size(); ++i) 322 for (size_t i = 0; i < handlers_.size(); ++i)
319 handlers_[i]->Initialize(); 323 handlers_[i]->InitializePage();
320 } 324 }
321 325
322 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, 326 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings,
323 OptionsPageUIHandler* handler_raw) { 327 OptionsPageUIHandler* handler_raw) {
324 scoped_ptr<OptionsPageUIHandler> handler(handler_raw); 328 scoped_ptr<OptionsPageUIHandler> handler(handler_raw);
325 DCHECK(handler.get()); 329 DCHECK(handler.get());
326 // Add only if handler's service is enabled. 330 // Add only if handler's service is enabled.
327 if (handler->IsEnabled()) { 331 if (handler->IsEnabled()) {
328 // Add handler to the list and also pass the ownership. 332 // Add handler to the list and also pass the ownership.
329 web_ui()->AddMessageHandler(handler.release()); 333 web_ui()->AddMessageHandler(handler.release());
(...skipping 10 matching lines...) Expand all
340 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString()); 344 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString());
341 #else 345 #else
342 command_line_string = 346 command_line_string =
343 CommandLine::ForCurrentProcess()->GetCommandLineString(); 347 CommandLine::ForCurrentProcess()->GetCommandLineString();
344 #endif 348 #endif
345 349
346 render_view_host->SetWebUIProperty("commandLineString", command_line_string); 350 render_view_host->SetWebUIProperty("commandLineString", command_line_string);
347 } 351 }
348 352
349 } // namespace options2 353 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698