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

Unified Diff: extensions/browser/api/networking_config/networking_config_service.h

Issue 880073002: Networking.config: Implementation of the NetworkingConfigService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 5 years, 11 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: extensions/browser/api/networking_config/networking_config_service.h
diff --git a/extensions/browser/api/networking_config/networking_config_service.h b/extensions/browser/api/networking_config/networking_config_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..3727db86dcf50b55dcaa4a5457c97e105e864cab
--- /dev/null
+++ b/extensions/browser/api/networking_config/networking_config_service.h
@@ -0,0 +1,101 @@
+// Copyright 2015 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 CHROME_BROWSER_EXTENSIONS_API_NETWORKING_CONFIG_NETWORKING_CONFIG_SERVICE_H_
+#define CHROME_BROWSER_EXTENSIONS_API_NETWORKING_CONFIG_NETWORKING_CONFIG_SERVICE_H_
stevenjb 2015/01/29 17:51:35 Fix all header guards.
cschuet (SLOW) 2015/01/30 12:33:34 Done.
+
+#include <map>
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/scoped_observer.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "extensions/browser/event_router.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_registry_observer.h"
+
+namespace extensions {
+
stevenjb 2015/01/29 17:51:35 Brief comment describing the purpose of this class
cschuet (SLOW) 2015/01/30 12:33:34 Done.
+class NetworkingConfigService : public ExtensionRegistryObserver,
+ public KeyedService {
+ public:
+ class EventDelegate {
+ public:
+ EventDelegate() {}
+ virtual ~EventDelegate() {}
+ virtual bool HasExtensionRegisteredForEvent(
+ const std::string& extension_id) const = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(EventDelegate);
+ };
+
+ // Indicates the authentication state of the portal.
+ enum AuthenticationState { NOTRY, TRYING, SUCCESS, REJECTED, FAILED };
+
+ // Provides information about the current authentication state of the portal.
+ struct AuthenticationResult {
+ AuthenticationResult();
+ ExtensionId extension_id;
+ std::string guid;
+ 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.
+ };
+
+ // Note: |extension_registry| must outlive this class.
+ explicit NetworkingConfigService(scoped_ptr<EventDelegate> event_delegate,
+ ExtensionRegistry* extension_registry);
stevenjb 2015/01/29 17:51:35 no explicit
cschuet (SLOW) 2015/01/30 12:33:34 Done.
+ ~NetworkingConfigService() override;
+
+ // ExtensionRegistryObserver
+ void OnExtensionUnloaded(content::BrowserContext* browser_context,
+ const Extension* extension,
+ UnloadedExtensionInfo::Reason reason) override;
+
+ // Returns the extension id registered for |hex_ssid|. If no extension is
+ // registered for this |hex_ssid|, the function returns an empty string.
+ // |hex_ssid|: SSID in hex encoding.
+ 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.
+
+ // Returns true if the extension with id |extension_id| registered for
+ // |onCaptivePortalDetected| events, otherwise false.
+ bool HasExtensionRegisteredForEvent(std::string extension_id) const;
+
+ // Registers |hex_ssid| as being handled by the extension with extension ID
+ // |extension_id|. Returns true on success and false if another extension
+ // already registered for |hex_ssid|.
+ // |hex_ssid|: SSID in hex encoding of the network to be registered.
+ // |extension_id|: extension ID of the extension handling captive portal
+ // authentication for this network.
+ 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
+
+ // Unregisters extension with the ID |extension_id| removing all associated
+ // HexSSIDs from the map.
+ // |extension_id|: ID identifying the extenion to be removed
+ void UnregisterExtension(const std::string& extensionId);
+
+ // Returns the current AuthenticationResult.
+ const AuthenticationResult& GetAuthenticationResult() const;
+
+ // Sets the authentication_state to NOTRY and clears all other fields.
+ void ResetAuthenticationResult();
+
+ // Sets the current AuthenticationResult.
+ void SetAuthenticationResult(
+ const AuthenticationResult& authentication_result);
+
+ private:
+ AuthenticationResult authentication_result_;
+
+ ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
+ registry_observer_;
+
+ scoped_ptr<EventDelegate> event_delegate_;
+
+ // This map associates a given hex encoded SSID to an extension entry.
+ std::map<std::string, std::string> hex_ssid_to_extension_id_;
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_NETWORKING_CONFIG_NETWORKING_CONFIG_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698