| 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/network/network_type_pattern.h" | 16 #include "chromeos/network/network_type_pattern.h" |
| 16 #include "chromeos/settings/cros_settings_names.h" | 17 #include "chromeos/settings/cros_settings_names.h" |
| 17 #include "third_party/cros_system_api/dbus/service_constants.h" | 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 19 | 20 |
| 20 namespace { | |
| 21 | |
| 22 const bool kDefaultUpdateOverCellularAllowed = false; | |
| 23 | |
| 24 } // namespace | |
| 25 | |
| 26 namespace help_utils_chromeos { | 21 namespace help_utils_chromeos { |
| 27 | 22 |
| 28 bool IsUpdateOverCellularAllowed() { | 23 bool IsUpdateOverCellularAllowed() { |
| 24 // If this is a Cellular First device, the default is to allow updates |
| 25 // over cellular. |
| 26 bool default_update_over_cellular_allowed = |
| 27 chromeos::switches::IsCellularFirstDevice(); |
| 28 |
| 29 // Device Policy overrides the defaults. |
| 29 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); | 30 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); |
| 30 if (!settings) | 31 if (!settings) |
| 31 return kDefaultUpdateOverCellularAllowed; | 32 return default_update_over_cellular_allowed; |
| 32 | 33 |
| 33 const base::Value* raw_types_value = | 34 const base::Value* raw_types_value = |
| 34 settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate); | 35 settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate); |
| 35 if (!raw_types_value) | 36 if (!raw_types_value) |
| 36 return kDefaultUpdateOverCellularAllowed; | 37 return default_update_over_cellular_allowed; |
| 37 const base::ListValue* types_value; | 38 const base::ListValue* types_value; |
| 38 CHECK(raw_types_value->GetAsList(&types_value)); | 39 CHECK(raw_types_value->GetAsList(&types_value)); |
| 39 for (size_t i = 0; i < types_value->GetSize(); ++i) { | 40 for (size_t i = 0; i < types_value->GetSize(); ++i) { |
| 40 int connection_type; | 41 int connection_type; |
| 41 if (!types_value->GetInteger(i, &connection_type)) { | 42 if (!types_value->GetInteger(i, &connection_type)) { |
| 42 LOG(WARNING) << "Can't parse connection type #" << i; | 43 LOG(WARNING) << "Can't parse connection type #" << i; |
| 43 continue; | 44 continue; |
| 44 } | 45 } |
| 45 if (connection_type == 4) | 46 if (connection_type == 4) |
| 46 return true; | 47 return true; |
| 47 } | 48 } |
| 48 return kDefaultUpdateOverCellularAllowed; | 49 return default_update_over_cellular_allowed; |
| 49 } | 50 } |
| 50 | 51 |
| 51 base::string16 GetConnectionTypeAsUTF16(const std::string& type) { | 52 base::string16 GetConnectionTypeAsUTF16(const std::string& type) { |
| 52 if (chromeos::NetworkTypePattern::Ethernet().MatchesType(type)) | 53 if (chromeos::NetworkTypePattern::Ethernet().MatchesType(type)) |
| 53 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_ETHERNET); | 54 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_ETHERNET); |
| 54 if (type == shill::kTypeWifi) | 55 if (type == shill::kTypeWifi) |
| 55 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIFI); | 56 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIFI); |
| 56 if (type == shill::kTypeWimax) | 57 if (type == shill::kTypeWimax) |
| 57 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIMAX); | 58 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIMAX); |
| 58 if (type == shill::kTypeBluetooth) | 59 if (type == shill::kTypeBluetooth) |
| 59 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_BLUETOOTH); | 60 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_BLUETOOTH); |
| 60 if (type == shill::kTypeCellular) | 61 if (type == shill::kTypeCellular) |
| 61 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_CELLULAR); | 62 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_CELLULAR); |
| 62 if (type == shill::kTypeVPN) | 63 if (type == shill::kTypeVPN) |
| 63 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_VPN); | 64 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_VPN); |
| 64 NOTREACHED(); | 65 NOTREACHED(); |
| 65 return base::string16(); | 66 return base::string16(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 } // namespace help_utils_chromeos | 69 } // namespace help_utils_chromeos |
| OLD | NEW |