Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: chrome/browser/ui/passwords/password_manager_presenter.cc

Issue 1193143003: Enable import/export of passwords into/from Password Manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add finch switch and address comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/passwords/password_manager_presenter.cc
diff --git a/chrome/browser/ui/passwords/password_manager_presenter.cc b/chrome/browser/ui/passwords/password_manager_presenter.cc
index 5b468a0a4b68cdeae84ad526100cc31b5bfb68be..400af5b88b77f7dbed85a82ad31487ba8bf2ce2f 100644
--- a/chrome/browser/ui/passwords/password_manager_presenter.cc
+++ b/chrome/browser/ui/passwords/password_manager_presenter.cc
@@ -21,6 +21,7 @@
#include "chrome/common/url_constants.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/affiliation_utils.h"
+#include "components/password_manager/core/browser/import/password_importer.h"
#include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "content/public/browser/user_metrics.h"
@@ -122,6 +123,32 @@ void PasswordManagerPresenter::RemovePasswordException(size_t index) {
base::UserMetricsAction("PasswordManager_RemovePasswordException"));
}
+bool PasswordManagerPresenter::AddPasswordsToStore(
+ const std::vector<autofill::PasswordForm>& forms) {
+ PasswordStore* store = GetPasswordStore();
+ if (!store)
+ return false;
+
+ for (std::vector<autofill::PasswordForm>::const_iterator it = forms.begin();
vabr (Chromium) 2015/07/06 08:57:15 optional nit: for (const autofill::PasswordForm* f
xunlu 2015/07/07 00:46:03 Done.
+ it != forms.end(); ++it) {
+ store->AddLogin(*it);
+ }
+ return true;
+}
+
+bool PasswordManagerPresenter::RequestToExportPassword() {
+#if !defined(OS_ANDROID) // This is never called on Android.
vabr (Chromium) 2015/07/06 08:57:15 Instead of the comment, I suggest the self-documen
xunlu 2015/07/07 00:46:03 Done.
+ if (IsAuthenticationRequired()) {
vabr (Chromium) 2015/07/06 08:57:15 I suggest to pull out lines 141-147 as a separate
xunlu 2015/07/07 00:46:03 Done.
+ if (password_manager_util::AuthenticateUser(
+ password_view_->GetNativeWindow()))
+ last_authentication_time_ = base::TimeTicks::Now();
+ else
+ return false;
+ }
+#endif
+ return true;
vabr (Chromium) 2015/07/06 08:57:16 Please move the "return true;" to the !defined(OS_
xunlu 2015/07/07 00:46:03 Done.
+}
+
void PasswordManagerPresenter::RequestShowPassword(size_t index) {
#if !defined(OS_ANDROID) // This is never called on Android.
if (index >= password_list_.size()) {
@@ -157,6 +184,19 @@ void PasswordManagerPresenter::RequestShowPassword(size_t index) {
#endif
}
+ScopedVector<autofill::PasswordForm>
+PasswordManagerPresenter::GetAllPasswords() {
+ ScopedVector<autofill::PasswordForm> retVal;
vabr (Chromium) 2015/07/06 08:57:16 nit: ret_val, not retVal (See http://google-styleg
xunlu 2015/07/07 00:46:03 Done.
+
+ for (ScopedVector<autofill::PasswordForm>::const_iterator it =
vabr (Chromium) 2015/07/06 08:57:15 optional nit: for (const autofill::PasswordForm* e
xunlu 2015/07/07 00:46:03 Done.
+ password_list_.begin();
+ it != password_list_.end(); ++it) {
+ retVal.push_back(new autofill::PasswordForm(**it));
+ }
+
+ return retVal.Pass();
+}
+
const autofill::PasswordForm* PasswordManagerPresenter::GetPassword(
size_t index) {
if (index >= password_list_.size()) {

Powered by Google App Engine
This is Rietveld 408576698