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

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

Issue 1833773002: [Extensions] Convert APIs to use movable types [8] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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_event_router.cc
diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_event_router.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_event_router.cc
index dfd7abbb0ce09b8cd0c2fc0fa3175170da75517d..a8c0952668a84a306d01de00cc1202f1fbd2c68c 100644
--- a/chrome/browser/extensions/api/passwords_private/passwords_private_event_router.cc
+++ b/chrome/browser/extensions/api/passwords_private/passwords_private_event_router.cc
@@ -7,6 +7,7 @@
#include <utility>
#include <vector>
+#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/strings/utf_string_conversions.h"
@@ -22,7 +23,8 @@ PasswordsPrivateEventRouter::PasswordsPrivateEventRouter(
content::BrowserContext* context)
: context_(context),
event_router_(nullptr),
- listening_(false) {
+ listening_(false),
+ ignore_updates_(false) {
// Register with the event router so we know when renderers are listening to
// our events. We first check and see if there *is* an event router, because
// some unit tests try to create all context services, but don't initialize
@@ -59,7 +61,13 @@ void PasswordsPrivateEventRouter::OnListenerAdded(
const EventListenerInfo& details) {
// Start listening to change events and propagate the original lists to
// listeners.
- StartOrStopListeningForChanges();
+ {
+ // Some delegates will immediately update observers. Since we dispatch the
+ // events again below, we want to ignore this here.
+ // TODO(stevenjb): Fix this. crbug.com/598826.
+ base::AutoReset<bool> ignore_updates(&ignore_updates_, true);
+ StartOrStopListeningForChanges();
+ }
SendSavedPasswordListToListeners();
SendPasswordExceptionListToListeners();
}
@@ -71,15 +79,14 @@ void PasswordsPrivateEventRouter::OnListenerRemoved(
}
void PasswordsPrivateEventRouter::OnSavedPasswordsListChanged(
- const std::vector<linked_ptr<
- api::passwords_private::PasswordUiEntry>>& entries) {
+ const std::vector<api::passwords_private::PasswordUiEntry>& entries) {
cached_saved_password_parameters_ =
api::passwords_private::OnSavedPasswordsListChanged::Create(entries);
SendSavedPasswordListToListeners();
}
void PasswordsPrivateEventRouter::SendSavedPasswordListToListeners() {
- if (!cached_saved_password_parameters_.get())
+ if (!cached_saved_password_parameters_.get() || ignore_updates_)
// If there is nothing to send, return early.
return;
@@ -99,7 +106,7 @@ void PasswordsPrivateEventRouter::OnPasswordExceptionsListChanged(
}
void PasswordsPrivateEventRouter::SendPasswordExceptionListToListeners() {
- if (!cached_password_exception_parameters_.get())
+ if (!cached_password_exception_parameters_.get() || ignore_updates_)
// If there is nothing to send, return early.
return;

Powered by Google App Engine
This is Rietveld 408576698