OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_NETWORKING_CONFIG_NETWORKING_CONFIG_SERVIC E_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_API_NETWORKING_CONFIG_NETWORKING_CONFIG_SERVIC E_H_ | |
stevenjb
2015/01/29 17:51:35
Fix all header guards.
cschuet (SLOW)
2015/01/30 12:33:34
Done.
| |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/scoped_observer.h" | |
13 #include "components/keyed_service/core/keyed_service.h" | |
14 #include "extensions/browser/event_router.h" | |
15 #include "extensions/browser/extension_registry.h" | |
16 #include "extensions/browser/extension_registry_observer.h" | |
17 | |
18 namespace extensions { | |
19 | |
stevenjb
2015/01/29 17:51:35
Brief comment describing the purpose of this class
cschuet (SLOW)
2015/01/30 12:33:34
Done.
| |
20 class NetworkingConfigService : public ExtensionRegistryObserver, | |
21 public KeyedService { | |
22 public: | |
23 class EventDelegate { | |
24 public: | |
25 EventDelegate() {} | |
26 virtual ~EventDelegate() {} | |
27 virtual bool HasExtensionRegisteredForEvent( | |
28 const std::string& extension_id) const = 0; | |
29 | |
30 private: | |
31 DISALLOW_COPY_AND_ASSIGN(EventDelegate); | |
32 }; | |
33 | |
34 // Indicates the authentication state of the portal. | |
35 enum AuthenticationState { NOTRY, TRYING, SUCCESS, REJECTED, FAILED }; | |
36 | |
37 // Provides information about the current authentication state of the portal. | |
38 struct AuthenticationResult { | |
39 AuthenticationResult(); | |
40 ExtensionId extension_id; | |
41 std::string guid; | |
42 AuthenticationState authentication_state; | |
stevenjb
2015/01/29 17:51:35
optional nit: We can now use:
authentication_state
cschuet (SLOW)
2015/01/30 12:33:34
Acknowledged.
| |
43 }; | |
44 | |
45 // Note: |extension_registry| must outlive this class. | |
46 explicit NetworkingConfigService(scoped_ptr<EventDelegate> event_delegate, | |
47 ExtensionRegistry* extension_registry); | |
stevenjb
2015/01/29 17:51:35
no explicit
cschuet (SLOW)
2015/01/30 12:33:34
Done.
| |
48 ~NetworkingConfigService() override; | |
49 | |
50 // ExtensionRegistryObserver | |
51 void OnExtensionUnloaded(content::BrowserContext* browser_context, | |
52 const Extension* extension, | |
53 UnloadedExtensionInfo::Reason reason) override; | |
54 | |
55 // Returns the extension id registered for |hex_ssid|. If no extension is | |
56 // registered for this |hex_ssid|, the function returns an empty string. | |
57 // |hex_ssid|: SSID in hex encoding. | |
58 std::string GetExtensionIdForHexSsid(std::string hex_ssid) const; | |
stevenjb
2015/01/29 17:51:35
nit: Is this the primary way we are going to deter
cschuet (SLOW)
2015/01/30 12:33:34
Done.
| |
59 | |
60 // Returns true if the extension with id |extension_id| registered for | |
61 // |onCaptivePortalDetected| events, otherwise false. | |
62 bool HasExtensionRegisteredForEvent(std::string extension_id) const; | |
63 | |
64 // Registers |hex_ssid| as being handled by the extension with extension ID | |
65 // |extension_id|. Returns true on success and false if another extension | |
66 // already registered for |hex_ssid|. | |
67 // |hex_ssid|: SSID in hex encoding of the network to be registered. | |
68 // |extension_id|: extension ID of the extension handling captive portal | |
69 // authentication for this network. | |
70 bool RegisterHexSsid(std::string hex_ssid, const std::string& extension_id); | |
stevenjb
2015/01/29 17:51:35
Are the above two methods going to be limited to c
cschuet (SLOW)
2015/01/30 12:33:34
I think that IsRegisteredForCaptivePortalEvent sho
| |
71 | |
72 // Unregisters extension with the ID |extension_id| removing all associated | |
73 // HexSSIDs from the map. | |
74 // |extension_id|: ID identifying the extenion to be removed | |
75 void UnregisterExtension(const std::string& extensionId); | |
76 | |
77 // Returns the current AuthenticationResult. | |
78 const AuthenticationResult& GetAuthenticationResult() const; | |
79 | |
80 // Sets the authentication_state to NOTRY and clears all other fields. | |
81 void ResetAuthenticationResult(); | |
82 | |
83 // Sets the current AuthenticationResult. | |
84 void SetAuthenticationResult( | |
85 const AuthenticationResult& authentication_result); | |
86 | |
87 private: | |
88 AuthenticationResult authentication_result_; | |
89 | |
90 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | |
91 registry_observer_; | |
92 | |
93 scoped_ptr<EventDelegate> event_delegate_; | |
94 | |
95 // This map associates a given hex encoded SSID to an extension entry. | |
96 std::map<std::string, std::string> hex_ssid_to_extension_id_; | |
97 }; | |
98 | |
99 } // namespace extensions | |
100 | |
101 #endif // CHROME_BROWSER_EXTENSIONS_API_NETWORKING_CONFIG_NETWORKING_CONFIG_SER VICE_H_ | |
OLD | NEW |