hidehiko | aab3dea | 2017-01-30 14:36:46 | [diff] [blame] | 1 | // 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 Oshima | 132ef98 | 2018-09-12 18:23:46 | [diff] [blame] | 12 | #include <stdint.h> |
| 13 | |
yusukes | 5f38c3cd | 2017-05-17 03:56:55 | [diff] [blame] | 14 | namespace aura { |
| 15 | class Window; |
| 16 | } // namespace aura |
| 17 | |
hidehiko | aab3dea | 2017-01-30 14:36:46 | [diff] [blame] | 18 | namespace base { |
| 19 | class CommandLine; |
| 20 | } // namespace base |
| 21 | |
xiyuan | 94a81dea | 2017-05-25 14:31:03 | [diff] [blame] | 22 | namespace user_manager { |
| 23 | class User; |
| 24 | } // namespace user_manager |
| 25 | |
hidehiko | aab3dea | 2017-01-30 14:36:46 | [diff] [blame] | 26 | namespace 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. |
| 37 | bool IsArcAvailable(); |
| 38 | |
Yusuke Sato | 0fadb60 | 2018-11-29 18:18:57 | [diff] [blame] | 39 | // Returns true if ARC VM is enabled. |
| 40 | bool IsArcVmEnabled(); |
| 41 | |
victorhsieh | ec70785 | 2017-03-07 19:37:06 | [diff] [blame] | 42 | // 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. |
| 45 | bool ShouldArcAlwaysStart(); |
| 46 | |
Michael Giuffrida | 29f5d2c | 2018-09-28 02:05:46 | [diff] [blame] | 47 | // 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. |
| 50 | bool ShouldArcAlwaysStartWithNoPlayStore(); |
| 51 | |
[email protected] | 4a982e3e | 2018-06-12 21:01:47 | [diff] [blame] | 52 | // Returns true if ARC OptIn ui needs to be shown for testing. |
| 53 | bool ShouldShowOptInForTesting(); |
| 54 | |
Victor Hsieh | 1124a9c | 2018-11-28 19:24:17 | [diff] [blame] | 55 | // Enables to always start ARC without Play Store for testing, by appending the |
| 56 | // command line flag. |
| 57 | void SetArcAlwaysStartWithoutPlayStoreForTesting(); |
victorhsieh | ec70785 | 2017-03-07 19:37:06 | [diff] [blame] | 58 | |
poromov | 4fdd067 | 2017-02-09 17:30:02 | [diff] [blame] | 59 | // 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. |
| 68 | bool IsArcKioskAvailable(); |
| 69 | |
hidehiko | aab3dea | 2017-01-30 14:36:46 | [diff] [blame] | 70 | // 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. |
| 75 | void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line); |
| 76 | |
poromov | 4fdd067 | 2017-02-09 17:30:02 | [diff] [blame] | 77 | // 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. |
hidehiko | 0b75bce6 | 2017-01-31 13:13:01 | [diff] [blame] | 81 | bool IsArcKioskMode(); |
| 82 | |
Toni Barzic | 7a5f3e78 | 2018-07-03 17:51:35 | [diff] [blame] | 83 | // 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 Poromov | ba8ed088 | 2017-12-22 11:40:45 | [diff] [blame] | 88 | // As it can return true only when user is already initialized, it implies |
| 89 | // that ARC availability was checked before. |
Toni Barzic | 7a5f3e78 | 2018-07-03 17:51:35 | [diff] [blame] | 90 | // The check is basically IsArcKioskMode() | IsLoggedInAsPublicSession(). |
| 91 | bool IsRobotOrOfflineDemoAccountMode(); |
Sergey Poromov | ba8ed088 | 2017-12-22 11:40:45 | [diff] [blame] | 92 | |
xiyuan | 94a81dea | 2017-05-25 14:31:03 | [diff] [blame] | 93 | // 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. |
| 98 | bool IsArcAllowedForUser(const user_manager::User* user); |
| 99 | |
hidehiko | 0b75bce6 | 2017-01-31 13:13:01 | [diff] [blame] | 100 | // Checks if opt-in verification was disabled by switch in command line. |
| 101 | // In most cases, it is disabled for testing purpose. |
| 102 | bool IsArcOptInVerificationDisabled(); |
| 103 | |
yusukes | 5f38c3cd | 2017-05-17 03:56:55 | [diff] [blame] | 104 | // Returns true if the |window|'s aura::client::kAppType is ARC_APP. When |
| 105 | // |window| is nullptr, returns false. |
Yuichiro Hanada | 9b8061f | 2018-06-06 22:51:27 | [diff] [blame] | 106 | bool IsArcAppWindow(const aura::Window* window); |
yusukes | 5f38c3cd | 2017-05-17 03:56:55 | [diff] [blame] | 107 | |
[email protected] | 654530e | 2018-12-18 21:31:51 | [diff] [blame] | 108 | // Returns true if ARC app icons are forced to cache. |
| 109 | bool IsArcForceCacheAppIcon(); |
| 110 | |
[email protected] | 95bfb71 | 2018-04-25 06:06:28 | [diff] [blame] | 111 | // Returns true if data clean up is requested for each ARC start. |
| 112 | bool IsArcDataCleanupOnStartRequested(); |
| 113 | |
[email protected] | 222c7a1 | 2018-12-21 21:48:54 | [diff] [blame] | 114 | // Returns true in case ARC app sync flow is disabled. |
| 115 | bool IsArcAppSyncFlowDisabled(); |
| 116 | |
| 117 | // Returns true in case ARC Play Auto Install flow is disabled. |
| 118 | bool IsArcPlayAutoInstallDisabled(); |
| 119 | |
yusukes | eca8151 | 2017-05-25 22:47:57 | [diff] [blame] | 120 | // Adjusts the amount of CPU the ARC instance is allowed to use. When |
| 121 | // |do_restrict| is true, the limit is adjusted so ARC can only use tightly |
| 122 | // restricted CPU resources. |
Yusuke Sato | 9e8443d | 2017-08-07 21:30:46 | [diff] [blame] | 123 | // TODO(yusukes): Use enum instead of bool. |
yusukes | eca8151 | 2017-05-25 22:47:57 | [diff] [blame] | 124 | void SetArcCpuRestriction(bool do_restrict); |
updowndota | 29b240a | 2017-05-25 20:19:19 | [diff] [blame] | 125 | |
Mitsuru Oshima | 132ef98 | 2018-09-12 18:23:46 | [diff] [blame] | 126 | // Returns the Android density that should be used for the given device scale |
| 127 | // factor used on chrome. |
| 128 | int32_t GetLcdDensityForDeviceScaleFactor(float device_scale_factor); |
| 129 | |
hidehiko | aab3dea | 2017-01-30 14:36:46 | [diff] [blame] | 130 | } // namespace arc |
| 131 | |
| 132 | #endif // COMPONENTS_ARC_ARC_UTIL_H_ |