blob: cfddc576e74bccca98180e0d81d159786f6590c0 [file] [log] [blame]
[email protected]7207a9c2013-06-08 00:18:091// 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
avi0f233432015-12-25 02:23:387#include <stddef.h>
8
[email protected]7207a9c2013-06-08 00:18:099#include <algorithm>
10
Henrique Ferreirof3fbcea22021-02-05 23:12:1911#include "ash/constants/ash_switches.h"
[email protected]7207a9c2013-06-08 00:18:0912#include "base/logging.h"
13#include "base/values.h"
Yeunjoo Choi5097e9c2021-02-25 08:46:5214#include "chrome/browser/ash/settings/cros_settings.h"
[email protected]833a6bf22013-10-10 21:59:2615#include "chromeos/settings/cros_settings_names.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 =
weidongga02f7da2017-05-23 17:12:1123 interactive ? true : chromeos::switches::IsCellularFirstDevice();
kumarniranjanb9afef62017-03-02 21:42:2224
25 // Device Policy overrides the defaults.
[email protected]7207a9c2013-06-08 00:18:0926 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get();
27 if (!settings)
kumarniranjanb9afef62017-03-02 21:42:2228 return default_update_over_cellular_allowed;
[email protected]7207a9c2013-06-08 00:18:0929
30 const base::Value* raw_types_value =
31 settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate);
32 if (!raw_types_value)
kumarniranjanb9afef62017-03-02 21:42:2233 return default_update_over_cellular_allowed;
[email protected]7207a9c2013-06-08 00:18:0934 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 }
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