Chromium Code Reviews| 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 841f9c471d7ff12b68bd8c0379b9e51379a9910f..6c24981e439bdc988af8fbd1e2d17a9018496d6a 100644 | 
| --- a/chrome/browser/ui/passwords/password_manager_presenter.cc | 
| +++ b/chrome/browser/ui/passwords/password_manager_presenter.cc | 
| @@ -25,10 +25,12 @@ | 
| #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/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" | 
| @@ -142,20 +144,9 @@ void PasswordManagerPresenter::RequestShowPassword(size_t index) { | 
| NOTREACHED(); | 
| return; | 
| } | 
| - if (require_reauthentication_ && | 
| - (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; | 
| @@ -182,6 +173,19 @@ 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_) { | 
| + scoped_ptr<autofill::PasswordForm> copyOfPassword( | 
| + new autofill::PasswordForm(*(form.get()))); | 
| + ret_val.push_back(std::move(copyOfPassword)); | 
| 
 
vabr (Chromium)
2016/03/10 10:53:31
nit: A shorter way to write lines 181-183:
ret_va
 
xunlu
2016/03/16 07:23:58
Done.
 
 | 
| + } | 
| + | 
| + return ret_val; | 
| +} | 
| + | 
| const autofill::PasswordForm* PasswordManagerPresenter::GetPassword( | 
| size_t index) { | 
| if (index >= password_list_.size()) { | 
| @@ -221,6 +225,27 @@ void PasswordManagerPresenter::SetPasswordExceptionList() { | 
| password_view_->SetPasswordExceptionList(password_exception_list_); | 
| } | 
| +bool PasswordManagerPresenter::IsUserAuthenticated() { | 
| +#if defined(OS_ANDROID) | 
| + NOTREACHED(); | 
| +#endif | 
| + if (require_reauthentication_ && | 
| + (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) { | 
| } |