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

Side by Side Diff: chrome/browser/search/contextual_search_promo_source_android.cc

Issue 450433002: [Resources] Move roboto.woff and add roboto.woff2 to a roboto/ directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/roboto/roboto.woff2 ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "grit/browser_resources.h" 12 #include "grit/browser_resources.h"
13 #include "grit/chromium_strings.h" 13 #include "grit/chromium_strings.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/base/webui/jstemplate_builder.h" 17 #include "ui/base/webui/jstemplate_builder.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace { 20 namespace {
21 21
22 const char kPromoHTMLPath[] = "/promo.html"; 22 const char kPromoHTMLPath[] = "/promo.html";
23 const char kPromoCSSPath[] = "/promo.css"; 23 const char kPromoCSSPath[] = "/promo.css";
24 const char kPromoJSPath[] = "/promo.js"; 24 const char kPromoJSPath[] = "/promo.js";
25 const char kPromoRobotoPath[] = "/roboto.woff"; 25 const char kRobotoWoffPath[] = "/roboto.woff";
26 const char kRobotoWoff2Path[] = "/roboto.woff2";
26 27
27 } // namespace 28 } // namespace
28 29
29 ContextualSearchPromoSourceAndroid::ContextualSearchPromoSourceAndroid() {} 30 ContextualSearchPromoSourceAndroid::ContextualSearchPromoSourceAndroid() {}
30 31
31 ContextualSearchPromoSourceAndroid::~ContextualSearchPromoSourceAndroid() {} 32 ContextualSearchPromoSourceAndroid::~ContextualSearchPromoSourceAndroid() {}
32 33
33 void ContextualSearchPromoSourceAndroid::StartDataRequest( 34 void ContextualSearchPromoSourceAndroid::StartDataRequest(
34 const std::string& path_and_query, int render_process_id, 35 const std::string& path_and_query, int render_process_id,
35 int render_frame_id, 36 int render_frame_id,
36 const content::URLDataSource::GotDataCallback& callback) { 37 const content::URLDataSource::GotDataCallback& callback) {
37 GURL url(std::string(chrome::kChromeUIContextualSearchPromoURL) + "/" + 38 GURL url(std::string(chrome::kChromeUIContextualSearchPromoURL) + "/" +
38 path_and_query); 39 path_and_query);
39 std::string path(url.path()); 40 std::string path(url.path());
40 if (path == kPromoHTMLPath) { 41 if (path == kPromoHTMLPath) {
41 SendHtmlWithStrings(callback); 42 SendHtmlWithStrings(callback);
42 } else if (path == kPromoCSSPath) { 43 } else if (path == kPromoCSSPath) {
43 SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_CSS, callback); 44 SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_CSS, callback);
44 } else if (path == kPromoJSPath) { 45 } else if (path == kPromoJSPath) {
45 SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_JS, callback); 46 SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_JS, callback);
46 } else if (path == kPromoRobotoPath) { 47 } else if (path == kRobotoWoffPath) {
47 SendResource(IDR_CONTEXTUAL_SEARCH_ROBOTO_WOFF, callback); 48 SendResource(IDR_ROBOTO_WOFF, callback);
49 } else if (path == kRobotoWoff2Path) {
50 SendResource(IDR_ROBOTO_WOFF2, callback);
48 } else { 51 } else {
49 callback.Run(NULL); 52 callback.Run(NULL);
50 } 53 }
51 } 54 }
52 55
53 std::string ContextualSearchPromoSourceAndroid::GetSource() const { 56 std::string ContextualSearchPromoSourceAndroid::GetSource() const {
54 return chrome::kChromeUIContextualSearchPromoHost; 57 return chrome::kChromeUIContextualSearchPromoHost;
55 } 58 }
56 59
57 std::string ContextualSearchPromoSourceAndroid::GetMimeType( 60 std::string ContextualSearchPromoSourceAndroid::GetMimeType(
58 const std::string& path_and_query) const { 61 const std::string& path_and_query) const {
59 std::string path(GURL("chrome://host/" + path_and_query).path()); 62 std::string path(GURL("chrome://host/" + path_and_query).path());
60 if (EndsWith(path, ".js", false)) return "application/javascript"; 63 if (EndsWith(path, ".js", false)) return "application/javascript";
61 if (EndsWith(path, ".png", false)) return "image/png"; 64 if (EndsWith(path, ".png", false)) return "image/png";
62 if (EndsWith(path, ".css", false)) return "text/css"; 65 if (EndsWith(path, ".css", false)) return "text/css";
63 if (EndsWith(path, ".html", false)) return "text/html"; 66 if (EndsWith(path, ".html", false)) return "text/html";
64 if (EndsWith(path, ".woff", false)) return "font/woff"; 67 if (EndsWith(path, ".woff", false)) return "font/woff";
68 if (EndsWith(path, ".woff2", false)) return "font/woff2";
65 return ""; 69 return "";
66 } 70 }
67 71
68 bool ContextualSearchPromoSourceAndroid::ShouldDenyXFrameOptions() const { 72 bool ContextualSearchPromoSourceAndroid::ShouldDenyXFrameOptions() const {
69 return false; 73 return false;
70 } 74 }
71 75
72 bool 76 bool
73 ContextualSearchPromoSourceAndroid::ShouldAddContentSecurityPolicy() const { 77 ContextualSearchPromoSourceAndroid::ShouldAddContentSecurityPolicy() const {
74 return false; 78 return false;
(...skipping 16 matching lines...) Expand all
91 "optIn", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTIN)); 95 "optIn", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTIN));
92 strings_data.SetString( 96 strings_data.SetString(
93 "optOut", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTOUT)); 97 "optOut", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTOUT));
94 base::StringPiece html( 98 base::StringPiece html(
95 ResourceBundle::GetSharedInstance().GetRawDataResource( 99 ResourceBundle::GetSharedInstance().GetRawDataResource(
96 IDR_CONTEXTUAL_SEARCH_PROMO_HTML)); 100 IDR_CONTEXTUAL_SEARCH_PROMO_HTML));
97 webui::UseVersion2 version; 101 webui::UseVersion2 version;
98 std::string response(webui::GetI18nTemplateHtml(html, &strings_data)); 102 std::string response(webui::GetI18nTemplateHtml(html, &strings_data));
99 callback.Run(base::RefCountedString::TakeString(&response)); 103 callback.Run(base::RefCountedString::TakeString(&response));
100 } 104 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/roboto/roboto.woff2 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698