Only send _NET_ACTIVE_WINDOW hint if the chromium window is not already active.
[chromium-blink-merge.git] / components / wifi_sync / wifi_config_delegate_chromeos.cc
blobd8d241fc17c885c947fd48ec79e117dfed44c05a
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.
5 #include "components/wifi_sync/wifi_config_delegate_chromeos.h"
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"
14 namespace wifi_sync {
16 namespace {
18 void OnCreateConfigurationFailed(
19 const WifiCredential& wifi_credential,
20 const std::string& config_handler_error_message,
21 scoped_ptr<base::DictionaryValue> error_data) {
22 LOG(ERROR) << "Create configuration failed";
23 // TODO(quiche): check if there is a matching network already. If
24 // so, try to configure it with |wifi_credential|.
27 } // namespace
29 WifiConfigDelegateChromeOs::WifiConfigDelegateChromeOs(
30 const std::string& user_hash,
31 chromeos::ManagedNetworkConfigurationHandler* managed_net_config_handler)
32 : user_hash_(user_hash),
33 managed_network_configuration_handler_(managed_net_config_handler) {
34 DCHECK(!user_hash_.empty());
35 DCHECK(managed_network_configuration_handler_);
38 WifiConfigDelegateChromeOs::~WifiConfigDelegateChromeOs() {
41 void WifiConfigDelegateChromeOs::AddToLocalNetworks(
42 const WifiCredential& network_credential) {
43 scoped_ptr<base::DictionaryValue> onc_properties(
44 network_credential.ToOncProperties());
45 // TODO(quiche): Replace with DCHECK, once ONC supports non-UTF-8 SSIDs.
46 // crbug.com/432546
47 if (!onc_properties) {
48 LOG(ERROR) << "Failed to generate ONC properties for "
49 << network_credential.ToString();
50 return;
53 managed_network_configuration_handler_
54 ->CreateConfiguration(
55 user_hash_,
56 *onc_properties,
57 chromeos::network_handler::StringResultCallback(),
58 base::Bind(OnCreateConfigurationFailed, network_credential));
61 } // namespace wifi_sync