| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/arc/arc_util.h" | 5 #include "components/arc/arc_util.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| 9 #include "chromeos/chromeos_switches.h" | 11 #include "chromeos/chromeos_switches.h" |
| 10 #include "components/user_manager/user_manager.h" | 12 #include "components/user_manager/user_manager.h" |
| 11 | 13 |
| 12 namespace arc { | 14 namespace arc { |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 // This is for finch. See also crbug.com/633704 for details. | 18 // This is for finch. See also crbug.com/633704 for details. |
| 17 // TODO(hidehiko): More comments of the intention how this works, when | 19 // TODO(hidehiko): More comments of the intention how this works, when |
| 18 // we unify the commandline flags. | 20 // we unify the commandline flags. |
| 19 const base::Feature kEnableArcFeature{"EnableARC", | 21 const base::Feature kEnableArcFeature{"EnableARC", |
| 20 base::FEATURE_DISABLED_BY_DEFAULT}; | 22 base::FEATURE_DISABLED_BY_DEFAULT}; |
| 21 | 23 |
| 24 // Possible values for --arc-availability flag. |
| 25 constexpr char kAvailabilityNone[] = "none"; |
| 26 constexpr char kAvailabilityInstalled[] = "installed"; |
| 27 constexpr char kAvailabilityOfficiallySupported[] = "officially-supported"; |
| 28 |
| 22 } // namespace | 29 } // namespace |
| 23 | 30 |
| 24 bool IsArcAvailable() { | 31 bool IsArcAvailable() { |
| 25 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 32 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 26 // TODO(hidehiko): Unify --enable-arc and --arc-available flags. | 33 |
| 27 // If switches::kEnableArc is set, the device is officially supported to run | 34 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { |
| 28 // ARC. If it is not, but switches::kArcAvailable is set, ARC is installed | 35 std::string value = command_line->GetSwitchValueASCII( |
| 29 // but is not allowed to run unless |kEnableArcFeature| is true. | 36 chromeos::switches::kArcAvailability); |
| 37 DCHECK(value == kAvailabilityNone || |
| 38 value == kAvailabilityInstalled || |
| 39 value == kAvailabilityOfficiallySupported) |
| 40 << "Unknown flag value: " << value; |
| 41 return value == kAvailabilityOfficiallySupported || |
| 42 (value == kAvailabilityInstalled && |
| 43 base::FeatureList::IsEnabled(kEnableArcFeature)); |
| 44 } |
| 45 |
| 46 // For transition, fallback to old flags. |
| 47 // TODO(hidehiko): Remove this and clean up whole this function, when |
| 48 // session_manager supports a new flag. |
| 30 return command_line->HasSwitch(chromeos::switches::kEnableArc) || | 49 return command_line->HasSwitch(chromeos::switches::kEnableArc) || |
| 31 (command_line->HasSwitch(chromeos::switches::kArcAvailable) && | 50 (command_line->HasSwitch(chromeos::switches::kArcAvailable) && |
| 32 base::FeatureList::IsEnabled(kEnableArcFeature)); | 51 base::FeatureList::IsEnabled(kEnableArcFeature)); |
| 33 } | 52 } |
| 34 | 53 |
| 35 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { | 54 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { |
| 36 command_line->AppendSwitch(chromeos::switches::kEnableArc); | 55 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, |
| 56 kAvailabilityOfficiallySupported); |
| 37 } | 57 } |
| 38 | 58 |
| 39 bool IsArcKioskMode() { | 59 bool IsArcKioskMode() { |
| 40 return user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); | 60 return user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); |
| 41 } | 61 } |
| 42 | 62 |
| 43 bool IsArcOptInVerificationDisabled() { | 63 bool IsArcOptInVerificationDisabled() { |
| 44 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 64 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 45 return command_line->HasSwitch( | 65 return command_line->HasSwitch( |
| 46 chromeos::switches::kDisableArcOptInVerification); | 66 chromeos::switches::kDisableArcOptInVerification); |
| 47 } | 67 } |
| 48 | 68 |
| 49 } // namespace arc | 69 } // namespace arc |
| OLD | NEW |