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

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: comment Created 4 years, 8 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 4710a7ef76fa468049a4819139bc70e797ab9c4e..f31826a1c967cd6ad7c742271c26f8d03fbad5c7 100644
--- a/chrome/browser/ui/passwords/password_manager_presenter.cc
+++ b/chrome/browser/ui/passwords/password_manager_presenter.cc
@@ -28,11 +28,13 @@
#include "components/autofill/core/common/password_form.h"
#include "components/browser_sync/browser/profile_sync_service.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/browser/password_ui_utils.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/password_manager/sync/browser/password_sync_util.h"
#include "components/prefs/pref_service.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
@@ -221,19 +223,9 @@ void PasswordManagerPresenter::RequestShowPassword(size_t index) {
// is empty). Don't let it crash the browser.
return;
}
- if ((base::TimeTicks::Now() - last_authentication_time_) >
- base::TimeDelta::FromSeconds(60)) {
- bool authenticated = true;
-#if defined(OS_WIN)
- authenticated = password_manager_util_win::AuthenticateUser(
- password_view_->GetNativeWindow());
-#elif defined(OS_MACOSX)
- authenticated = password_manager_util_mac::AuthenticateUser();
-#endif
- if (authenticated)
- last_authentication_time_ = base::TimeTicks::Now();
- else
- return;
+
+ if (!IsUserAuthenticated()) {
+ return;
}
sync_driver::SyncService* sync_service = nullptr;
@@ -260,6 +252,17 @@ void PasswordManagerPresenter::RequestShowPassword(size_t index) {
#endif
}
+std::vector<scoped_ptr<autofill::PasswordForm>>
+PasswordManagerPresenter::GetAllPasswords() {
+ std::vector<scoped_ptr<autofill::PasswordForm>> ret_val;
+
+ for (const auto& form : password_list_) {
+ ret_val.push_back(make_scoped_ptr(new autofill::PasswordForm(*form)));
+ }
+
+ return ret_val;
+}
+
const autofill::PasswordForm* PasswordManagerPresenter::GetPassword(
size_t index) {
if (index >= password_list_.size()) {
@@ -324,6 +327,26 @@ void PasswordManagerPresenter::SortEntriesAndHideDuplicates(
}
}
+bool PasswordManagerPresenter::IsUserAuthenticated() {
+#if defined(OS_ANDROID)
+ NOTREACHED();
+#endif
+ if (base::TimeTicks::Now() - last_authentication_time_ >
+ base::TimeDelta::FromSeconds(60)) {
+ bool authenticated = true;
+#if defined(OS_WIN)
+ authenticated = password_manager_util_win::AuthenticateUser(
+ password_view_->GetNativeWindow());
+#elif defined(OS_MACOSX)
+ authenticated = password_manager_util_mac::AuthenticateUser();
+#endif
+ if (authenticated)
+ last_authentication_time_ = base::TimeTicks::Now();
+ return authenticated;
+ }
+ return true;
+}
+
PasswordManagerPresenter::ListPopulater::ListPopulater(
PasswordManagerPresenter* page) : page_(page) {
}

Powered by Google App Engine
This is Rietveld 408576698