Make password manager signons actually be removed from the database when you press shift+delete (bug 242250). r=blake.

This commit is contained in:
bryner%brianryner.com 2004-07-29 05:55:30 +00:00
Родитель 018508b90a
Коммит f02df734cf
7 изменённых файлов: 39 добавлений и 24 удалений

Просмотреть файл

@ -37,7 +37,7 @@
#include "nsISupports.idl"
[scriptable, uuid(44864910-332C-46b0-A4F9-14A301DBCA80)]
[scriptable, uuid(eb43e1dc-2060-4d8e-aebf-3efec4e21cf8)]
interface nsIAutoCompleteResult : nsISupports
{
/**
@ -87,4 +87,11 @@ interface nsIAutoCompleteResult : nsISupports
* Get the style hint for the result at the given index
*/
AString getStyleAt(in long index);
/**
* Remove the value at the given index from the autocomplete results.
* If removeFromDb is set to true, the value should be removed from
* persistent storage as well.
*/
void removeValueAt(in long rowIndex, in boolean removeFromDb);
};

Просмотреть файл

@ -49,7 +49,7 @@ native mdb_scope(mdb_scope);
native mdb_column(mdb_column);
/* noscript */
[uuid(c5257f44-b4d0-41aa-a50b-5b7bcefcc235)]
[uuid(e6396544-921d-4776-aa62-8bf2dc1ae058)]
interface nsIAutoCompleteBaseResult : nsIAutoCompleteResult
{
void setSearchString(in AString searchString);
@ -73,8 +73,6 @@ interface nsIAutoCompleteMdbResult : nsIAutoCompleteBaseResult
void addRow(in nsIMdbRow row);
void removeRowAt(in unsigned long rowIndex, in boolean removeFromDb);
nsIMdbRow getRowAt(in unsigned long rowIndex);
AString getRowValue(in nsIMdbRow row, in mdb_column col);

Просмотреть файл

@ -352,16 +352,9 @@ nsAutoCompleteController::HandleDelete(PRBool *_retval)
nsAutoString search;
mInput->GetSearchParam(search);
nsAutoString value;
result->GetValueAt(rowIndex, value);
nsCOMPtr<nsIAutoCompleteMdbResult> mdbResult(do_QueryInterface(result));
if (mdbResult) {
// Clear the row in our result and in the DB.
mdbResult->RemoveRowAt(rowIndex, PR_TRUE);
--mRowCount;
}
// Clear the row in our result and in the DB.
result->RemoveValueAt(rowIndex, PR_TRUE);
--mRowCount;
// Unselect the current item.
popup->SetSelectedIndex(-1);

Просмотреть файл

@ -210,7 +210,7 @@ nsAutoCompleteMdbResult::AddRow(nsIMdbRow *aRow)
}
NS_IMETHODIMP
nsAutoCompleteMdbResult::RemoveRowAt(PRUint32 aRowIndex, PRBool aRemoveFromDb)
nsAutoCompleteMdbResult::RemoveValueAt(PRInt32 aRowIndex, PRBool aRemoveFromDb)
{
nsIMdbRow *row = mResults.ObjectAt(aRowIndex);
NS_ENSURE_TRUE(row, NS_ERROR_INVALID_ARG);

Просмотреть файл

@ -4177,7 +4177,7 @@ nsGlobalHistory::AutoCompleteSearch(const nsAString &aSearchString,
aPrevResult->GetValueAt(i, url);
if (!AutoCompleteCompare(url, aSearchString, aExclude))
aPrevResult->RemoveRowAt(i, PR_FALSE);
aPrevResult->RemoveValueAt(i, PR_FALSE);
}
*aResult = aPrevResult;

Просмотреть файл

@ -1290,20 +1290,23 @@ nsPasswordManager::HandleEvent(nsIDOMEvent* aEvent)
class UserAutoComplete : public nsIAutoCompleteResult
{
public:
UserAutoComplete(const nsAString& aSearchString);
UserAutoComplete(const nsACString& aHost, const nsAString& aSearchString);
virtual ~UserAutoComplete();
NS_DECL_ISUPPORTS
NS_DECL_NSIAUTOCOMPLETERESULT
nsVoidArray mArray;
nsString mSearchString;
PRInt32 mDefaultIndex;
PRUint16 mResult;
nsCString mHost;
nsString mSearchString;
PRInt32 mDefaultIndex;
PRUint16 mResult;
};
UserAutoComplete::UserAutoComplete(const nsAString& aSearchString)
: mSearchString(aSearchString),
UserAutoComplete::UserAutoComplete(const nsACString& aHost,
const nsAString& aSearchString)
: mHost(aHost),
mSearchString(aSearchString),
mDefaultIndex(-1),
mResult(RESULT_FAILURE)
{
@ -1373,6 +1376,20 @@ UserAutoComplete::GetStyleAt(PRInt32 aIndex, nsAString& aHint)
return NS_OK;
}
NS_IMETHODIMP
UserAutoComplete::RemoveValueAt(PRInt32 aIndex, PRBool aRemoveFromDB)
{
NS_ENSURE_TRUE(aIndex >= 0 && aIndex < mArray.Count(), NS_ERROR_INVALID_ARG);
PRUnichar *user = NS_STATIC_CAST(PRUnichar*, mArray.ElementAt(aIndex));
if (aRemoveFromDB)
sPasswordManager->RemoveUser(mHost, nsDependentString(user));
nsMemory::Free(user);
mArray.RemoveElementAt(aIndex);
return NS_OK;
}
PR_STATIC_CALLBACK(int)
SortPRUnicharComparator(const void* aElement1,
const void* aElement2,
@ -1426,7 +1443,7 @@ nsPasswordManager::AutoCompleteSearch(const nsAString& aSearchString,
// Get all of the matches into an array that we can sort.
result = new UserAutoComplete(aSearchString);
result = new UserAutoComplete(realm, aSearchString);
SignonHashEntry* hashEnt;
if (mSignonTable.Get(realm, &hashEnt)) {

Просмотреть файл

@ -705,7 +705,7 @@ nsFormHistory::AutoCompleteSearch(const nsAString &aInputName,
nsIMdbRow *row;
result->GetRowAt(i, &row);
if (!RowMatch(row, aInputName, aInputValue, nsnull))
result->RemoveRowAt(i, PR_FALSE);
result->RemoveValueAt(i, PR_FALSE);
}
} else {
result = do_CreateInstance("@mozilla.org/autocomplete/mdb-result;1");