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

Unified Diff: components/translate/core/browser/translate_script.cc

Issue 2108053004: add code to propagate finch config TranslateServerStudy server_params to translate element code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove header changes and unnessary initialization Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/translate/core/browser/resources/translate.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/translate/core/browser/translate_script.cc
diff --git a/components/translate/core/browser/translate_script.cc b/components/translate/core/browser/translate_script.cc
index 511ac6c9057f43a17e42fa0c7e400b8662e0c58a..875fc7f45e3633100129b3a6e55b036f00295650 100644
--- a/components/translate/core/browser/translate_script.cc
+++ b/components/translate/core/browser/translate_script.cc
@@ -19,6 +19,7 @@
#include "components/translate/core/browser/translate_url_util.h"
#include "components/translate/core/common/translate_switches.h"
#include "components/translate/core/common/translate_util.h"
+#include "components/variations/variations_associated_data.h"
#include "google_apis/google_api_keys.h"
#include "grit/components_resources.h"
#include "net/base/escape.h"
@@ -48,6 +49,8 @@ const char TranslateScript::kCssLoaderCallbackQueryValue[] =
const char TranslateScript::kJavascriptLoaderCallbackQueryName[] = "jlc";
const char TranslateScript::kJavascriptLoaderCallbackQueryValue[] =
"cr.googleTranslate.onLoadJavascript";
+const char kTranslateServerStudy[] = "TranslateServerStudy";
+const char kServerParams[] = "server_params";
TranslateScript::TranslateScript()
: expiration_delay_(base::TimeDelta::FromDays(kExpirationDelayDays)),
@@ -132,6 +135,16 @@ void TranslateScript::OnScriptFetchComplete(
data_ = base::StringPrintf("var translateApiKey = '%s';\n",
google_apis::GetAPIKey().c_str());
+ // Insert server params to pass experimental params to google translate
+ // server.
+ std::string server_params;
+ std::map<std::string, std::string> params;
+ if (variations::GetVariationParams(kTranslateServerStudy, &params)) {
+ server_params = params[kServerParams];
+ }
+ base::StringAppendF(&data_, "var serverParams = '%s';\n",
groby-ooo-7-16 2016/08/04 01:31:36 Last question, and then I promise I let this go. D
+ server_params.c_str());
+
GURL security_origin = translate::GetTranslateSecurityOrigin();
base::StringAppendF(
&data_, "var securityOrigin = '%s';", security_origin.spec().c_str());
« no previous file with comments | « components/translate/core/browser/resources/translate.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698