[Extensions UI] Update the chrome://extensions page on permissions change
Wire up the chrome://extensions page to listen for permissions changes,
and dispatch the appropriate event. In addition to helping solve
existing edge cases, this is necessary for the click-to-script
management UI.
Add unittests for the same, and fix some lifetime dependency issues.
Bug: 844128
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I105dbb27f0d84e51081f521fcb5f9e32faead394
Reviewed-on: https://chromium-review.googlesource.com/1142382
Commit-Queue: Devlin <[email protected]>
Reviewed-by: Karan Bhatia <[email protected]>
Cr-Commit-Position: refs/heads/master@{#576907}
diff --git a/extensions/browser/test_event_router_observer.h b/extensions/browser/test_event_router_observer.h
new file mode 100644
index 0000000..19926835
--- /dev/null
+++ b/extensions/browser/test_event_router_observer.h
@@ -0,0 +1,40 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXTENSIONS_BROWSER_TEST_EVENT_ROUTER_OBSERVER_H_
+#define EXTENSIONS_BROWSER_TEST_EVENT_ROUTER_OBSERVER_H_
+
+#include <map>
+#include <memory>
+#include <string>
+
+#include "extensions/browser/event_router.h"
+
+namespace extensions {
+
+class TestEventRouterObserver : public EventRouter::TestObserver {
+ public:
+ using EventMap = std::map<std::string, std::unique_ptr<Event>>;
+
+ explicit TestEventRouterObserver(EventRouter* event_router);
+ ~TestEventRouterObserver() override;
+
+ // Clears all recorded events.
+ void ClearEvents();
+
+ const EventMap& events() { return events_; }
+
+ private:
+ // EventRouter::TestObserver:
+ void OnWillDispatchEvent(const Event& event) override;
+
+ EventMap events_;
+ EventRouter* event_router_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestEventRouterObserver);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_TEST_EVENT_ROUTER_OBSERVER_H_