[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 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. | ||||
4 | |||||
5 | #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" | ||||
6 | |||||
7 | #include <algorithm> | ||||
8 | |||||
9 | #include "base/logging.h" | ||||
10 | #include "base/values.h" | ||||
11 | #include "chrome/browser/chromeos/settings/cros_settings.h" | ||||
[email protected] | 184bd2d | 2013-09-11 20:38:04 | [diff] [blame] | 12 | #include "chromeos/network/shill_property_util.h" |
[email protected] | 833a6bf2 | 2013-10-10 21:59:26 | [diff] [blame^] | 13 | #include "chromeos/settings/cros_settings_names.h" |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 14 | #include "grit/chromium_strings.h" |
15 | #include "grit/generated_resources.h" | ||||
16 | #include "third_party/cros_system_api/dbus/service_constants.h" | ||||
17 | #include "ui/base/l10n/l10n_util.h" | ||||
18 | |||||
19 | namespace { | ||||
20 | |||||
21 | const bool kDefaultUpdateOverCellularAllowed = false; | ||||
22 | |||||
23 | } // namespace | ||||
24 | |||||
25 | namespace help_utils_chromeos { | ||||
26 | |||||
27 | bool IsUpdateOverCellularAllowed() { | ||||
28 | chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); | ||||
29 | if (!settings) | ||||
30 | return kDefaultUpdateOverCellularAllowed; | ||||
31 | |||||
32 | const base::Value* raw_types_value = | ||||
33 | settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate); | ||||
34 | if (!raw_types_value) | ||||
35 | return kDefaultUpdateOverCellularAllowed; | ||||
36 | const base::ListValue* types_value; | ||||
37 | CHECK(raw_types_value->GetAsList(&types_value)); | ||||
38 | for (size_t i = 0; i < types_value->GetSize(); ++i) { | ||||
39 | int connection_type; | ||||
40 | if (!types_value->GetInteger(i, &connection_type)) { | ||||
41 | LOG(WARNING) << "Can't parse connection type #" << i; | ||||
42 | continue; | ||||
43 | } | ||||
44 | if (connection_type == 4) | ||||
45 | return true; | ||||
46 | } | ||||
47 | return kDefaultUpdateOverCellularAllowed; | ||||
48 | } | ||||
49 | |||||
50 | string16 GetConnectionTypeAsUTF16(const std::string& type) { | ||||
[email protected] | 184bd2d | 2013-09-11 20:38:04 | [diff] [blame] | 51 | if (chromeos::NetworkTypePattern::Ethernet().MatchesType(type)) |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 52 | return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_ETHERNET); |
[email protected] | 05f43462 | 2013-09-25 06:51:55 | [diff] [blame] | 53 | if (type == shill::kTypeWifi) |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 54 | return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIFI); |
[email protected] | 05f43462 | 2013-09-25 06:51:55 | [diff] [blame] | 55 | if (type == shill::kTypeWimax) |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 56 | return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIMAX); |
[email protected] | 05f43462 | 2013-09-25 06:51:55 | [diff] [blame] | 57 | if (type == shill::kTypeBluetooth) |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 58 | return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_BLUETOOTH); |
[email protected] | 05f43462 | 2013-09-25 06:51:55 | [diff] [blame] | 59 | if (type == shill::kTypeCellular) |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 60 | return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_CELLULAR); |
[email protected] | 05f43462 | 2013-09-25 06:51:55 | [diff] [blame] | 61 | if (type == shill::kTypeVPN) |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 62 | return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_VPN); |
63 | NOTREACHED(); | ||||
64 | return string16(); | ||||
65 | } | ||||
66 | |||||
67 | } // namespace help_utils_chromeos |