| 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/ntp/ntp_resource_cache.h" | 5 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 localized_strings.SetString("content", | 116 localized_strings.SetString("content", |
| 117 l10n_util::GetStringFUTF16( | 117 l10n_util::GetStringFUTF16( |
| 118 IDS_NEW_TAB_OTR_MESSAGE_MOBILE, learnMoreLink)); | 118 IDS_NEW_TAB_OTR_MESSAGE_MOBILE, learnMoreLink)); |
| 119 | 119 |
| 120 // Load the new tab page appropriate for this build. | 120 // Load the new tab page appropriate for this build. |
| 121 std::string full_html; | 121 std::string full_html; |
| 122 | 122 |
| 123 // Inject the template data into the HTML so that it is available before any | 123 // Inject the template data into the HTML so that it is available before any |
| 124 // layout is needed. | 124 // layout is needed. |
| 125 std::string json_html; | 125 std::string json_html; |
| 126 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html); | 126 webui::AppendJsonHtml(&localized_strings, &json_html); |
| 127 | 127 |
| 128 static const base::StringPiece template_data_placeholder( | 128 static const base::StringPiece template_data_placeholder( |
| 129 "<!-- template data placeholder -->"); | 129 "<!-- template data placeholder -->"); |
| 130 size_t pos = new_tab_html.find(template_data_placeholder); | 130 size_t pos = new_tab_html.find(template_data_placeholder); |
| 131 | 131 |
| 132 if (pos != base::StringPiece::npos) { | 132 if (pos != base::StringPiece::npos) { |
| 133 full_html.assign(new_tab_html.data(), pos); | 133 full_html.assign(new_tab_html.data(), pos); |
| 134 full_html.append(json_html); | 134 full_html.append(json_html); |
| 135 size_t after_offset = pos + template_data_placeholder.size(); | 135 size_t after_offset = pos + template_data_placeholder.size(); |
| 136 full_html.append(new_tab_html.data() + after_offset, | 136 full_html.append(new_tab_html.data() + after_offset, |
| 137 new_tab_html.size() - after_offset); | 137 new_tab_html.size() - after_offset); |
| 138 } else { | 138 } else { |
| 139 NOTREACHED(); | 139 NOTREACHED(); |
| 140 full_html.assign(new_tab_html.data(), new_tab_html.size()); | 140 full_html.assign(new_tab_html.data(), new_tab_html.size()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 new_tab_html_ = base::RefCountedString::TakeString(&full_html); | 143 new_tab_html_ = base::RefCountedString::TakeString(&full_html); |
| 144 } | 144 } |
| OLD | NEW |