OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/search/contextual_search_promo_source_android.h" | 5 #include "chrome/browser/search/contextual_search_promo_source_android.h" |
6 | 6 |
7 #include "base/memory/ref_counted_memory.h" | 7 #include "base/memory/ref_counted_memory.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 void ContextualSearchPromoSourceAndroid::SendResource( | 80 void ContextualSearchPromoSourceAndroid::SendResource( |
81 int resource_id, const content::URLDataSource::GotDataCallback& callback) { | 81 int resource_id, const content::URLDataSource::GotDataCallback& callback) { |
82 scoped_refptr<base::RefCountedStaticMemory> response( | 82 scoped_refptr<base::RefCountedStaticMemory> response( |
83 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id)); | 83 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id)); |
84 callback.Run(response.get()); | 84 callback.Run(response.get()); |
85 } | 85 } |
86 | 86 |
87 void ContextualSearchPromoSourceAndroid::SendHtmlWithStrings( | 87 void ContextualSearchPromoSourceAndroid::SendHtmlWithStrings( |
88 const content::URLDataSource::GotDataCallback& callback) { | 88 const content::URLDataSource::GotDataCallback& callback) { |
89 base::DictionaryValue strings_data; | 89 base::DictionaryValue strings_data; |
| 90 // The three following statements are part of the description paragraph. |
90 strings_data.SetString( | 91 strings_data.SetString( |
91 "description", | 92 "description-1", |
92 l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_DESCRIPTION)); | 93 l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_DESCRIPTION_1)); |
| 94 strings_data.SetString( |
| 95 "feature-name", |
| 96 l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_FEATURE_NAME)); |
| 97 strings_data.SetString( |
| 98 "description-2", |
| 99 l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_DESCRIPTION_2)); |
| 100 |
93 strings_data.SetString( | 101 strings_data.SetString( |
94 "heading", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_HEADER)); | 102 "heading", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_HEADER)); |
95 strings_data.SetString( | 103 strings_data.SetString( |
96 "optIn", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTIN)); | 104 "optIn", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTIN)); |
97 strings_data.SetString( | 105 strings_data.SetString( |
98 "optOut", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTOUT)); | 106 "optOut", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTOUT)); |
99 base::StringPiece html( | 107 base::StringPiece html( |
100 ResourceBundle::GetSharedInstance().GetRawDataResource( | 108 ResourceBundle::GetSharedInstance().GetRawDataResource( |
101 IDR_CONTEXTUAL_SEARCH_PROMO_HTML)); | 109 IDR_CONTEXTUAL_SEARCH_PROMO_HTML)); |
102 webui::UseVersion2 version; | 110 webui::UseVersion2 version; |
103 std::string response(webui::GetI18nTemplateHtml(html, &strings_data)); | 111 std::string response(webui::GetI18nTemplateHtml(html, &strings_data)); |
104 callback.Run(base::RefCountedString::TakeString(&response)); | 112 callback.Run(base::RefCountedString::TakeString(&response)); |
105 } | 113 } |
OLD | NEW |