OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" | 5 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/chromeos/settings/cros_settings.h" | 13 #include "chrome/browser/chromeos/settings/cros_settings.h" |
14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
15 #include "chromeos/chromeos_switches.h" | 15 #include "chromeos/chromeos_switches.h" |
16 #include "chromeos/network/network_type_pattern.h" | 16 #include "chromeos/network/network_type_pattern.h" |
17 #include "chromeos/settings/cros_settings_names.h" | 17 #include "chromeos/settings/cros_settings_names.h" |
18 #include "third_party/cros_system_api/dbus/service_constants.h" | 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 | 20 |
21 namespace help_utils_chromeos { | 21 namespace help_utils_chromeos { |
22 | 22 |
23 bool IsUpdateOverCellularAllowed() { | 23 bool IsUpdateOverCellularAllowed(bool interactive) { |
24 // If this is a Cellular First device, the default is to allow updates | 24 // If this is a Cellular First device or the user actively checks for update, |
25 // over cellular. | 25 // the default is to allow updates over cellular. |
26 bool default_update_over_cellular_allowed = | 26 bool default_update_over_cellular_allowed = |
27 chromeos::switches::IsCellularFirstDevice(); | 27 interactive ? true : chromeos::switches::IsCellularFirstDevice(); |
28 | 28 |
29 // Device Policy overrides the defaults. | 29 // Device Policy overrides the defaults. |
30 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); | 30 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); |
31 if (!settings) | 31 if (!settings) |
32 return default_update_over_cellular_allowed; | 32 return default_update_over_cellular_allowed; |
33 | 33 |
34 const base::Value* raw_types_value = | 34 const base::Value* raw_types_value = |
35 settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate); | 35 settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate); |
36 if (!raw_types_value) | 36 if (!raw_types_value) |
37 return default_update_over_cellular_allowed; | 37 return default_update_over_cellular_allowed; |
38 const base::ListValue* types_value; | 38 const base::ListValue* types_value; |
39 CHECK(raw_types_value->GetAsList(&types_value)); | 39 CHECK(raw_types_value->GetAsList(&types_value)); |
40 for (size_t i = 0; i < types_value->GetSize(); ++i) { | 40 for (size_t i = 0; i < types_value->GetSize(); ++i) { |
41 int connection_type; | 41 int connection_type; |
42 if (!types_value->GetInteger(i, &connection_type)) { | 42 if (!types_value->GetInteger(i, &connection_type)) { |
43 LOG(WARNING) << "Can't parse connection type #" << i; | 43 LOG(WARNING) << "Can't parse connection type #" << i; |
44 continue; | 44 continue; |
45 } | 45 } |
46 if (connection_type == 4) | 46 if (connection_type == 4) |
47 return true; | 47 return true; |
48 } | 48 } |
49 return default_update_over_cellular_allowed; | 49 // Device policy does not allow updates over cellular, as cellular is not |
| 50 // included in allowed connection types for updates. |
| 51 return false; |
50 } | 52 } |
51 | 53 |
52 base::string16 GetConnectionTypeAsUTF16(const std::string& type) { | 54 base::string16 GetConnectionTypeAsUTF16(const std::string& type) { |
53 if (chromeos::NetworkTypePattern::Ethernet().MatchesType(type)) | 55 if (chromeos::NetworkTypePattern::Ethernet().MatchesType(type)) |
54 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_ETHERNET); | 56 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_ETHERNET); |
55 if (type == shill::kTypeWifi) | 57 if (type == shill::kTypeWifi) |
56 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIFI); | 58 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIFI); |
57 if (type == shill::kTypeWimax) | 59 if (type == shill::kTypeWimax) |
58 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIMAX); | 60 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIMAX); |
59 if (type == shill::kTypeBluetooth) | 61 if (type == shill::kTypeBluetooth) |
60 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_BLUETOOTH); | 62 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_BLUETOOTH); |
61 if (type == shill::kTypeCellular) | 63 if (type == shill::kTypeCellular) |
62 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_CELLULAR); | 64 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_CELLULAR); |
63 if (type == shill::kTypeVPN) | 65 if (type == shill::kTypeVPN) |
64 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_VPN); | 66 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_VPN); |
65 NOTREACHED(); | 67 NOTREACHED(); |
66 return base::string16(); | 68 return base::string16(); |
67 } | 69 } |
68 | 70 |
69 } // namespace help_utils_chromeos | 71 } // namespace help_utils_chromeos |
OLD | NEW |