зеркало из https://github.com/mozilla/gecko-dev.git
215094 - add new profile migrator interface, adapt password manager to support api for adding signons with details (235360)
This commit is contained in:
Родитель
95a75a2673
Коммит
136c4d71dd
|
@ -57,6 +57,7 @@ DIRS = \
|
|||
history \
|
||||
passwordmgr \
|
||||
printing \
|
||||
profile \
|
||||
satchel \
|
||||
viewconfig \
|
||||
viewsource \
|
||||
|
|
|
@ -375,7 +375,7 @@ nsPasswordManager::AddUser(const nsACString& aHost,
|
|||
}
|
||||
|
||||
AddSignonData(aHost, entry);
|
||||
WriteSignonFile();
|
||||
WritePasswords(mSignonFile);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ nsPasswordManager::RemoveUser(const nsACString& aHost, const nsAString& aUser)
|
|||
if (!hashEnt->head)
|
||||
mSignonTable.Remove(aHost); // deletes hashEnt
|
||||
|
||||
WriteSignonFile();
|
||||
WritePasswords(mSignonFile);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ NS_IMETHODIMP
|
|||
nsPasswordManager::AddReject(const nsACString& aHost)
|
||||
{
|
||||
mRejectTable.Put(aHost, 1);
|
||||
WriteSignonFile();
|
||||
WritePasswords(mSignonFile);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -429,7 +429,7 @@ NS_IMETHODIMP
|
|||
nsPasswordManager::RemoveReject(const nsACString& aHost)
|
||||
{
|
||||
mRejectTable.Remove(aHost);
|
||||
WriteSignonFile();
|
||||
WritePasswords(mSignonFile);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -579,9 +579,8 @@ nsPasswordManager::FindPasswordEntry(const nsACString& aHostURI,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef MIGRATION_ENABLED
|
||||
NS_IMETHODIMP
|
||||
nsPasswordManager::AddUserFull(const nsACString& aHost,
|
||||
nsPasswordManager::AddUserFull(const nsACString& aKey,
|
||||
const nsAString& aUser,
|
||||
const nsAString& aPassword,
|
||||
const nsAString& aUserFieldName,
|
||||
|
@ -593,9 +592,9 @@ nsPasswordManager::AddUserFull(const nsACString& aHost,
|
|||
return NS_OK;
|
||||
|
||||
// Check for an existing entry for this host + user
|
||||
if (!aHost.IsEmpty()) {
|
||||
if (!aKey.IsEmpty()) {
|
||||
SignonHashEntry *hashEnt;
|
||||
if (mSignonTable.Get(aHost, &hashEnt)) {
|
||||
if (mSignonTable.Get(aKey, &hashEnt)) {
|
||||
nsString empty;
|
||||
SignonDataEntry *entry = nsnull;
|
||||
FindPasswordEntryInternal(hashEnt->head, aUser, empty, empty, &entry);
|
||||
|
@ -616,18 +615,13 @@ nsPasswordManager::AddUserFull(const nsACString& aHost,
|
|||
EncryptDataUCS2(aUser, entry->userValue);
|
||||
EncryptDataUCS2(aPassword, entry->passValue);
|
||||
|
||||
AddSignonData(aHost, entry);
|
||||
WriteSignonFile();
|
||||
AddSignonData(aKey, entry);
|
||||
WritePasswords(mSignonFile);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MIGRATION_ENABLED
|
||||
NS_IMETHODIMP
|
||||
#else
|
||||
nsresult
|
||||
#endif
|
||||
nsPasswordManager::ReadPasswords(nsIFile* aPasswordFile)
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> fileStream;
|
||||
|
@ -734,7 +728,7 @@ nsPasswordManager::ReadPasswords(nsIFile* aPasswordFile)
|
|||
|
||||
if (writeOnFinish) {
|
||||
fileStream->Close();
|
||||
WriteSignonFile();
|
||||
WritePasswords(mSignonFile);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1082,7 +1076,7 @@ nsPasswordManager::Notify(nsIContent* aFormNode,
|
|||
if (NS_FAILED(EncryptDataUCS2(passValue, entry->passValue)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
WriteSignonFile();
|
||||
WritePasswords(mSignonFile);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1120,7 +1114,7 @@ nsPasswordManager::Notify(nsIContent* aFormNode,
|
|||
}
|
||||
|
||||
AddSignonData(realm, entry);
|
||||
WriteSignonFile();
|
||||
WritePasswords(mSignonFile);
|
||||
} else if (selection == 2) {
|
||||
AddReject(realm);
|
||||
}
|
||||
|
@ -1234,7 +1228,7 @@ nsPasswordManager::Notify(nsIContent* aFormNode,
|
|||
if (NS_FAILED(EncryptDataUCS2(newValue, changeEntry->passValue)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
WriteSignonFile();
|
||||
WritePasswords(mSignonFile);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1584,10 +1578,10 @@ nsPasswordManager::WriteSignonEntryEnumerator(const nsACString& aKey,
|
|||
}
|
||||
|
||||
void
|
||||
nsPasswordManager::WriteSignonFile()
|
||||
nsPasswordManager::WritePasswords(nsIFile* aPasswordFile)
|
||||
{
|
||||
nsCOMPtr<nsIOutputStream> fileStream;
|
||||
NS_NewLocalFileOutputStream(getter_AddRefs(fileStream), mSignonFile, -1,
|
||||
NS_NewLocalFileOutputStream(getter_AddRefs(fileStream), aPasswordFile, -1,
|
||||
0600, 0);
|
||||
|
||||
if (!fileStream)
|
||||
|
|
|
@ -144,10 +144,7 @@ public:
|
|||
nsIAutoCompleteResult** aResult);
|
||||
|
||||
protected:
|
||||
#ifndef MIGRATION_ENABLED
|
||||
nsresult ReadPasswords(nsIFile* aPasswordFile);
|
||||
#endif
|
||||
void WriteSignonFile();
|
||||
void WritePasswords(nsIFile* aPasswordFile);
|
||||
void AddSignonData(const nsACString& aRealm, SignonDataEntry* aEntry);
|
||||
|
||||
nsresult FindPasswordEntryInternal(const SignonDataEntry* aEntry,
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = profile
|
||||
|
||||
XPIDLSRCS = nsIProfileMigrator.idl
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is The Browser Profile Migrator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Ben Goodger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@bengoodger.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(5d9c7f6a-4af4-4a3d-be48-da1e70600b9c)]
|
||||
interface nsIProfileMigrator : nsISupports
|
||||
{
|
||||
/**
|
||||
* Copy user profile information to the current active profile.
|
||||
*/
|
||||
void migrate();
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
#define NS_PROFILEMIGRATOR_CONTRACTID "@mozilla.org/profile/migrator;1"
|
||||
|
||||
#define NS_PROFILEMIGRATOR_CID \
|
||||
{ 0xc0f8241e, 0x3340, 0x431e, { 0xbe, 0xba, 0x7b, 0x82, 0xf8, 0x7d, 0xd1, 0x41 } }
|
||||
|
||||
%}
|
Загрузка…
Ссылка в новой задаче