Commit 3b2937a1 authored by mathp@chromium.org's avatar mathp@chromium.org

[Resources] Add the Roboto font for contextual_search_promo_source and localize strings.

BUG=374932
TBR=jam
TEST=manual

Review URL: https://codereview.chromium.org/392273004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284003 0039d316-1c4b-4281-b951-d872f2087c98
parent 5b92d4e1
...@@ -1214,6 +1214,17 @@ Signing in anyway will merge Chromium information like bookmarks, history, and o ...@@ -1214,6 +1214,17 @@ Signing in anyway will merge Chromium information like bookmarks, history, and o
</message> </message>
</if> </if>
<!-- Contextual Search -->
<message name="IDS_CONTEXTUAL_SEARCH_PROMO_DESCRIPTION" desc="Description of the Contextual Search feature.">
Enabling "Tap to Search" provides an easy way to search for terms on a web page by simply tapping on them. The word tapped and surrounding page will be sent to Google.
</message>
<message name="IDS_CONTEXTUAL_SEARCH_PROMO_OPTIN" desc="Text for the button the user clicks to opt in.">
Yes, please
</message>
<message name="IDS_CONTEXTUAL_SEARCH_PROMO_OPTOUT" desc="Text for the button the user clicks to opt out.">
No, thanks
</message>
<!-- Update bubble --> <!-- Update bubble -->
<message name="IDS_REINSTALL_APP" desc="Text for the button the user clicks to reinstall the app."> <message name="IDS_REINSTALL_APP" desc="Text for the button the user clicks to reinstall the app.">
Reinstall Chromium Reinstall Chromium
......
...@@ -1139,6 +1139,17 @@ Signing in anyway will merge Chrome information like bookmarks, history, and oth ...@@ -1139,6 +1139,17 @@ Signing in anyway will merge Chrome information like bookmarks, history, and oth
</message> </message>
</if> </if>
<!-- Contextual Search -->
<message name="IDS_CONTEXTUAL_SEARCH_PROMO_DESCRIPTION" desc="Description of the Contextual Search feature.">
Enabling "Tap to Search" provides an easy way to search for terms on a web page by simply tapping on them. The word tapped and surrounding page will be sent to Google.
</message>
<message name="IDS_CONTEXTUAL_SEARCH_PROMO_OPTIN" desc="Text for the button the user clicks to opt in.">
Yes, please
</message>
<message name="IDS_CONTEXTUAL_SEARCH_PROMO_OPTOUT" desc="Text for the button the user clicks to opt out.">
No, thanks
</message>
<!-- Update bubble --> <!-- Update bubble -->
<message name="IDS_REINSTALL_APP" desc="Text for the button the user clicks to reinstall the app."> <message name="IDS_REINSTALL_APP" desc="Text for the button the user clicks to reinstall the app.">
Reinstall Chrome Reinstall Chrome
......
...@@ -117,6 +117,7 @@ ...@@ -117,6 +117,7 @@
</if> </if>
<if expr="is_android"> <if expr="is_android">
<include name="IDR_CONTEXTUAL_SEARCH_PROMO_JS" file="resources\contextual_search\promo.js" type="BINDATA" /> <include name="IDR_CONTEXTUAL_SEARCH_PROMO_JS" file="resources\contextual_search\promo.js" type="BINDATA" />
<include name="IDR_CONTEXTUAL_SEARCH_ROBOTO_WOFF" file="resources\contextual_search\roboto.woff" type="BINDATA" />
</if> </if>
<if expr="enable_printing"> <if expr="enable_printing">
<include name="IDR_CLOUDPRINT_MANIFEST" file="resources\cloud_print_app\manifest.json" type="BINDATA" /> <include name="IDR_CLOUDPRINT_MANIFEST" file="resources\cloud_print_app\manifest.json" type="BINDATA" />
......
/* Copyright 2014 The Chromium Authors. All rights reserved. /* Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. found in the LICENSE file.
TODO(mathp): Add some CSS here.
*/ */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src: url(/roboto.woff) format('woff');
}
body {
font-family: 'Roboto';
font-size: 1em;
}
p {
margin: 1em;
text-align: justify;
}
a {
color: black;
}
.colored {
color: rgb(66, 133, 244);
}
.label {
display: inline-block;
padding: 0.5em;
text-align: center;
width: 41%;
}
.label a {
font-weight: bold;
text-decoration: none;
text-transform: uppercase;
}
...@@ -5,14 +5,15 @@ ...@@ -5,14 +5,15 @@
found in the LICENSE file. --> found in the LICENSE file. -->
<head> <head>
<script src="promo.js"></script> <script src="promo.js"></script>
<script src="../../../../ui/webui/resources/js/util.js"></script>
<script src="../../../../ui/webui/resources/js/load_time_data.js"></script>
<link rel="stylesheet" href="promo.css"> <link rel="stylesheet" href="promo.css">
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no"> <meta name="viewport" content="width=device-width, user-scalable=no">
</head> </head>
<body> <body>
<!--TODO(mathp): Update this text. --> <p i18n-content="description"></p>
<p>Hello, world!</p> <div class='label'><a class='colored' href="#optin" i18n-content="optIn"></a></div>
<p><a href="#optin">Yes</a></p> <div class='label'><a href="#optout" i18n-content="optOut"></a></div>
<p><a href="#optout">No</a></p>
</body> </body>
</html> </html>
...@@ -7,9 +7,14 @@ ...@@ -7,9 +7,14 @@
#include "base/memory/ref_counted_memory.h" #include "base/memory/ref_counted_memory.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "grit/browser_resources.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/resource/resource_bundle.h"
#include "ui/base/webui/jstemplate_builder.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace { namespace {
...@@ -17,6 +22,7 @@ namespace { ...@@ -17,6 +22,7 @@ namespace {
const char kPromoHTMLPath[] = "/promo.html"; const char kPromoHTMLPath[] = "/promo.html";
const char kPromoCSSPath[] = "/promo.css"; const char kPromoCSSPath[] = "/promo.css";
const char kPromoJSPath[] = "/promo.js"; const char kPromoJSPath[] = "/promo.js";
const char kPromoRobotoPath[] = "/roboto.woff";
} // namespace } // namespace
...@@ -32,11 +38,13 @@ void ContextualSearchPromoSource::StartDataRequest( ...@@ -32,11 +38,13 @@ void ContextualSearchPromoSource::StartDataRequest(
path_and_query); path_and_query);
std::string path(url.path()); std::string path(url.path());
if (path == kPromoHTMLPath) { if (path == kPromoHTMLPath) {
SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_HTML, callback); SendHtmlWithStrings(callback);
} else if (path == kPromoCSSPath) { } else if (path == kPromoCSSPath) {
SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_CSS, callback); SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_CSS, callback);
} else if (path == kPromoJSPath) { } else if (path == kPromoJSPath) {
SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_JS, callback); SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_JS, callback);
} else if (path == kPromoRobotoPath) {
SendResource(IDR_CONTEXTUAL_SEARCH_ROBOTO_WOFF, callback);
} else { } else {
callback.Run(NULL); callback.Run(NULL);
} }
...@@ -53,6 +61,7 @@ std::string ContextualSearchPromoSource::GetMimeType( ...@@ -53,6 +61,7 @@ std::string ContextualSearchPromoSource::GetMimeType(
if (EndsWith(path, ".png", false)) return "image/png"; if (EndsWith(path, ".png", false)) return "image/png";
if (EndsWith(path, ".css", false)) return "text/css"; if (EndsWith(path, ".css", false)) return "text/css";
if (EndsWith(path, ".html", false)) return "text/html"; if (EndsWith(path, ".html", false)) return "text/html";
if (EndsWith(path, ".woff", false)) return "font/woff";
return ""; return "";
} }
...@@ -60,9 +69,31 @@ bool ContextualSearchPromoSource::ShouldDenyXFrameOptions() const { ...@@ -60,9 +69,31 @@ bool ContextualSearchPromoSource::ShouldDenyXFrameOptions() const {
return false; return false;
} }
bool ContextualSearchPromoSource::ShouldAddContentSecurityPolicy() const {
return false;
}
void ContextualSearchPromoSource::SendResource( void ContextualSearchPromoSource::SendResource(
int resource_id, const content::URLDataSource::GotDataCallback& callback) { int resource_id, const content::URLDataSource::GotDataCallback& callback) {
scoped_refptr<base::RefCountedStaticMemory> response( scoped_refptr<base::RefCountedStaticMemory> response(
ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id)); ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id));
callback.Run(response.get()); 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));
}
...@@ -26,12 +26,17 @@ class ContextualSearchPromoSource : public content::URLDataSource { ...@@ -26,12 +26,17 @@ class ContextualSearchPromoSource : public content::URLDataSource {
virtual std::string GetMimeType( virtual std::string GetMimeType(
const std::string& path_and_query) const OVERRIDE; const std::string& path_and_query) const OVERRIDE;
virtual bool ShouldDenyXFrameOptions() const OVERRIDE; virtual bool ShouldDenyXFrameOptions() const OVERRIDE;
virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE;
// Sends unmodified resource bytes. // Sends unmodified resource bytes.
void SendResource( void SendResource(
int resource_id, int resource_id,
const content::URLDataSource::GotDataCallback& callback); const content::URLDataSource::GotDataCallback& callback);
// Sends HTML with localized strings.
void SendHtmlWithStrings(
const content::URLDataSource::GotDataCallback& callback);
private: private:
DISALLOW_COPY_AND_ASSIGN(ContextualSearchPromoSource); DISALLOW_COPY_AND_ASSIGN(ContextualSearchPromoSource);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment