Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / webui / help / help_utils_chromeos.cc
blob7896f0c6804fdd5108ec2cad6c4f3e8ca93e448e
1 // Copyright 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.
5 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h"
7 #include <algorithm>
9 #include "base/logging.h"
10 #include "base/values.h"
11 #include "chrome/browser/chromeos/settings/cros_settings.h"
12 #include "chrome/grit/generated_resources.h"
13 #include "chromeos/network/network_type_pattern.h"
14 #include "chromeos/settings/cros_settings_names.h"
15 #include "third_party/cros_system_api/dbus/service_constants.h"
16 #include "ui/base/l10n/l10n_util.h"
18 namespace {
20 const bool kDefaultUpdateOverCellularAllowed = false;
22 } // namespace
24 namespace help_utils_chromeos {
26 bool IsUpdateOverCellularAllowed() {
27 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get();
28 if (!settings)
29 return kDefaultUpdateOverCellularAllowed;
31 const base::Value* raw_types_value =
32 settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate);
33 if (!raw_types_value)
34 return kDefaultUpdateOverCellularAllowed;
35 const base::ListValue* types_value;
36 CHECK(raw_types_value->GetAsList(&types_value));
37 for (size_t i = 0; i < types_value->GetSize(); ++i) {
38 int connection_type;
39 if (!types_value->GetInteger(i, &connection_type)) {
40 LOG(WARNING) << "Can't parse connection type #" << i;
41 continue;
43 if (connection_type == 4)
44 return true;
46 return kDefaultUpdateOverCellularAllowed;
49 base::string16 GetConnectionTypeAsUTF16(const std::string& type) {
50 if (chromeos::NetworkTypePattern::Ethernet().MatchesType(type))
51 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_ETHERNET);
52 if (type == shill::kTypeWifi)
53 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIFI);
54 if (type == shill::kTypeWimax)
55 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIMAX);
56 if (type == shill::kTypeBluetooth)
57 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_BLUETOOTH);
58 if (type == shill::kTypeCellular)
59 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_CELLULAR);
60 if (type == shill::kTypeVPN)
61 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_VPN);
62 NOTREACHED();
63 return base::string16();
66 } // namespace help_utils_chromeos