| 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/string16.h" | 7 #include "base/string16.h" |
| 8 #include "base/string_piece.h" | 8 #include "base/string_piece.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); | 73 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); |
| 74 | 74 |
| 75 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). | 75 base::StringPiece new_tab_html(ResourceBundle::GetSharedInstance(). |
| 76 GetRawDataResource(IDR_NEW_TAB_4_HTML)); | 76 GetRawDataResource(IDR_NEW_TAB_4_HTML)); |
| 77 | 77 |
| 78 const char* new_tab_link = kLearnMoreIncognitoUrl; | 78 const char* new_tab_link = kLearnMoreIncognitoUrl; |
| 79 string16 learnMoreLink = ASCIIToUTF16( | 79 string16 learnMoreLink = ASCIIToUTF16( |
| 80 google_util::AppendGoogleLocaleParam(GURL(new_tab_link)).spec()); | 80 google_util::AppendGoogleLocaleParam(GURL(new_tab_link)).spec()); |
| 81 localized_strings.SetString("content", | 81 localized_strings.SetString("content", |
| 82 l10n_util::GetStringFUTF16(IDS_NEW_TAB_OTR_MESSAGE, learnMoreLink)); | 82 l10n_util::GetStringFUTF16(IDS_NEW_TAB_INCOGNITO_MESSAGE, learnMoreLink)); |
| 83 | 83 |
| 84 // Load the new tab page appropriate for this build. | 84 // Load the new tab page appropriate for this build. |
| 85 std::string full_html; | 85 std::string full_html; |
| 86 | 86 |
| 87 // Inject the template data into the HTML so that it is available before any | 87 // Inject the template data into the HTML so that it is available before any |
| 88 // layout is needed. | 88 // layout is needed. |
| 89 std::string json_html; | 89 std::string json_html; |
| 90 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html); | 90 jstemplate_builder::AppendJsonHtml(&localized_strings, &json_html); |
| 91 | 91 |
| 92 static const base::StringPiece template_data_placeholder( | 92 static const base::StringPiece template_data_placeholder( |
| 93 "<!-- template data placeholder -->"); | 93 "<!-- template data placeholder -->"); |
| 94 size_t pos = new_tab_html.find(template_data_placeholder); | 94 size_t pos = new_tab_html.find(template_data_placeholder); |
| 95 | 95 |
| 96 if (pos != base::StringPiece::npos) { | 96 if (pos != base::StringPiece::npos) { |
| 97 full_html.assign(new_tab_html.data(), pos); | 97 full_html.assign(new_tab_html.data(), pos); |
| 98 full_html.append(json_html); | 98 full_html.append(json_html); |
| 99 size_t after_offset = pos + template_data_placeholder.size(); | 99 size_t after_offset = pos + template_data_placeholder.size(); |
| 100 full_html.append(new_tab_html.data() + after_offset, | 100 full_html.append(new_tab_html.data() + after_offset, |
| 101 new_tab_html.size() - after_offset); | 101 new_tab_html.size() - after_offset); |
| 102 } else { | 102 } else { |
| 103 NOTREACHED(); | 103 NOTREACHED(); |
| 104 full_html.assign(new_tab_html.data(), new_tab_html.size()); | 104 full_html.assign(new_tab_html.data(), new_tab_html.size()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 new_tab_html_ = base::RefCountedString::TakeString(&full_html); | 107 new_tab_html_ = base::RefCountedString::TakeString(&full_html); |
| 108 } | 108 } |
| OLD | NEW |