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

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 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 it's lifetime is managed by by the Chrome startup
34 // code.
35 //
36 // 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
37 // shouldn't rely on these identifiers being GUIDs from policies or Shill
38 // service paths. The identifiers are only guaranteed to be persistent over the
39 // lifetime of the singleton.
40 //
41 // Note on callbacks: Because all the functions here are meant to be
42 // asynchronous, they all take a |callback| of some type, and an
43 // |error_callback|. When the operation succeeds, |callback| will be called, and
44 // when it doesn't, |error_callback| will be called with information about the
45 // error, including a symbolic name for the error and often some error message
46 // that is suitable for logging. None of the error message text is meant for
47 // user consumption.
48 //
49 // Important note on the implementation: Currently, Shill's service paths are
50 // used as identifiers. However, this may change in the future.
51 //
52 // TODO(pneubeck): Enforce network policies.
53
54 class ManagedNetworkConfigurationHandler {
55 public:
56 // Initializes the singleton.
57 static void Initialize();
58
59 // Returns if the singleton is initialized.
60 static bool IsInitialized();
61
62 // Destroys the singleton.
63 static void Shutdown();
64
65 // Initialize() must be called before this.
66 static ManagedNetworkConfigurationHandler* Get();
67
68 // Provides the properties of the network with |id| to |callback|.
69 void GetProperties(
70 const std::string& id,
71 const network_handler::DictionaryResultCallback& callback,
72 const network_handler::ErrorCallback& error_callback) const;
73
74 // Sets the user's settings of an already configured network with |id|. A
75 // network can be initially configured by calling CreateConfiguration or if it
76 // is managed by a policy. The given properties will be merged with the
77 // existing settings, and it won't clear any existing properties.
78 void SetProperties(
79 const std::string& id,
80 const base::DictionaryValue& properties,
81 const base::Closure& callback,
82 const network_handler::ErrorCallback& error_callback) const;
83
84 // Initiates a connection with network that has |id|. |callback| is called if
85 // the connection request was successfully handled. That doesn't mean that the
86 // connection was successfully established.
87 void Connect(const std::string& id,
88 const base::Closure& callback,
89 const network_handler::ErrorCallback& error_callback) const;
90
91 // Initiates a disconnect with the network at |id|. |callback| is called if
92 // the diconnect request was successfully handled. That doesn't mean that the
93 // network is already diconnected.
94 void Disconnect(const std::string& id,
95 const base::Closure& callback,
96 const network_handler::ErrorCallback& error_callback) const;
97
98
99 // Initially configures an unconfigured network with the given user settings
100 // and returns the new identifier to |callback| if successful. Fails if the
101 // network was already configured by a call to this function or because of a
102 // policy.
103 void CreateConfiguration(
104 const base::DictionaryValue& properties,
105 const network_handler::StringResultCallback& callback,
106 const network_handler::ErrorCallback& error_callback) const;
107
108 // Removes the user's configuration from the network with |id|. The network
109 // may still show up in the visible networks after this, but no user
110 // configuration will remain. If it was managed, it will still be configured.
111 void RemoveConfiguration(
112 const std::string& id,
113 const base::Closure& callback,
114 const network_handler::ErrorCallback& error_callback) const;
115
116 private:
117 ManagedNetworkConfigurationHandler();
118 ~ManagedNetworkConfigurationHandler();
119
120 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler);
121 };
122
123 } // namespace chromeos
124
125 #endif // CHROME_BROWSER_CHROMEOS_NET_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698