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