[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 | |||||
avi | 0f23343 | 2015-12-25 02:23:38 | [diff] [blame] | 7 | #include <stddef.h> |
8 | |||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 9 | #include <algorithm> |
10 | |||||
Henrique Ferreiro | f3fbcea2 | 2021-02-05 23:12:19 | [diff] [blame] | 11 | #include "ash/constants/ash_switches.h" |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 12 | #include "base/logging.h" |
13 | #include "base/values.h" | ||||
Yeunjoo Choi | 5097e9c | 2021-02-25 08:46:52 | [diff] [blame^] | 14 | #include "chrome/browser/ash/settings/cros_settings.h" |
[email protected] | 833a6bf2 | 2013-10-10 21:59:26 | [diff] [blame] | 15 | #include "chromeos/settings/cros_settings_names.h" |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 16 | |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 17 | namespace help_utils_chromeos { |
18 | |||||
weidongg | a02f7da | 2017-05-23 17:12:11 | [diff] [blame] | 19 | bool IsUpdateOverCellularAllowed(bool interactive) { |
20 | // If this is a Cellular First device or the user actively checks for update, | ||||
21 | // the default is to allow updates over cellular. | ||||
kumarniranjan | b9afef6 | 2017-03-02 21:42:22 | [diff] [blame] | 22 | bool default_update_over_cellular_allowed = |
weidongg | a02f7da | 2017-05-23 17:12:11 | [diff] [blame] | 23 | interactive ? true : chromeos::switches::IsCellularFirstDevice(); |
kumarniranjan | b9afef6 | 2017-03-02 21:42:22 | [diff] [blame] | 24 | |
25 | // Device Policy overrides the defaults. | ||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 26 | chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); |
27 | if (!settings) | ||||
kumarniranjan | b9afef6 | 2017-03-02 21:42:22 | [diff] [blame] | 28 | return default_update_over_cellular_allowed; |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 29 | |
30 | const base::Value* raw_types_value = | ||||
31 | settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate); | ||||
32 | if (!raw_types_value) | ||||
kumarniranjan | b9afef6 | 2017-03-02 21:42:22 | [diff] [blame] | 33 | return default_update_over_cellular_allowed; |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 34 | const base::ListValue* types_value; |
35 | CHECK(raw_types_value->GetAsList(&types_value)); | ||||
36 | for (size_t i = 0; i < types_value->GetSize(); ++i) { | ||||
37 | int connection_type; | ||||
38 | if (!types_value->GetInteger(i, &connection_type)) { | ||||
39 | LOG(WARNING) << "Can't parse connection type #" << i; | ||||
40 | continue; | ||||
41 | } | ||||
42 | if (connection_type == 4) | ||||
43 | return true; | ||||
44 | } | ||||
weidongg | a02f7da | 2017-05-23 17:12:11 | [diff] [blame] | 45 | // Device policy does not allow updates over cellular, as cellular is not |
46 | // included in allowed connection types for updates. | ||||
47 | return false; | ||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 48 | } |
49 | |||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 50 | } // namespace help_utils_chromeos |