blob: 2cccfb2fbfbc17f99abe454cfcbb8bee3a09bf72 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2013 The Chromium Authors
[email protected]7207a9c2013-06-08 00:18:092// 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
avi0f233432015-12-25 02:23:387#include <stddef.h>
8
[email protected]7207a9c2013-06-08 00:18:099#include <algorithm>
10
Yeunjoo Choi6baf3062021-11-08 02:51:1011#include "ash/components/settings/cros_settings_names.h"
Henrique Ferreirof3fbcea22021-02-05 23:12:1912#include "ash/constants/ash_switches.h"
[email protected]7207a9c2013-06-08 00:18:0913#include "base/logging.h"
14#include "base/values.h"
Yeunjoo Choi5097e9c2021-02-25 08:46:5215#include "chrome/browser/ash/settings/cros_settings.h"
[email protected]7207a9c2013-06-08 00:18:0916
[email protected]7207a9c2013-06-08 00:18:0917namespace help_utils_chromeos {
18
weidongga02f7da2017-05-23 17:12:1119bool 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.
kumarniranjanb9afef62017-03-02 21:42:2222 bool default_update_over_cellular_allowed =
Henrique Ferreiro93dd33b2022-01-18 16:06:4523 interactive ? true : ash::switches::IsCellularFirstDevice();
kumarniranjanb9afef62017-03-02 21:42:2224
25 // Device Policy overrides the defaults.
Yeunjoo Choid461f872021-03-11 06:52:1926 ash::CrosSettings* settings = ash::CrosSettings::Get();
[email protected]7207a9c2013-06-08 00:18:0927 if (!settings)
kumarniranjanb9afef62017-03-02 21:42:2228 return default_update_over_cellular_allowed;
[email protected]7207a9c2013-06-08 00:18:0929
Alex Cooperf47262cc2021-07-17 04:11:2130 const base::Value* types_value =
Yeunjoo Choif6e9d4a2021-11-10 02:50:2831 settings->GetPref(ash::kAllowedConnectionTypesForUpdate);
Alex Cooperf47262cc2021-07-17 04:11:2132 if (!types_value)
kumarniranjanb9afef62017-03-02 21:42:2233 return default_update_over_cellular_allowed;
Alex Cooperf47262cc2021-07-17 04:11:2134 CHECK(types_value->is_list());
David Bertonife117fd2022-10-04 19:53:0135 const auto& list = types_value->GetList();
Alex Cooperf47262cc2021-07-17 04:11:2136 for (size_t i = 0; i < list.size(); ++i) {
37 if (!list[i].is_int()) {
[email protected]7207a9c2013-06-08 00:18:0938 LOG(WARNING) << "Can't parse connection type #" << i;
39 continue;
40 }
Alex Cooperf47262cc2021-07-17 04:11:2141
42 if (list[i].GetInt() == 4)
[email protected]7207a9c2013-06-08 00:18:0943 return true;
44 }
weidongga02f7da2017-05-23 17:12:1145 // 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]7207a9c2013-06-08 00:18:0948}
49
[email protected]7207a9c2013-06-08 00:18:0950} // namespace help_utils_chromeos