blob: 19f16b89a5d88a096f8964e05da216a11d84547a [file] [log] [blame]
hidehikoaab3dea2017-01-30 14:36:461// Copyright 2017 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#ifndef COMPONENTS_ARC_ARC_UTIL_H_
6#define COMPONENTS_ARC_ARC_UTIL_H_
7
8// This file contains utility to see ARC functionality status controlled by
9// outside of ARC, e.g. CommandLine flag, attribute of global data/state,
10// users' preferences, and FeatureList.
11
Mitsuru Oshima132ef982018-09-12 18:23:4612#include <stdint.h>
13
yusukes5f38c3cd2017-05-17 03:56:5514namespace aura {
15class Window;
16} // namespace aura
17
hidehikoaab3dea2017-01-30 14:36:4618namespace base {
19class CommandLine;
20} // namespace base
21
xiyuan94a81dea2017-05-25 14:31:0322namespace user_manager {
23class User;
24} // namespace user_manager
25
hidehikoaab3dea2017-01-30 14:36:4626namespace arc {
27
28// Returns true if ARC is installed and the current device is officially
29// supported to run ARC.
30// Note that, to run ARC practically, it is necessary to meet more conditions,
31// e.g., ARC supports only on Primary User Profile. To see if ARC can actually
32// run for the profile etc., arc::ArcSessionManager::IsAllowedForProfile() is
33// the function for that purpose. Please see also its comment, too.
34// Also note that, ARC singleton classes (e.g. ArcSessionManager,
35// ArcServiceManager, ArcServiceLauncher) are instantiated regardless of this
36// check, so it is ok to access them directly.
37bool IsArcAvailable();
38
Yusuke Sato0fadb602018-11-29 18:18:5739// Returns true if ARC VM is enabled.
40bool IsArcVmEnabled();
41
victorhsiehec707852017-03-07 19:37:0642// Returns true if ARC should always start within the primary user session
43// (opted in user or not), and other supported mode such as guest and Kiosk
44// mode.
45bool ShouldArcAlwaysStart();
46
Michael Giuffrida29f5d2c2018-09-28 02:05:4647// Returns true if ARC should always start with no Play Store availability
48// within the primary user session (opted in user or not), and other supported
49// mode such as guest and Kiosk mode.
50bool ShouldArcAlwaysStartWithNoPlayStore();
51
[email protected]4a982e3e2018-06-12 21:01:4752// Returns true if ARC OptIn ui needs to be shown for testing.
53bool ShouldShowOptInForTesting();
54
Victor Hsieh1124a9c2018-11-28 19:24:1755// Enables to always start ARC without Play Store for testing, by appending the
56// command line flag.
57void SetArcAlwaysStartWithoutPlayStoreForTesting();
victorhsiehec707852017-03-07 19:37:0658
poromov4fdd0672017-02-09 17:30:0259// Returns true if ARC is installed and running ARC kiosk apps on the current
60// device is officially supported.
61// It doesn't follow that ARC is available for user sessions and
62// IsArcAvailable() will return true, although the reverse should be.
63// This is used to distinguish special cases when ARC kiosk is available on
64// the device, but is not yet supported for regular user sessions.
65// In most cases, IsArcAvailable() check should be used instead of this.
66// Also not that this function may return true when ARC is not running in
67// Kiosk mode, it checks only ARC Kiosk availability.
68bool IsArcKioskAvailable();
69
hidehikoaab3dea2017-01-30 14:36:4670// For testing ARC in browser tests, this function should be called in
71// SetUpCommandLine(), and its argument should be passed to this function.
72// Also, in unittests, this can be called in SetUp() with
73// base::CommandLine::ForCurrentProcess().
74// |command_line| must not be nullptr.
75void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line);
76
poromov4fdd0672017-02-09 17:30:0277// Returns true if ARC should run under Kiosk mode for the current profile.
78// As it can return true only when user is already initialized, it implies
79// that ARC availability was checked before and IsArcKioskAvailable()
80// should also return true in that case.
hidehiko0b75bce62017-01-31 13:13:0181bool IsArcKioskMode();
82
Toni Barzic7a5f3e782018-07-03 17:51:3583// Returns true if current user is a robot account user, or offline demo mode
84// user.
85// These are Public Session and ARC Kiosk users. Note that demo mode, including
86// offline demo mode, is implemented as a Public Session - offline demo mode
87// is setup offline and it isn't associated with a working robot account.
Sergey Poromovba8ed0882017-12-22 11:40:4588// As it can return true only when user is already initialized, it implies
89// that ARC availability was checked before.
Toni Barzic7a5f3e782018-07-03 17:51:3590// The check is basically IsArcKioskMode() | IsLoggedInAsPublicSession().
91bool IsRobotOrOfflineDemoAccountMode();
Sergey Poromovba8ed0882017-12-22 11:40:4592
xiyuan94a81dea2017-05-25 14:31:0393// Returns true if ARC is allowed for the given user. Note this should not be
94// used as a signal of whether ARC is allowed alone because it only considers
95// user meta data. e.g. a user could be allowed for ARC but if the user signs in
96// as a secondary user or signs in to create a supervised user, ARC should be
97// disabled for such cases.
98bool IsArcAllowedForUser(const user_manager::User* user);
99
hidehiko0b75bce62017-01-31 13:13:01100// Checks if opt-in verification was disabled by switch in command line.
101// In most cases, it is disabled for testing purpose.
102bool IsArcOptInVerificationDisabled();
103
yusukes5f38c3cd2017-05-17 03:56:55104// Returns true if the |window|'s aura::client::kAppType is ARC_APP. When
105// |window| is nullptr, returns false.
Yuichiro Hanada9b8061f2018-06-06 22:51:27106bool IsArcAppWindow(const aura::Window* window);
yusukes5f38c3cd2017-05-17 03:56:55107
[email protected]654530e2018-12-18 21:31:51108// Returns true if ARC app icons are forced to cache.
109bool IsArcForceCacheAppIcon();
110
[email protected]95bfb712018-04-25 06:06:28111// Returns true if data clean up is requested for each ARC start.
112bool IsArcDataCleanupOnStartRequested();
113
yusukeseca81512017-05-25 22:47:57114// Adjusts the amount of CPU the ARC instance is allowed to use. When
115// |do_restrict| is true, the limit is adjusted so ARC can only use tightly
116// restricted CPU resources.
Yusuke Sato9e8443d2017-08-07 21:30:46117// TODO(yusukes): Use enum instead of bool.
yusukeseca81512017-05-25 22:47:57118void SetArcCpuRestriction(bool do_restrict);
updowndota29b240a2017-05-25 20:19:19119
Mitsuru Oshima132ef982018-09-12 18:23:46120// Returns the Android density that should be used for the given device scale
121// factor used on chrome.
122int32_t GetLcdDensityForDeviceScaleFactor(float device_scale_factor);
123
hidehikoaab3dea2017-01-30 14:36:46124} // namespace arc
125
126#endif // COMPONENTS_ARC_ARC_UTIL_H_