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

Unified Diff: chrome/browser/resources/translate.js

Issue 22645015: Translate: cleanup on how to pass api key to the script (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (rebase) Created 7 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 | « no previous file | chrome/browser/translate/translate_script.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/translate.js
diff --git a/chrome/browser/resources/translate.js b/chrome/browser/resources/translate.js
index 773189e097da556f74170762808dac4e078efab6..6658406760dc92b3e5be9e99d85908f13f9d604c 100644
--- a/chrome/browser/resources/translate.js
+++ b/chrome/browser/resources/translate.js
@@ -9,7 +9,11 @@
var cr = {};
-cr.googleTranslate = (function(key) {
+/**
+ * An object to provide functions to interact with the Translate library.
+ * @type {object}
+ */
+cr.googleTranslate = (function() {
/**
* The Translate Element library's instance.
* @type {object}
@@ -259,11 +263,14 @@ cr.googleTranslate = (function(key) {
loadedTime = performance.now();
try {
lib = google.translate.TranslateService({
- 'key': key,
+ // translateApiKey is predefined by translate_script.cc.
+ 'key': translateApiKey,
'useSecureConnection': true
});
+ translateApiKey = undefined;
} catch (err) {
error = true;
+ translateApiKey = undefined;
return;
}
// The TranslateService is not available immediately as it needs to start
@@ -271,4 +278,4 @@ cr.googleTranslate = (function(key) {
checkLibReady();
}
};
-})/* Calling code '(|key|);' will be appended by TranslateHelper in C++ here. */
+})();
« no previous file with comments | « no previous file | chrome/browser/translate/translate_script.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698