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

Side by Side Diff: extensions/browser/event_router.cc

Issue 2973903002: [Extensions Bindings] Introduce a supportsLazyListeners property (Closed)
Patch Set: onMessage event fix Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « extensions/browser/event_router.h ('k') | extensions/renderer/bindings/api_binding.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/event_router.h" 5 #include "extensions/browser/event_router.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm>
9 #include <utility> 10 #include <utility>
10 11
11 #include "base/atomic_sequence_num.h" 12 #include "base/atomic_sequence_num.h"
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
16 #include "base/stl_util.h" 17 #include "base/stl_util.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 399 }
399 400
400 void EventRouter::ClearRegisteredEventsForTest( 401 void EventRouter::ClearRegisteredEventsForTest(
401 const ExtensionId& extension_id) { 402 const ExtensionId& extension_id) {
402 SetRegisteredEvents(extension_id, std::set<std::string>(), 403 SetRegisteredEvents(extension_id, std::set<std::string>(),
403 RegisteredEventType::kLazy); 404 RegisteredEventType::kLazy);
404 SetRegisteredEvents(extension_id, std::set<std::string>(), 405 SetRegisteredEvents(extension_id, std::set<std::string>(),
405 RegisteredEventType::kServiceWorker); 406 RegisteredEventType::kServiceWorker);
406 } 407 }
407 408
409 bool EventRouter::HasLazyEventListenerForTesting(
410 const std::string& event_name) {
411 const EventListenerMap::ListenerList& listeners =
412 listeners_.GetEventListenersByName(event_name);
413 return std::any_of(listeners.begin(), listeners.end(),
414 [](const std::unique_ptr<EventListener>& listener) {
415 return listener->IsLazy();
416 });
417 }
418
408 void EventRouter::RemoveFilterFromEvent(const std::string& event_name, 419 void EventRouter::RemoveFilterFromEvent(const std::string& event_name,
409 const std::string& extension_id, 420 const std::string& extension_id,
410 const DictionaryValue* filter) { 421 const DictionaryValue* filter) {
411 ExtensionPrefs::ScopedDictionaryUpdate update( 422 ExtensionPrefs::ScopedDictionaryUpdate update(
412 extension_prefs_, extension_id, kFilteredEvents); 423 extension_prefs_, extension_id, kFilteredEvents);
413 auto filtered_events = update.Create(); 424 auto filtered_events = update.Create();
414 ListValue* filter_list = NULL; 425 ListValue* filter_list = NULL;
415 if (!filtered_events || 426 if (!filtered_events ||
416 !filtered_events->GetListWithoutPathExpansion(event_name, &filter_list)) { 427 !filtered_events->GetListWithoutPathExpansion(event_name, &filter_list)) {
417 return; 428 return;
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 const std::string& extension_id, 867 const std::string& extension_id,
857 const GURL& listener_url, 868 const GURL& listener_url,
858 content::BrowserContext* browser_context) 869 content::BrowserContext* browser_context)
859 : event_name(event_name), 870 : event_name(event_name),
860 extension_id(extension_id), 871 extension_id(extension_id),
861 listener_url(listener_url), 872 listener_url(listener_url),
862 browser_context(browser_context) { 873 browser_context(browser_context) {
863 } 874 }
864 875
865 } // namespace extensions 876 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/event_router.h ('k') | extensions/renderer/bindings/api_binding.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698