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

Side by Side Diff: components/wifi_sync/wifi_config_delegate_chromeos.cc

Issue 836363002: wifi_sync: add WifiConfigDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@submit-4.1-network-state-helper
Patch Set: git checkout submit-4.4.0-add-delegate-factory 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 unified diff | Download patch
OLDNEW
(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 #include "components/wifi_sync/wifi_config_delegate_chromeos.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h"
11 #include "chromeos/network/managed_network_configuration_handler.h"
12 #include "components/wifi_sync/wifi_credential.h"
13
14 namespace wifi_sync {
15
16 namespace {
17
18 void DoNothingWithString(const std::string& arg) {}
19
20 void OnCreateConfigurationFailed(
21 const WifiCredential& wifi_credential,
22 const std::string& config_handler_error_message,
23 scoped_ptr<base::DictionaryValue> error_data) {
24 LOG(ERROR) << "Create configuration failed";
25 // TODO(quiche): check if there is a matching network already. If
26 // so, try to configure it with |wifi_credential|.
27 }
28
29 } // namespace
30
31 WifiConfigDelegateChromeOs::WifiConfigDelegateChromeOs(
32 const std::string& user_hash,
33 chromeos::ManagedNetworkConfigurationHandler* managed_net_config_handler)
34 : user_hash_(user_hash),
35 managed_network_configuration_handler_(managed_net_config_handler) {
36 DCHECK(!user_hash_.empty());
37 DCHECK(managed_network_configuration_handler_);
38 }
39
40 WifiConfigDelegateChromeOs::~WifiConfigDelegateChromeOs() {
41 }
42
43 void WifiConfigDelegateChromeOs::AddToLocalNetworks(
44 const WifiCredential& network_credential) {
45 scoped_ptr<base::DictionaryValue> onc_properties(
46 network_credential.ToOncProperties());
47 // TODO(quiche): Replace with DCHECK, once ONC supports non-UTF-8 SSIDs.
48 // crbug.com/432546
49 if (!onc_properties) {
50 LOG(ERROR) << "Failed to generate ONC properties for "
51 << network_credential.ToString();
52 return;
53 }
54 managed_network_configuration_handler_
55 ->CreateConfiguration(
56 user_hash_,
57 *onc_properties,
58 base::Bind(DoNothingWithString), // success_callback
erikwright (departed) 2015/01/13 19:03:13 These appear to be optional, although the document
stevenjb 2015/01/13 23:45:39 Correct. We should update the 'Note on callbacks'
mukesh agrawal 2015/01/15 03:01:48 Working on updating the NetworkConfigurationHandle
mukesh agrawal 2015/01/15 03:01:48 Done.
59 base::Bind(OnCreateConfigurationFailed, network_credential));
60 }
61
62 } // namespace wifi_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698