mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 18:26:15 +00:00
Bug 1535379 - Remove handling of autocomplete-will-enter-text from Places. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D51280 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
81fb8caad9
commit
04bd60ab30
@ -372,32 +372,5 @@ void TokensToQueryString(const nsTArray<QueryKeyValuePair>& aTokens,
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// AsyncStatementCallbackNotifier
|
||||
|
||||
NS_IMETHODIMP
|
||||
AsyncStatementCallbackNotifier::HandleCompletion(uint16_t aReason) {
|
||||
if (aReason != mozIStorageStatementCallback::REASON_FINISHED)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (obs) {
|
||||
(void)obs->NotifyObservers(nullptr, mTopic, nullptr);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// AsyncStatementCallbackNotifier
|
||||
|
||||
NS_IMETHODIMP
|
||||
AsyncStatementTelemetryTimer::HandleCompletion(uint16_t aReason) {
|
||||
if (aReason == mozIStorageStatementCallback::REASON_FINISHED) {
|
||||
Telemetry::AccumulateTimeDelta(mHistogramId, mStart);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace places
|
||||
} // namespace mozilla
|
||||
|
@ -258,20 +258,6 @@ class FinalizeStatementCacheProxy : public Runnable {
|
||||
*/
|
||||
bool GetHiddenState(bool aIsRedirect, uint32_t aTransitionType);
|
||||
|
||||
/**
|
||||
* Used to notify a topic to system observers on async execute completion.
|
||||
*/
|
||||
class AsyncStatementCallbackNotifier : public AsyncStatementCallback {
|
||||
public:
|
||||
explicit AsyncStatementCallbackNotifier(const char* aTopic)
|
||||
: mTopic(aTopic) {}
|
||||
|
||||
NS_IMETHOD HandleCompletion(uint16_t aReason) override;
|
||||
|
||||
private:
|
||||
const char* mTopic;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to notify a topic to system observers on async execute completion.
|
||||
*/
|
||||
|
@ -438,7 +438,6 @@ var PlacesUtils = {
|
||||
TOPIC_INIT_COMPLETE: "places-init-complete",
|
||||
TOPIC_DATABASE_LOCKED: "places-database-locked",
|
||||
TOPIC_EXPIRATION_FINISHED: "places-expiration-finished",
|
||||
TOPIC_FEEDBACK_UPDATED: "places-autocomplete-feedback-updated",
|
||||
TOPIC_FAVICONS_EXPIRED: "places-favicons-expired",
|
||||
TOPIC_VACUUM_STARTING: "places-vacuum-starting",
|
||||
TOPIC_BOOKMARKS_RESTORE_BEGIN: "bookmarks-restore-begin",
|
||||
|
@ -42,11 +42,6 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
# include "nsIAutoCompleteInput.h"
|
||||
# include "nsIAutoCompletePopup.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::places;
|
||||
|
||||
@ -142,9 +137,6 @@ using namespace mozilla::places;
|
||||
#define RECENT_EVENTS_INITIAL_CACHE_LENGTH 64
|
||||
|
||||
// Observed topics.
|
||||
#ifdef MOZ_XUL
|
||||
# define TOPIC_AUTOCOMPLETE_FEEDBACK_INCOMING "autocomplete-will-enter-text"
|
||||
#endif
|
||||
#define TOPIC_IDLE_DAILY "idle-daily"
|
||||
#define TOPIC_PREF_CHANGED "nsPref:changed"
|
||||
#define TOPIC_PROFILE_TEARDOWN "profile-change-teardown"
|
||||
@ -450,9 +442,6 @@ nsresult nsNavHistory::Init() {
|
||||
if (obsSvc) {
|
||||
(void)obsSvc->AddObserver(this, TOPIC_PLACES_CONNECTION_CLOSED, true);
|
||||
(void)obsSvc->AddObserver(this, TOPIC_IDLE_DAILY, true);
|
||||
#ifdef MOZ_XUL
|
||||
(void)obsSvc->AddObserver(this, TOPIC_AUTOCOMPLETE_FEEDBACK_INCOMING, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Don't add code that can fail here! Do it up above, before we add our
|
||||
@ -2251,51 +2240,7 @@ nsNavHistory::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
mCanNotify = false;
|
||||
mObservers.Clear();
|
||||
}
|
||||
#ifdef MOZ_XUL
|
||||
else if (strcmp(aTopic, TOPIC_AUTOCOMPLETE_FEEDBACK_INCOMING) == 0) {
|
||||
nsCOMPtr<nsIAutoCompleteInput> input = do_QueryInterface(aSubject);
|
||||
if (!input) return NS_OK;
|
||||
|
||||
// If the source is a private window, don't add any input history.
|
||||
bool isPrivate;
|
||||
nsresult rv = input->GetInPrivateContext(&isPrivate);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (isPrivate) return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAutoCompletePopup> popup;
|
||||
input->GetPopup(getter_AddRefs(popup));
|
||||
if (!popup) {
|
||||
nsCOMPtr<Element> popupEl;
|
||||
input->GetPopupElement(getter_AddRefs(popupEl));
|
||||
if (!popupEl) {
|
||||
return NS_OK;
|
||||
}
|
||||
popup = popupEl->AsAutoCompletePopup();
|
||||
if (!popup) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAutoCompleteController> controller;
|
||||
input->GetController(getter_AddRefs(controller));
|
||||
if (!controller) return NS_OK;
|
||||
|
||||
// Don't bother if the popup is closed
|
||||
bool open;
|
||||
rv = popup->GetPopupOpen(&open);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!open) return NS_OK;
|
||||
|
||||
// Ignore if nothing selected from the popup
|
||||
int32_t selectedIndex;
|
||||
rv = popup->GetSelectedIndex(&selectedIndex);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (selectedIndex == -1) return NS_OK;
|
||||
|
||||
rv = AutoCompleteFeedback(selectedIndex, controller);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
#endif
|
||||
else if (strcmp(aTopic, TOPIC_PREF_CHANGED) == 0) {
|
||||
LoadPrefs();
|
||||
}
|
||||
@ -3458,46 +3403,6 @@ nsresult nsNavHistory::UpdateFrecency(int64_t aPlaceId) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
|
||||
nsresult nsNavHistory::AutoCompleteFeedback(
|
||||
int32_t aIndex, nsIAutoCompleteController* aController) {
|
||||
nsCOMPtr<mozIStorageAsyncStatement> stmt = mDB->GetAsyncStatement(
|
||||
"INSERT OR REPLACE INTO moz_inputhistory "
|
||||
// use_count will asymptotically approach the max of 10.
|
||||
"SELECT h.id, IFNULL(i.input, :input_text), IFNULL(i.use_count, 0) * .9 "
|
||||
"+ 1 "
|
||||
"FROM moz_places h "
|
||||
"LEFT JOIN moz_inputhistory i ON i.place_id = h.id AND i.input = "
|
||||
":input_text "
|
||||
"WHERE url_hash = hash(:page_url) AND url = :page_url ");
|
||||
NS_ENSURE_STATE(stmt);
|
||||
|
||||
nsAutoString input;
|
||||
nsresult rv = aController->GetSearchString(input);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = stmt->BindStringByName(NS_LITERAL_CSTRING("input_text"), input);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString url;
|
||||
rv = aController->GetValueAt(aIndex, url);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = URIBinder::Bind(stmt, NS_LITERAL_CSTRING("page_url"),
|
||||
NS_ConvertUTF16toUTF8(url));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// We do the update asynchronously and we do not care about failures.
|
||||
RefPtr<AsyncStatementCallbackNotifier> callback =
|
||||
new AsyncStatementCallbackNotifier(TOPIC_AUTOCOMPLETE_FEEDBACK_UPDATED);
|
||||
nsCOMPtr<mozIStoragePendingStatement> canceler;
|
||||
rv = stmt->ExecuteAsync(callback, getter_AddRefs(canceler));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
nsICollation* nsNavHistory::GetCollation() {
|
||||
if (mCollation) return mCollation;
|
||||
|
||||
|
@ -49,12 +49,6 @@
|
||||
// If you typed it more than this time ago, it's not recent.
|
||||
#define RECENT_EVENT_THRESHOLD PRTime((int64_t)15 * 60 * PR_USEC_PER_SEC)
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
// Fired after autocomplete feedback has been updated.
|
||||
# define TOPIC_AUTOCOMPLETE_FEEDBACK_UPDATED \
|
||||
"places-autocomplete-feedback-updated"
|
||||
#endif
|
||||
|
||||
// The preference we watch to know when the mobile bookmarks folder is filled by
|
||||
// sync.
|
||||
#define MOBILE_BOOKMARKS_PREF "browser.bookmarks.showMobileBookmarks"
|
||||
@ -508,11 +502,6 @@ class nsNavHistory final : public nsSupportsWeakReference,
|
||||
bool CheckIsRecentEvent(RecentEventHash* hashTable, const nsACString& url);
|
||||
void ExpireNonrecentEvents(RecentEventHash* hashTable);
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
nsresult AutoCompleteFeedback(int32_t aIndex,
|
||||
nsIAutoCompleteController* aController);
|
||||
#endif
|
||||
|
||||
// Whether history is enabled or not.
|
||||
// Will mimic value of the places.history.enabled preference.
|
||||
bool mHistoryEnabled;
|
||||
|
@ -609,34 +609,3 @@ add_task(async function ensure_search_engine() {
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
await Services.search.setDefault(engine);
|
||||
});
|
||||
|
||||
/**
|
||||
* Add a adaptive result for a given (url, string) tuple.
|
||||
* @param {string} aUrl
|
||||
* The url to add an adaptive result for.
|
||||
* @param {string} aSearch
|
||||
* The string to add an adaptive result for.
|
||||
* @resolves When the operation is complete.
|
||||
*/
|
||||
function addAdaptiveFeedback(aUrl, aSearch) {
|
||||
let promise = TestUtils.topicObserved("places-autocomplete-feedback-updated");
|
||||
let thing = {
|
||||
QueryInterface: ChromeUtils.generateQI([
|
||||
Ci.nsIAutoCompleteInput,
|
||||
Ci.nsIAutoCompletePopup,
|
||||
Ci.nsIAutoCompleteController,
|
||||
]),
|
||||
get popup() {
|
||||
return thing;
|
||||
},
|
||||
get controller() {
|
||||
return thing;
|
||||
},
|
||||
popupOpen: true,
|
||||
selectedIndex: 0,
|
||||
getValueAt: () => aUrl,
|
||||
searchString: aSearch,
|
||||
};
|
||||
Services.obs.notifyObservers(thing, "autocomplete-will-enter-text");
|
||||
return promise;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user