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

Unified Diff: chrome/browser/search/contextual_search_promo_source.cc

Issue 392273004: [Resources] Add the Roboto font for contextual_search_promo_source and localize strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tweaks Created 6 years, 5 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 | « chrome/browser/search/contextual_search_promo_source.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/contextual_search_promo_source.cc
diff --git a/chrome/browser/search/contextual_search_promo_source.cc b/chrome/browser/search/contextual_search_promo_source.cc
index 0b9adf2d78285429453a5c3658472d034d0de67c..7c50b004fecf4a4487408b4b39b8850875bbf24f 100644
--- a/chrome/browser/search/contextual_search_promo_source.cc
+++ b/chrome/browser/search/contextual_search_promo_source.cc
@@ -7,9 +7,14 @@
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "base/values.h"
#include "chrome/common/url_constants.h"
#include "grit/browser_resources.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/webui/jstemplate_builder.h"
#include "url/gurl.h"
namespace {
@@ -17,6 +22,7 @@ namespace {
const char kPromoHTMLPath[] = "/promo.html";
const char kPromoCSSPath[] = "/promo.css";
const char kPromoJSPath[] = "/promo.js";
+const char kPromoRobotoPath[] = "/roboto.woff";
} // namespace
@@ -32,11 +38,13 @@ void ContextualSearchPromoSource::StartDataRequest(
path_and_query);
std::string path(url.path());
if (path == kPromoHTMLPath) {
- SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_HTML, callback);
+ SendHtmlWithStrings(callback);
} else if (path == kPromoCSSPath) {
SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_CSS, callback);
} else if (path == kPromoJSPath) {
SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_JS, callback);
+ } else if (path == kPromoRobotoPath) {
+ SendResource(IDR_CONTEXTUAL_SEARCH_ROBOTO_WOFF, callback);
} else {
callback.Run(NULL);
}
@@ -53,6 +61,7 @@ std::string ContextualSearchPromoSource::GetMimeType(
if (EndsWith(path, ".png", false)) return "image/png";
if (EndsWith(path, ".css", false)) return "text/css";
if (EndsWith(path, ".html", false)) return "text/html";
+ if (EndsWith(path, ".woff", false)) return "font/woff";
return "";
}
@@ -60,9 +69,31 @@ bool ContextualSearchPromoSource::ShouldDenyXFrameOptions() const {
return false;
}
+bool ContextualSearchPromoSource::ShouldAddContentSecurityPolicy() const {
+ return false;
+}
+
void ContextualSearchPromoSource::SendResource(
int resource_id, const content::URLDataSource::GotDataCallback& callback) {
scoped_refptr<base::RefCountedStaticMemory> response(
ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id));
callback.Run(response.get());
}
+
+void ContextualSearchPromoSource::SendHtmlWithStrings(
+ const content::URLDataSource::GotDataCallback& callback) {
+ base::DictionaryValue strings_data;
+ strings_data.SetString(
+ "description",
+ l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_DESCRIPTION));
+ strings_data.SetString(
+ "optIn", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTIN));
+ strings_data.SetString(
+ "optOut", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTOUT));
+ base::StringPiece html(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_CONTEXTUAL_SEARCH_PROMO_HTML));
+ webui::UseVersion2 version;
+ std::string response(webui::GetI18nTemplateHtml(html, &strings_data));
+ callback.Run(base::RefCountedString::TakeString(&response));
+}
« no previous file with comments | « chrome/browser/search/contextual_search_promo_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698