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

Unified Diff: chrome/browser/chromeos/net/managed_network_configuration_handler.h

Issue 12211103: Adding a new ManagedNetworkConfigurationHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Greg's comments. Created 7 years, 10 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: chrome/browser/chromeos/net/managed_network_configuration_handler.h
diff --git a/chrome/browser/chromeos/net/managed_network_configuration_handler.h b/chrome/browser/chromeos/net/managed_network_configuration_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..f3af482cdc2cbf6df7460389af488e0733d8e5df
--- /dev/null
+++ b/chrome/browser/chromeos/net/managed_network_configuration_handler.h
@@ -0,0 +1,125 @@
+// Copyright (c) 2012 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_CHROMEOS_NET_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
+#define CHROME_BROWSER_CHROMEOS_NET_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/gtest_prod_util.h"
+#include "chromeos/chromeos_export.h"
+#include "chromeos/network/network_handler_callbacks.h"
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace chromeos {
+
+// The ManagedNetworkConfigurationHandler class is used to create and configure
+// networks in ChromeOS using ONC.
+//
+// Its interface exposes only ONC and should decouple users from Shill.
+// Internally it translates ONC to Shill dictionaries and calls through to the
+// NetworkConfigurationHandler.
+//
+// For accessing lists of visible networks, and other state information, see the
+// class NetworkStateHandler.
+//
+// This is a singleton and it's lifetime is managed by by the Chrome startup
+// code.
+//
+// Network configurations are referred to by identifiers. Users of this class
pneubeck (no reviews) 2013/02/22 10:22:31 It may be better to actually expose that the ident
+// shouldn't rely on these identifiers being GUIDs from policies or Shill
+// service paths. The identifiers are only guaranteed to be persistent over the
+// lifetime of the singleton.
+//
+// Note on callbacks: Because all the functions here are meant to be
+// asynchronous, they all take a |callback| of some type, and an
+// |error_callback|. When the operation succeeds, |callback| will be called, and
+// when it doesn't, |error_callback| will be called with information about the
+// error, including a symbolic name for the error and often some error message
+// that is suitable for logging. None of the error message text is meant for
+// user consumption.
+//
+// Important note on the implementation: Currently, Shill's service paths are
+// used as identifiers. However, this may change in the future.
+//
+// TODO(pneubeck): Enforce network policies.
+
+class ManagedNetworkConfigurationHandler {
+ public:
+ // Initializes the singleton.
+ static void Initialize();
+
+ // Returns if the singleton is initialized.
+ static bool IsInitialized();
+
+ // Destroys the singleton.
+ static void Shutdown();
+
+ // Initialize() must be called before this.
+ static ManagedNetworkConfigurationHandler* Get();
+
+ // Provides the properties of the network with |id| to |callback|.
+ void GetProperties(
+ const std::string& id,
+ const network_handler::DictionaryResultCallback& callback,
+ const network_handler::ErrorCallback& error_callback) const;
+
+ // Sets the user's settings of an already configured network with |id|. A
+ // network can be initially configured by calling CreateConfiguration or if it
+ // is managed by a policy. The given properties will be merged with the
+ // existing settings, and it won't clear any existing properties.
+ void SetProperties(
+ const std::string& id,
+ const base::DictionaryValue& properties,
+ const base::Closure& callback,
+ const network_handler::ErrorCallback& error_callback) const;
+
+ // Initiates a connection with network that has |id|. |callback| is called if
+ // the connection request was successfully handled. That doesn't mean that the
+ // connection was successfully established.
+ void Connect(const std::string& id,
+ const base::Closure& callback,
+ const network_handler::ErrorCallback& error_callback) const;
+
+ // Initiates a disconnect with the network at |id|. |callback| is called if
+ // the diconnect request was successfully handled. That doesn't mean that the
+ // network is already diconnected.
+ void Disconnect(const std::string& id,
+ const base::Closure& callback,
+ const network_handler::ErrorCallback& error_callback) const;
+
+
+ // Initially configures an unconfigured network with the given user settings
+ // and returns the new identifier to |callback| if successful. Fails if the
+ // network was already configured by a call to this function or because of a
+ // policy.
+ void CreateConfiguration(
+ const base::DictionaryValue& properties,
+ const network_handler::StringResultCallback& callback,
+ const network_handler::ErrorCallback& error_callback) const;
+
+ // Removes the user's configuration from the network with |id|. The network
+ // may still show up in the visible networks after this, but no user
+ // configuration will remain. If it was managed, it will still be configured.
+ void RemoveConfiguration(
+ const std::string& id,
+ const base::Closure& callback,
+ const network_handler::ErrorCallback& error_callback) const;
+
+ private:
+ ManagedNetworkConfigurationHandler();
+ ~ManagedNetworkConfigurationHandler();
+
+ DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_NET_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698