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

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

Issue 846833002: Make Roboto accessible from chrome://resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « chrome/browser/resources/roboto/roboto.woff2 ('k') | ui/webui/resources/roboto/OWNERS » ('j') | 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 <string> 7 #include <string>
8 8
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "chrome/grit/chromium_strings.h" 15 #include "chrome/grit/chromium_strings.h"
16 #include "components/variations/variations_associated_data.h" 16 #include "components/variations/variations_associated_data.h"
17 #include "grit/browser_resources.h" 17 #include "grit/browser_resources.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/base/webui/jstemplate_builder.h" 20 #include "ui/base/webui/jstemplate_builder.h"
21 #include "url/gurl.h" 21 #include "url/gurl.h"
22 22
23 namespace { 23 namespace {
24 24
25 const char kPromoConfigPath[] = "/config.js"; 25 const char kPromoConfigPath[] = "/config.js";
26 const char kPromoHTMLPath[] = "/promo.html"; 26 const char kPromoHTMLPath[] = "/promo.html";
27 const char kPromoCSSPath[] = "/promo.css"; 27 const char kPromoCSSPath[] = "/promo.css";
28 const char kPromoJSPath[] = "/promo.js"; 28 const char kPromoJSPath[] = "/promo.js";
29 const char kRobotoWoffPath[] = "/roboto.woff";
30 const char kRobotoWoff2Path[] = "/roboto.woff2";
31 29
32 // Field trial related constants. 30 // Field trial related constants.
33 const char kContextualSearchFieldTrialName[] = "ContextualSearch"; 31 const char kContextualSearchFieldTrialName[] = "ContextualSearch";
34 const char kContextualSearchHidePromoHeaderParam[] = "hide_promo_header"; 32 const char kContextualSearchHidePromoHeaderParam[] = "hide_promo_header";
35 const char kContextualSearchEnabledValue[] = "enabled"; 33 const char kContextualSearchEnabledValue[] = "enabled";
36 34
37 // Returns whether we should hide the first-run promo header. 35 // Returns whether we should hide the first-run promo header.
38 bool ShouldHidePromoHeader() { 36 bool ShouldHidePromoHeader() {
39 return variations::GetVariationParamValue( 37 return variations::GetVariationParamValue(
40 kContextualSearchFieldTrialName, kContextualSearchHidePromoHeaderParam) == 38 kContextualSearchFieldTrialName, kContextualSearchHidePromoHeaderParam) ==
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 path_and_query); 71 path_and_query);
74 std::string path(url.path()); 72 std::string path(url.path());
75 if (path == kPromoHTMLPath) { 73 if (path == kPromoHTMLPath) {
76 SendHtmlWithStrings(callback); 74 SendHtmlWithStrings(callback);
77 } else if (path == kPromoCSSPath) { 75 } else if (path == kPromoCSSPath) {
78 SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_CSS, callback); 76 SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_CSS, callback);
79 } else if (path == kPromoJSPath) { 77 } else if (path == kPromoJSPath) {
80 SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_JS, callback); 78 SendResource(IDR_CONTEXTUAL_SEARCH_PROMO_JS, callback);
81 } else if (path == kPromoConfigPath) { 79 } else if (path == kPromoConfigPath) {
82 SendConfigResource(callback); 80 SendConfigResource(callback);
83 } else if (path == kRobotoWoffPath) {
84 SendResource(IDR_ROBOTO_WOFF, callback);
85 } else if (path == kRobotoWoff2Path) {
86 SendResource(IDR_ROBOTO_WOFF2, callback);
87 } else { 81 } else {
88 callback.Run(NULL); 82 callback.Run(NULL);
89 } 83 }
90 } 84 }
91 85
92 std::string ContextualSearchPromoSourceAndroid::GetSource() const { 86 std::string ContextualSearchPromoSourceAndroid::GetSource() const {
93 return chrome::kChromeUIContextualSearchPromoHost; 87 return chrome::kChromeUIContextualSearchPromoHost;
94 } 88 }
95 89
96 std::string ContextualSearchPromoSourceAndroid::GetMimeType( 90 std::string ContextualSearchPromoSourceAndroid::GetMimeType(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 strings_data.SetString( 140 strings_data.SetString(
147 "optIn", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTIN)); 141 "optIn", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTIN));
148 strings_data.SetString( 142 strings_data.SetString(
149 "optOut", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTOUT)); 143 "optOut", l10n_util::GetStringUTF16(IDS_CONTEXTUAL_SEARCH_PROMO_OPTOUT));
150 base::StringPiece html( 144 base::StringPiece html(
151 ResourceBundle::GetSharedInstance().GetRawDataResource( 145 ResourceBundle::GetSharedInstance().GetRawDataResource(
152 IDR_CONTEXTUAL_SEARCH_PROMO_HTML)); 146 IDR_CONTEXTUAL_SEARCH_PROMO_HTML));
153 std::string response(webui::GetI18nTemplateHtml(html, &strings_data)); 147 std::string response(webui::GetI18nTemplateHtml(html, &strings_data));
154 callback.Run(base::RefCountedString::TakeString(&response)); 148 callback.Run(base::RefCountedString::TakeString(&response));
155 } 149 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/roboto/roboto.woff2 ('k') | ui/webui/resources/roboto/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698