From 2189596918ca3ac8f6cf06eeefc53888b36b4f64 Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Wed, 5 Jun 2013 22:29:40 -0400 Subject: [PATCH] Bug 861164 - use different search URLs for tablet vs. non-tablet r=gavin --- toolkit/components/search/nsSearchService.js | 27 +++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/toolkit/components/search/nsSearchService.js b/toolkit/components/search/nsSearchService.js index 82bdcfe1df4..c6053a991df 100644 --- a/toolkit/components/search/nsSearchService.js +++ b/toolkit/components/search/nsSearchService.js @@ -2504,10 +2504,35 @@ Engine.prototype = { this._lazySerializeToFile(); }, +#ifdef ANDROID + get _defaultMobileResponseType() { + let type = URLTYPE_SEARCH_HTML; + + let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2); + let isTablet = sysInfo.get("tablet"); + if (isTablet && this.supportsResponseType("application/x-moz-tabletsearch")) { + // Check for a tablet-specific search URL override + type = "application/x-moz-tabletsearch"; + } else if (!isTablet && this.supportsResponseType("application/x-moz-phonesearch")) { + // Check for a phone-specific search URL override + type = "application/x-moz-phonesearch"; + } + + delete this._defaultMobileResponseType; + return this._defaultMobileResponseType = type; + }, +#endif + // from nsISearchEngine getSubmission: function SRCH_ENG_getSubmission(aData, aResponseType, aPurpose) { - if (!aResponseType) +#ifdef ANDROID + if (!aResponseType) { + aResponseType = this._defaultMobileResponseType; + } +#endif + if (!aResponseType) { aResponseType = URLTYPE_SEARCH_HTML; + } var url = this._getURLOfType(aResponseType);