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 | |
yusukes | 5f38c3cd | 2017-05-17 03:56:55 | [diff] [blame] | 12 | namespace aura { |
| 13 | class Window; |
| 14 | } // namespace aura |
| 15 | |
hidehiko | aab3dea | 2017-01-30 14:36:46 | [diff] [blame] | 16 | namespace base { |
| 17 | class CommandLine; |
| 18 | } // namespace base |
| 19 | |
xiyuan | 94a81dea | 2017-05-25 14:31:03 | [diff] [blame] | 20 | namespace user_manager { |
| 21 | class User; |
| 22 | } // namespace user_manager |
| 23 | |
hidehiko | aab3dea | 2017-01-30 14:36:46 | [diff] [blame] | 24 | namespace arc { |
| 25 | |
| 26 | // Returns true if ARC is installed and the current device is officially |
| 27 | // supported to run ARC. |
| 28 | // Note that, to run ARC practically, it is necessary to meet more conditions, |
| 29 | // e.g., ARC supports only on Primary User Profile. To see if ARC can actually |
| 30 | // run for the profile etc., arc::ArcSessionManager::IsAllowedForProfile() is |
| 31 | // the function for that purpose. Please see also its comment, too. |
| 32 | // Also note that, ARC singleton classes (e.g. ArcSessionManager, |
| 33 | // ArcServiceManager, ArcServiceLauncher) are instantiated regardless of this |
| 34 | // check, so it is ok to access them directly. |
| 35 | bool IsArcAvailable(); |
| 36 | |
Alex Newcomer | 8a32759 | 2017-08-09 18:53:18 | [diff] [blame] | 37 | // Returns true if ARC is not installed and the current device is not supported |
| 38 | // to run ARC. |
| 39 | bool IsWebstoreSearchEnabled(); |
| 40 | |
khmel | b045baaf | 2017-06-09 21:50:26 | [diff] [blame] | 41 | // Returns true if ARC image has Play Store package. |
| 42 | bool IsPlayStoreAvailable(); |
| 43 | |
victorhsieh | ec70785 | 2017-03-07 19:37:06 | [diff] [blame] | 44 | // Returns true if ARC should always start within the primary user session |
| 45 | // (opted in user or not), and other supported mode such as guest and Kiosk |
| 46 | // mode. |
| 47 | bool ShouldArcAlwaysStart(); |
| 48 | |
| 49 | // Enables to always start ARC for testing, by appending the command line flag. |
khmel | b045baaf | 2017-06-09 21:50:26 | [diff] [blame] | 50 | // If |bool play_store_available| is not set then flag that disables ARC Play |
| 51 | // Store UI is added. |
| 52 | void SetArcAlwaysStartForTesting(bool play_store_available); |
victorhsieh | ec70785 | 2017-03-07 19:37:06 | [diff] [blame] | 53 | |
poromov | 4fdd067 | 2017-02-09 17:30:02 | [diff] [blame] | 54 | // Returns true if ARC is installed and running ARC kiosk apps on the current |
| 55 | // device is officially supported. |
| 56 | // It doesn't follow that ARC is available for user sessions and |
| 57 | // IsArcAvailable() will return true, although the reverse should be. |
| 58 | // This is used to distinguish special cases when ARC kiosk is available on |
| 59 | // the device, but is not yet supported for regular user sessions. |
| 60 | // In most cases, IsArcAvailable() check should be used instead of this. |
| 61 | // Also not that this function may return true when ARC is not running in |
| 62 | // Kiosk mode, it checks only ARC Kiosk availability. |
| 63 | bool IsArcKioskAvailable(); |
| 64 | |
hidehiko | aab3dea | 2017-01-30 14:36:46 | [diff] [blame] | 65 | // For testing ARC in browser tests, this function should be called in |
| 66 | // SetUpCommandLine(), and its argument should be passed to this function. |
| 67 | // Also, in unittests, this can be called in SetUp() with |
| 68 | // base::CommandLine::ForCurrentProcess(). |
| 69 | // |command_line| must not be nullptr. |
| 70 | void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line); |
| 71 | |
poromov | 4fdd067 | 2017-02-09 17:30:02 | [diff] [blame] | 72 | // Returns true if ARC should run under Kiosk mode for the current profile. |
| 73 | // As it can return true only when user is already initialized, it implies |
| 74 | // that ARC availability was checked before and IsArcKioskAvailable() |
| 75 | // should also return true in that case. |
hidehiko | 0b75bce6 | 2017-01-31 13:13:01 | [diff] [blame] | 76 | bool IsArcKioskMode(); |
| 77 | |
Sergey Poromov | ba8ed088 | 2017-12-22 11:40:45 | [diff] [blame^] | 78 | // Returns true if current user is a robot account user. |
| 79 | // These are Public Session and ARC Kiosk users. |
| 80 | // As it can return true only when user is already initialized, it implies |
| 81 | // that ARC availability was checked before. |
| 82 | // The check is basically IsArcKioskMode() | IsPublicSessionMode(). |
| 83 | bool IsRobotAccountMode(); |
| 84 | |
xiyuan | 94a81dea | 2017-05-25 14:31:03 | [diff] [blame] | 85 | // Returns true if ARC is allowed for the given user. Note this should not be |
| 86 | // used as a signal of whether ARC is allowed alone because it only considers |
| 87 | // user meta data. e.g. a user could be allowed for ARC but if the user signs in |
| 88 | // as a secondary user or signs in to create a supervised user, ARC should be |
| 89 | // disabled for such cases. |
| 90 | bool IsArcAllowedForUser(const user_manager::User* user); |
| 91 | |
hidehiko | 0b75bce6 | 2017-01-31 13:13:01 | [diff] [blame] | 92 | // Checks if opt-in verification was disabled by switch in command line. |
| 93 | // In most cases, it is disabled for testing purpose. |
| 94 | bool IsArcOptInVerificationDisabled(); |
| 95 | |
yusukes | 5f38c3cd | 2017-05-17 03:56:55 | [diff] [blame] | 96 | // Returns true if the |window|'s aura::client::kAppType is ARC_APP. When |
| 97 | // |window| is nullptr, returns false. |
| 98 | bool IsArcAppWindow(aura::Window* window); |
| 99 | |
yusukes | eca8151 | 2017-05-25 22:47:57 | [diff] [blame] | 100 | // Adjusts the amount of CPU the ARC instance is allowed to use. When |
| 101 | // |do_restrict| is true, the limit is adjusted so ARC can only use tightly |
| 102 | // restricted CPU resources. |
Yusuke Sato | 9e8443d | 2017-08-07 21:30:46 | [diff] [blame] | 103 | // TODO(yusukes): Use enum instead of bool. |
yusukes | eca8151 | 2017-05-25 22:47:57 | [diff] [blame] | 104 | void SetArcCpuRestriction(bool do_restrict); |
updowndota | 29b240a | 2017-05-25 20:19:19 | [diff] [blame] | 105 | |
hidehiko | aab3dea | 2017-01-30 14:36:46 | [diff] [blame] | 106 | } // namespace arc |
| 107 | |
| 108 | #endif // COMPONENTS_ARC_ARC_UTIL_H_ |