diff options
author | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 19:47:41 +0000 |
---|---|---|
committer | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 19:47:41 +0000 |
commit | 9b83b4880858f85eb0ec47929fa6505553d29614 (patch) | |
tree | 5a710c60cfed56ed4e4e1ae36b1273b8a97b1d5a /chrome/browser/dom_ui | |
parent | d8365fca0e6fbb13c77472b170549d8254f85871 (diff) | |
download | chromium_src-9b83b4880858f85eb0ec47929fa6505553d29614.zip chromium_src-9b83b4880858f85eb0ec47929fa6505553d29614.tar.gz chromium_src-9b83b4880858f85eb0ec47929fa6505553d29614.tar.bz2 |
NTP: Fix startup visual state
This inject the template data earlier in the document so that we can set
the initial visual state based on the user preference. This prevents
flickering when the user is not showing the most visited thumbnails.
BUG=24513
TEST=Use a theme with a background image to make this easier to spot.
Hide the most visited. Restart Chrome. The thumbnails should not flicker
Review URL: http://codereview.chromium.org/269095
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc index 30a683d..238a46a 100644 --- a/chrome/browser/dom_ui/new_tab_ui.cc +++ b/chrome/browser/dom_ui/new_tab_ui.cc @@ -1198,6 +1198,11 @@ void NewTabUI::NewTabHTMLSource::InitFullHTML() { Animation::ShouldRenderRichAnimation() ? L"true" : L"false"; localized_strings.SetString(L"anim", anim); + // Pass the shown_sections pref early so that we can prevent flicker. + const int shown_sections = profile_->GetPrefs()->GetInteger( + prefs::kNTPShownSections); + localized_strings.SetInteger(L"shown_sections", shown_sections); + // In case we have the new new tab page enabled we first try to read the file // provided on the command line. If that fails we just get the resource from // the resource bundle. @@ -1215,7 +1220,16 @@ void NewTabUI::NewTabHTMLSource::InitFullHTML() { } full_html_.assign(new_tab_html.data(), new_tab_html.size()); - jstemplate_builder::AppendJsonHtml(&localized_strings, &full_html_); - jstemplate_builder::AppendI18nTemplateSourceHtml(&full_html_); + + // Inject the template data into the HTML so that it is available before any + // layout is needed. + std::string json_html; + jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html); + + static const std::string template_data_placeholder = + "<!-- template data placeholder -->"; + ReplaceFirstSubstringAfterOffset(&full_html_, 0, template_data_placeholder, + json_html); + jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html_); } |