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

Side by Side 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 Gaurav's and Steven's comments. Created 7 years, 9 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 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_CHROMEOS_NET_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
6 #define CHROME_BROWSER_CHROMEOS_NET_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/gtest_prod_util.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/network/network_handler_callbacks.h"
16
17 namespace base {
18 class DictionaryValue;
19 }
20
21 namespace chromeos {
22
23 // The ManagedNetworkConfigurationHandler class is used to create and configure
24 // networks in ChromeOS using ONC.
25 //
26 // Its interface exposes only ONC and should decouple users from Shill.
27 // Internally it translates ONC to Shill dictionaries and calls through to the
28 // NetworkConfigurationHandler.
29 //
30 // For accessing lists of visible networks, and other state information, see the
31 // class NetworkStateHandler.
32 //
33 // This is a singleton and its lifetime is managed by the Chrome startup code.
34 //
35 // Network configurations are referred to by Shill's service path. These
36 // identifiers should at most be used to also access network state using the
37 // NetworkStateHandler, but dependencies to Shill should be avoided. In the
38 // future, we may switch to other identifiers.
39 //
40 // Note on callbacks: Because all the functions here are meant to be
41 // asynchronous, they all take a |callback| of some type, and an
42 // |error_callback|. When the operation succeeds, |callback| will be called, and
43 // when it doesn't, |error_callback| will be called with information about the
44 // error, including a symbolic name for the error and often some error message
45 // that is suitable for logging. None of the error message text is meant for
46 // user consumption.
47 //
48 // TODO(pneubeck): Enforce network policies.
49
50 class ManagedNetworkConfigurationHandler {
51 public:
52 // Initializes the singleton.
53 static void Initialize();
54
55 // Returns if the singleton is initialized.
56 static bool IsInitialized();
57
58 // Destroys the singleton.
59 static void Shutdown();
60
61 // Initialize() must be called before this.
62 static ManagedNetworkConfigurationHandler* Get();
63
64 // Provides the properties of the network with |service_path| to |callback|.
65 void GetProperties(
66 const std::string& service_path,
67 const network_handler::DictionaryResultCallback& callback,
68 const network_handler::ErrorCallback& error_callback) const;
69
70 // Sets the user's settings of an already configured network with
71 // |service_path|. A network can be initially configured by calling
72 // CreateConfiguration or if it is managed by a policy. The given properties
73 // will be merged with the existing settings, and it won't clear any existing
74 // properties.
75 void SetProperties(
76 const std::string& service_path,
77 const base::DictionaryValue& properties,
78 const base::Closure& callback,
79 const network_handler::ErrorCallback& error_callback) const;
80
81 // Initiates a connection with network that has |service_path|. |callback| is
82 // called if the connection request was successfully handled. That doesn't
83 // mean that the connection was successfully established.
84 void Connect(const std::string& service_path,
85 const base::Closure& callback,
86 const network_handler::ErrorCallback& error_callback) const;
87
88 // Initiates a disconnect with the network at |service_path|. |callback| is
89 // called if the diconnect request was successfully handled. That doesn't mean
90 // that the network is already diconnected.
91 void Disconnect(const std::string& service_path,
92 const base::Closure& callback,
93 const network_handler::ErrorCallback& error_callback) const;
94
95 // Initially configures an unconfigured network with the given user settings
96 // and returns the new identifier to |callback| if successful. Fails if the
97 // network was already configured by a call to this function or because of a
98 // policy.
99 void CreateConfiguration(
100 const base::DictionaryValue& properties,
101 const network_handler::StringResultCallback& callback,
102 const network_handler::ErrorCallback& error_callback) const;
103
104 // Removes the user's configuration from the network with |service_path|. The
105 // network may still show up in the visible networks after this, but no user
106 // configuration will remain. If it was managed, it will still be configured.
107 void RemoveConfiguration(
108 const std::string& service_path,
109 const base::Closure& callback,
110 const network_handler::ErrorCallback& error_callback) const;
111
112 private:
113 ManagedNetworkConfigurationHandler();
114 ~ManagedNetworkConfigurationHandler();
115
116 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler);
117 };
118
119 } // namespace chromeos
120
121 #endif // CHROME_BROWSER_CHROMEOS_NET_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/net/OWNERS ('k') | chrome/browser/chromeos/net/managed_network_configuration_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698