OLD | NEW |
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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 } | 324 } |
325 | 325 |
326 void OptionsUI::RenderViewCreated(RenderViewHost* render_view_host) { | 326 void OptionsUI::RenderViewCreated(RenderViewHost* render_view_host) { |
327 SetCommandLineString(render_view_host); | 327 SetCommandLineString(render_view_host); |
328 } | 328 } |
329 | 329 |
330 void OptionsUI::RenderViewReused(RenderViewHost* render_view_host) { | 330 void OptionsUI::RenderViewReused(RenderViewHost* render_view_host) { |
331 SetCommandLineString(render_view_host); | 331 SetCommandLineString(render_view_host); |
332 } | 332 } |
333 | 333 |
334 void OptionsUI::DidBecomeActiveForReusedRenderView() { | |
335 // When the renderer is re-used (e.g., for back/forward navigation within | |
336 // options), the handlers are torn down and rebuilt, so are no longer | |
337 // initialized, but the web page's DOM may remain intact, in which case onload | |
338 // won't fire to initilize the handlers. To make sure initialization always | |
339 // happens, call reinitializeCore (which is a no-op unless the DOM was already | |
340 // initialized). | |
341 web_ui()->CallJavascriptFunction("OptionsPage.reinitializeCore"); | |
342 } | |
343 | |
344 // static | 334 // static |
345 void OptionsUI::ProcessAutocompleteSuggestions( | 335 void OptionsUI::ProcessAutocompleteSuggestions( |
346 const AutocompleteResult& autocompleteResult, | 336 const AutocompleteResult& autocompleteResult, |
347 ListValue * const suggestions) { | 337 ListValue * const suggestions) { |
348 for (size_t i = 0; i < autocompleteResult.size(); ++i) { | 338 for (size_t i = 0; i < autocompleteResult.size(); ++i) { |
349 const AutocompleteMatch& match = autocompleteResult.match_at(i); | 339 const AutocompleteMatch& match = autocompleteResult.match_at(i); |
350 AutocompleteMatch::Type type = match.type; | 340 AutocompleteMatch::Type type = match.type; |
351 if (type != AutocompleteMatch::HISTORY_URL && | 341 if (type != AutocompleteMatch::HISTORY_URL && |
352 type != AutocompleteMatch::HISTORY_TITLE && | 342 type != AutocompleteMatch::HISTORY_TITLE && |
353 type != AutocompleteMatch::HISTORY_BODY && | 343 type != AutocompleteMatch::HISTORY_BODY && |
(...skipping 11 matching lines...) Expand all Loading... |
365 // static | 355 // static |
366 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { | 356 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { |
367 return ResourceBundle::GetSharedInstance(). | 357 return ResourceBundle::GetSharedInstance(). |
368 LoadDataResourceBytes(IDR_SETTINGS_FAVICON); | 358 LoadDataResourceBytes(IDR_SETTINGS_FAVICON); |
369 } | 359 } |
370 | 360 |
371 void OptionsUI::InitializeHandlers() { | 361 void OptionsUI::InitializeHandlers() { |
372 Profile* profile = Profile::FromWebUI(web_ui()); | 362 Profile* profile = Profile::FromWebUI(web_ui()); |
373 DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession()); | 363 DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession()); |
374 | 364 |
375 // The reinitialize call from DidBecomeActiveForReusedRenderView end up being | 365 // A new web page DOM has been brought up in an existing renderer, causing |
376 // delivered after a new web page DOM has been brought up in an existing | 366 // this method to be called twice. If that happens, ignore the second call. |
377 // renderer (due to IPC delays), causing this method to be called twice. If | |
378 // that happens, ignore the second call. | |
379 if (!initialized_handlers_) { | 367 if (!initialized_handlers_) { |
380 for (size_t i = 0; i < handlers_.size(); ++i) | 368 for (size_t i = 0; i < handlers_.size(); ++i) |
381 handlers_[i]->InitializeHandler(); | 369 handlers_[i]->InitializeHandler(); |
382 initialized_handlers_ = true; | 370 initialized_handlers_ = true; |
383 } | 371 } |
384 | 372 |
385 // Always initialize the page as when handlers are left over we still need to | 373 // Always initialize the page as when handlers are left over we still need to |
386 // do various things like show/hide sections and send data to the Javascript. | 374 // do various things like show/hide sections and send data to the Javascript. |
387 for (size_t i = 0; i < handlers_.size(); ++i) | 375 for (size_t i = 0; i < handlers_.size(); ++i) |
388 handlers_[i]->InitializePage(); | 376 handlers_[i]->InitializePage(); |
(...skipping 24 matching lines...) Expand all Loading... |
413 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString()); | 401 WideToASCII(CommandLine::ForCurrentProcess()->GetCommandLineString()); |
414 #else | 402 #else |
415 command_line_string = | 403 command_line_string = |
416 CommandLine::ForCurrentProcess()->GetCommandLineString(); | 404 CommandLine::ForCurrentProcess()->GetCommandLineString(); |
417 #endif | 405 #endif |
418 | 406 |
419 render_view_host->SetWebUIProperty("commandLineString", command_line_string); | 407 render_view_host->SetWebUIProperty("commandLineString", command_line_string); |
420 } | 408 } |
421 | 409 |
422 } // namespace options2 | 410 } // namespace options2 |
OLD | NEW |