/** * @return the search domain. This is of the form "google.co.xx" or "google.com", used by UI code. */ public String getSearchDomain() { String domain = mSearchSettings.getSearchBaseDomain(); if (domain == null) { if (DBG) { Log.w( TAG, "Search base domain was null, last apply time=" + mSearchSettings.getSearchBaseDomainApplyTime()); } // This is required to deal with the case wherein getSearchDomain // is called before checkSearchDomain returns a valid URL. This will // happen *only* on the first run of the app when the "use google.com" // option is unchecked. In other cases, the previously set domain (or // the default) will be returned. // // We have no choice in this case but to use the default search domain. domain = getDefaultBaseDomain(); } if (domain.startsWith(".")) { if (DBG) Log.d(TAG, "Prepending www to " + domain); domain = "www" + domain; } return domain; }
/** * Update the base search url, either: (a) it has never been set (first run) (b) it has expired * (c) if the caller forces an update by setting the "force" parameter. * * @param force if true, then the URL is reset whether or not it has expired. */ public void maybeUpdateBaseUrlSetting(boolean force) { long lastUpdateTime = mSearchSettings.getSearchBaseDomainApplyTime(); long currentTime = System.currentTimeMillis(); if (force || lastUpdateTime == -1 || currentTime - lastUpdateTime >= SEARCH_BASE_URL_EXPIRY_MS) { if (mSearchSettings.shouldUseGoogleCom()) { setSearchBaseDomain(getDefaultBaseDomain()); } else { checkSearchDomain(); } } }