OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/extensions/api/networking_private/networking_private_ev
ent_router.h" | 5 #include "chrome/browser/extensions/api/networking_private/networking_private_ev
ent_router.h" |
6 | 6 |
7 #include "chrome/browser/extensions/api/networking_private/networking_private_ap
i.h" | 7 #include "chrome/browser/extensions/api/networking_private/networking_private_ap
i.h" |
8 #include "chrome/browser/extensions/api/networking_private/networking_private_se
rvice_client.h" | 8 #include "chrome/browser/extensions/api/networking_private/networking_private_se
rvice_client.h" |
9 #include "chrome/browser/extensions/api/networking_private/networking_private_se
rvice_client_factory.h" | 9 #include "chrome/browser/extensions/api/networking_private/networking_private_se
rvice_client_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/common/extensions/api/networking_private.h" | 11 #include "chrome/common/extensions/api/networking_private.h" |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 | 14 |
15 // This is an event router that will observe listeners to |NetworksChanged| and | 15 // This is an event router that will observe listeners to |NetworksChanged| and |
16 // |NetworkListChanged| events. | 16 // |NetworkListChanged| events. |
17 class NetworkingPrivateEventRouterImpl | 17 class NetworkingPrivateEventRouterImpl |
18 : public NetworkingPrivateEventRouter, | 18 : public NetworkingPrivateEventRouter, |
19 NetworkingPrivateServiceClient::Observer { | 19 NetworkingPrivateServiceClient::Observer { |
20 public: | 20 public: |
21 explicit NetworkingPrivateEventRouterImpl(Profile* profile); | 21 explicit NetworkingPrivateEventRouterImpl(Profile* profile); |
22 virtual ~NetworkingPrivateEventRouterImpl(); | 22 virtual ~NetworkingPrivateEventRouterImpl(); |
23 | 23 |
24 protected: | 24 protected: |
25 // KeyedService overrides: | 25 // KeyedService overrides: |
26 virtual void Shutdown() OVERRIDE; | 26 virtual void Shutdown() override; |
27 | 27 |
28 // EventRouter::Observer overrides: | 28 // EventRouter::Observer overrides: |
29 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 29 virtual void OnListenerAdded(const EventListenerInfo& details) override; |
30 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; | 30 virtual void OnListenerRemoved(const EventListenerInfo& details) override; |
31 | 31 |
32 // NetworkingPrivateServiceClient::Observer overrides: | 32 // NetworkingPrivateServiceClient::Observer overrides: |
33 virtual void OnNetworksChangedEvent( | 33 virtual void OnNetworksChangedEvent( |
34 const std::vector<std::string>& network_guids) OVERRIDE; | 34 const std::vector<std::string>& network_guids) override; |
35 virtual void OnNetworkListChangedEvent( | 35 virtual void OnNetworkListChangedEvent( |
36 const std::vector<std::string>& network_guids) OVERRIDE; | 36 const std::vector<std::string>& network_guids) override; |
37 | 37 |
38 private: | 38 private: |
39 // Decide if we should listen for network changes or not. If there are any | 39 // Decide if we should listen for network changes or not. If there are any |
40 // JavaScript listeners registered for the onNetworkChanged event, then we | 40 // JavaScript listeners registered for the onNetworkChanged event, then we |
41 // want to register for change notification from the network state handler. | 41 // want to register for change notification from the network state handler. |
42 // Otherwise, we want to unregister and not be listening to network changes. | 42 // Otherwise, we want to unregister and not be listening to network changes. |
43 void StartOrStopListeningForNetworkChanges(); | 43 void StartOrStopListeningForNetworkChanges(); |
44 | 44 |
45 Profile* profile_; | 45 Profile* profile_; |
46 bool listening_; | 46 bool listening_; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 args.Pass())); | 147 args.Pass())); |
148 event_router->BroadcastEvent(netlistchanged_event.Pass()); | 148 event_router->BroadcastEvent(netlistchanged_event.Pass()); |
149 } | 149 } |
150 | 150 |
151 NetworkingPrivateEventRouter* NetworkingPrivateEventRouter::Create( | 151 NetworkingPrivateEventRouter* NetworkingPrivateEventRouter::Create( |
152 Profile* profile) { | 152 Profile* profile) { |
153 return new NetworkingPrivateEventRouterImpl(profile); | 153 return new NetworkingPrivateEventRouterImpl(profile); |
154 } | 154 } |
155 | 155 |
156 } // namespace extensions | 156 } // namespace extensions |
OLD | NEW |