зеркало из https://github.com/mozilla/pjs.git
112208 - Autocomplete doesn't match against redirected urls (like amazon.com, hotmail.com). r=hewitt sr=alecf
This commit is contained in:
Родитель
168660ddfe
Коммит
c1075d3839
|
@ -41,6 +41,8 @@ const MAX_HISTORY_MENU_ITEMS = 15;
|
|||
const MAX_HISTORY_ITEMS = 100;
|
||||
var gRDF = null;
|
||||
var gRDFC = null;
|
||||
var gGlobalHistory = null;
|
||||
var gURIFixup = null;
|
||||
var gLocalStore = null;
|
||||
|
||||
function FillHistoryMenu(aParent, aMenu)
|
||||
|
@ -164,6 +166,13 @@ function addToUrlbarHistory()
|
|||
gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"]
|
||||
.getService(Components.interfaces.nsIRDFService);
|
||||
|
||||
if (!gGlobalHistory)
|
||||
gGlobalHistory = Components.classes["@mozilla.org/browser/global-history;1"]
|
||||
.getService(Components.interfaces.nsIBrowserHistory);
|
||||
|
||||
if (!gURIFixup)
|
||||
gURIFixup = Components.classes["@mozilla.org/docshell/urifixup;1"]
|
||||
.getService(Components.interfaces.nsIURIFixup);
|
||||
if (!gLocalStore)
|
||||
gLocalStore = gRDF.GetDataSource("rdf:local-store");
|
||||
|
||||
|
@ -248,6 +257,8 @@ function addToUrlbarHistory()
|
|||
// Otherwise, we've got a new URL in town. Add it!
|
||||
// Put the value as it was typed by the user in to RDF
|
||||
// Insert it to the beginning of the list.
|
||||
var fixedUpURI = gURIFixup.createFixupURI(entryToAdd.Value, 0);
|
||||
gGlobalHistory.markPageAsTyped(fixedUpURI.spec);
|
||||
entries.InsertElementAt(entryToAdd, 1, true);
|
||||
|
||||
// Remove any expired history items so that we don't let
|
||||
|
|
|
@ -109,6 +109,14 @@ interface nsIBrowserHistory : nsISupports
|
|||
*/
|
||||
|
||||
void hidePage(in string url);
|
||||
|
||||
/**
|
||||
* markPageAsTyped
|
||||
* Designate the url as having been explicitly typed in by
|
||||
* the user, so it's okay to be an autocomplete result.
|
||||
*/
|
||||
|
||||
void markPageAsTyped(in string url);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
|
|
@ -1235,6 +1235,23 @@ nsGlobalHistory::HidePage(const char *aURL)
|
|||
return NotifyFindUnassertions(urlResource, row);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalHistory::MarkPageAsTyped(const char* aURL)
|
||||
{
|
||||
nsCOMPtr<nsIMdbRow> row;
|
||||
nsresult rv = FindRow(kToken_URLColumn, aURL, getter_AddRefs(row));
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = AddPage(aURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = FindRow(kToken_URLColumn, aURL, getter_AddRefs(row));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
return SetRowValue(row, kToken_TypedColumn, 1);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsGlobalHistory
|
||||
|
@ -2613,6 +2630,9 @@ nsGlobalHistory::CreateTokens()
|
|||
err = mStore->StringToToken(mEnv, "Hidden", &kToken_HiddenColumn);
|
||||
if (err != 0) return NS_ERROR_FAILURE;
|
||||
|
||||
err = mStore->StringToToken(mEnv, "Typed", &kToken_TypedColumn);
|
||||
if (err != 0) return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3770,12 +3790,12 @@ nsGlobalHistory::AutoCompleteEnumerator::~AutoCompleteEnumerator()
|
|||
PRBool
|
||||
nsGlobalHistory::AutoCompleteEnumerator::IsResult(nsIMdbRow* aRow)
|
||||
{
|
||||
if (HasCell(mEnv, aRow, mHiddenColumn))
|
||||
if (HasCell(mEnv, aRow, mHiddenColumn) && !HasCell(mEnv, aRow, mTypedColumn))
|
||||
return PR_FALSE;
|
||||
|
||||
nsCAutoString url;
|
||||
mHistory->GetRowValue(aRow, mURLColumn, url);
|
||||
|
||||
|
||||
nsAutoString url2;
|
||||
url2.AssignWithConversion(url.get());
|
||||
PRBool result = mHistory->AutoCompleteCompare(url2, mSelectValue, mExclude);
|
||||
|
@ -3952,6 +3972,7 @@ nsGlobalHistory::AutoCompleteSearch(const nsAReadableString& aSearchString,
|
|||
enumerator = new AutoCompleteEnumerator(this, kToken_URLColumn,
|
||||
kToken_NameColumn,
|
||||
kToken_HiddenColumn,
|
||||
kToken_TypedColumn,
|
||||
aSearchString, aExclude);
|
||||
rv = enumerator->Init(mEnv, mTable);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
|
|
@ -271,6 +271,7 @@ protected:
|
|||
mdb_column kToken_NameColumn;
|
||||
mdb_column kToken_HostnameColumn;
|
||||
mdb_column kToken_HiddenColumn;
|
||||
mdb_column kToken_TypedColumn;
|
||||
|
||||
//
|
||||
// AddPage-oriented stuff
|
||||
|
@ -395,6 +396,7 @@ protected:
|
|||
nsGlobalHistory* mHistory;
|
||||
mdb_column mURLColumn;
|
||||
mdb_column mHiddenColumn;
|
||||
mdb_column mTypedColumn;
|
||||
mdb_column mCommentColumn;
|
||||
AutocompleteExclude* mExclude;
|
||||
const nsAReadableString& mSelectValue;
|
||||
|
@ -406,11 +408,13 @@ protected:
|
|||
mdb_column aURLColumn,
|
||||
mdb_column aCommentColumn,
|
||||
mdb_column aHiddenColumn,
|
||||
mdb_column aTypedColumn,
|
||||
const nsAReadableString& aSelectValue,
|
||||
AutocompleteExclude* aExclude) :
|
||||
mHistory(aHistory),
|
||||
mURLColumn(aURLColumn),
|
||||
mHiddenColumn(aHiddenColumn),
|
||||
mTypedColumn(aTypedColumn),
|
||||
mCommentColumn(aCommentColumn),
|
||||
mExclude(aExclude),
|
||||
mSelectValue(aSelectValue) {}
|
||||
|
|
Загрузка…
Ссылка в новой задаче