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

Unified Diff: chrome/browser/dom_ui/new_tab_ui.cc

Issue 269095: NTP: Fix startup visual state ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/new_new_tab.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/new_tab_ui.cc
===================================================================
--- chrome/browser/dom_ui/new_tab_ui.cc (revision 29178)
+++ chrome/browser/dom_ui/new_tab_ui.cc (working copy)
@@ -1198,6 +1198,11 @@
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 @@
}
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_);
}
« no previous file with comments | « no previous file | chrome/browser/resources/new_new_tab.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698