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

Unified Diff: chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc

Issue 1857513002: Update code so 1:1 relation between delegate and router is more clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback 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/extensions/api/passwords_private/passwords_private_delegate_impl.cc
diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc
index d762a4d1ba3820be0e3f5c82c863ac36eb38299b..8b1927999ae5a7ec588fe0dc130c9c06654b146d 100644
--- a/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc
+++ b/chrome/browser/extensions/api/passwords_private/passwords_private_delegate_impl.cc
@@ -6,6 +6,8 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
+#include "chrome/browser/extensions/api/passwords_private/passwords_private_event_router.h"
+#include "chrome/browser/extensions/api/passwords_private/passwords_private_event_router_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
#include "chrome/common/pref_names.h"
@@ -41,20 +43,18 @@ PasswordsPrivateDelegateImpl::PasswordsPrivateDelegateImpl(Profile* profile)
PasswordsPrivateDelegateImpl::~PasswordsPrivateDelegateImpl() {}
-void PasswordsPrivateDelegateImpl::AddObserver(Observer* observer) {
- observers_.AddObserver(observer);
-
- // Send the current cached lists to the new observer.
- ExecuteFunction(base::Bind(
- &PasswordsPrivateDelegateImpl::SendSavedPasswordsList,
- base::Unretained(this)));
- ExecuteFunction(base::Bind(
- &PasswordsPrivateDelegateImpl::SendPasswordExceptionsList,
- base::Unretained(this)));
+void PasswordsPrivateDelegateImpl::SendSavedPasswordsList() {
+ PasswordsPrivateEventRouter* router =
+ PasswordsPrivateEventRouterFactory::GetForProfile(profile_);
+ if (router)
+ router->OnSavedPasswordsListChanged(current_entries_);
}
-void PasswordsPrivateDelegateImpl::RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
+void PasswordsPrivateDelegateImpl::SendPasswordExceptionsList() {
+ PasswordsPrivateEventRouter* router =
+ PasswordsPrivateEventRouterFactory::GetForProfile(profile_);
+ if (router)
+ router->OnPasswordExceptionsListChanged(current_exceptions_);
}
void PasswordsPrivateDelegateImpl::RemoveSavedPassword(
@@ -139,10 +139,12 @@ void PasswordsPrivateDelegateImpl::ShowPassword(
const std::string& origin_url,
const std::string& username,
const base::string16& password_value) {
- FOR_EACH_OBSERVER(
- Observer, observers_,
- OnPlaintextPasswordFetched(origin_url, username,
- base::UTF16ToUTF8(password_value)));
+ PasswordsPrivateEventRouter* router =
+ PasswordsPrivateEventRouterFactory::GetForProfile(profile_);
+ if (router) {
+ router->OnPlaintextPasswordFetched(origin_url, username,
+ base::UTF16ToUTF8(password_value));
+ }
}
void PasswordsPrivateDelegateImpl::SetPasswordList(
@@ -181,11 +183,6 @@ void PasswordsPrivateDelegateImpl::SetPasswordList(
InitializeIfNecessary();
}
-void PasswordsPrivateDelegateImpl::SendSavedPasswordsList() {
- FOR_EACH_OBSERVER(Observer, observers_,
- OnSavedPasswordsListChanged(current_entries_));
-}
-
void PasswordsPrivateDelegateImpl::SetPasswordExceptionList(
const std::vector<scoped_ptr<autofill::PasswordForm>>&
password_exception_list) {
@@ -211,12 +208,6 @@ void PasswordsPrivateDelegateImpl::SetPasswordExceptionList(
InitializeIfNecessary();
}
-void PasswordsPrivateDelegateImpl::SendPasswordExceptionsList() {
- FOR_EACH_OBSERVER(
- Observer, observers_,
- Observer::OnPasswordExceptionsListChanged(current_exceptions_));
-}
-
#if !defined(OS_ANDROID)
gfx::NativeWindow PasswordsPrivateDelegateImpl::GetNativeWindow() const {
DCHECK(web_contents_);

Powered by Google App Engine
This is Rietveld 408576698