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

Unified Diff: chrome/browser/resources/hotword_helper/manager.js

Issue 277523005: [Hotword] Add new base URLs for the additional languages so it works on their respective local sear… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updating isEligibleUrl Created 6 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/hotword_helper/manager.js
diff --git a/chrome/browser/resources/hotword_helper/manager.js b/chrome/browser/resources/hotword_helper/manager.js
index 3fcdb05653ff594c011a009a53b0208a89a87df7..89848034589ff75f2ac5a3cca9e51ffdf3e7d031 100644
--- a/chrome/browser/resources/hotword_helper/manager.js
+++ b/chrome/browser/resources/hotword_helper/manager.js
@@ -124,6 +124,27 @@ OptInManager.prototype.handleMessage_ = function(
return false;
};
+/**
+ * Helper function to test urls.
James Hawkins 2014/05/09 02:54:27 Can you update the method name and documentation t
rpetterson 2014/05/09 06:07:20 Done.
+ * @param {string} url Url to check.
+ * @param {string} base Base url to compare against..
+ * @return {boolean} True if url is eligible hotword url.
+ */
+OptInManager.prototype.checkUrl = function(url, base) {
+ if (!url)
+ return false;
+
+ if (url === base + '/' ||
+ url.indexOf(base + '/_/chrome/newtab?') === 0 || // Appcache NTP.
+ url.indexOf(base + '/?') === 0 ||
+ url.indexOf(base + '/#') === 0 ||
+ url.indexOf(base + '/webhp') === 0 ||
+ url.indexOf(base + '/search') === 0) {
+ return true;
+ }
+ return false;
+
+};
/**
* Determines if a URL is eligible for hotwording. For now, the
@@ -136,20 +157,28 @@ OptInManager.prototype.isEligibleUrl = function(url) {
return false;
var baseUrls = [
- 'https://www.google.com',
- 'chrome://newtab',
- 'https://encrypted.google.com'
+ 'chrome://newtab'
+ ];
+ var baseGoogleUrls = [
+ 'https://www.google.',
+ 'https://encrypted.google.'
];
+ var tlds = [
+ 'com',
+ 'co.uk',
+ 'de',
+ 'fr',
+ 'ru'
+ ];
+
+ if (this.checkUrl(url, baseUrls[0]))
+ return true;
- for (var i = 0; i < baseUrls.length; i++) {
- var base = baseUrls[i];
- if (url === base + '/' ||
- url.indexOf(base + '/_/chrome/newtab?') === 0 || // Appcache NTP.
- url.indexOf(base + '/?') === 0 ||
- url.indexOf(base + '/#') === 0 ||
- url.indexOf(base + '/webhp') === 0 ||
- url.indexOf(base + '/search') === 0) {
- return true;
+ for (var i = 0; i < baseGoogleUrls.length; i++) {
+ for (var j = 0; j < tlds.length; j++) {
+ var base = baseGoogleUrls[i] + tlds[j];
+ if (this.checkUrl(url, base))
+ return true;
}
}
return false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698