Chromium Code Reviews| 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> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| 11 #include "chromeos/chromeos_switches.h" | 11 #include "chromeos/chromeos_switches.h" |
| 12 #include "components/user_manager/user_manager.h" | 12 #include "components/user_manager/user_manager.h" |
| 13 | 13 |
| 14 namespace arc { | 14 namespace arc { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // This is for finch. See also crbug.com/633704 for details. | 18 // This is for finch. See also crbug.com/633704 for details. |
| 19 // TODO(hidehiko): More comments of the intention how this works, when | 19 // TODO(hidehiko): More comments of the intention how this works, when |
| 20 // we unify the commandline flags. | 20 // we unify the commandline flags. |
| 21 const base::Feature kEnableArcFeature{"EnableARC", | 21 const base::Feature kEnableArcFeature{"EnableARC", |
| 22 base::FEATURE_DISABLED_BY_DEFAULT}; | 22 base::FEATURE_DISABLED_BY_DEFAULT}; |
| 23 | 23 |
| 24 // Possible values for --arc-availability flag. | 24 // Possible values for --arc-availability flag. |
| 25 constexpr char kAvailabilityNone[] = "none"; | 25 constexpr char kAvailabilityNone[] = "none"; |
| 26 constexpr char kAvailabilityInstalled[] = "installed"; | 26 constexpr char kAvailabilityInstalled[] = "installed"; |
| 27 constexpr char kAvailabilityOfficiallySupported[] = "officially-supported"; | 27 constexpr char kAvailabilityOfficiallySupported[] = "officially-supported"; |
| 28 constexpr char kAvailabilityOfficiallySupportedWithActiveDirectory[] = | |
| 29 "officially-supported-with-active-directory"; | |
| 28 | 30 |
| 29 } // namespace | 31 } // namespace |
| 30 | 32 |
| 31 bool IsArcAvailable() { | 33 bool IsArcAvailable() { |
| 32 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 34 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 33 | 35 |
| 34 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { | 36 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { |
| 35 std::string value = command_line->GetSwitchValueASCII( | 37 std::string value = command_line->GetSwitchValueASCII( |
| 36 chromeos::switches::kArcAvailability); | 38 chromeos::switches::kArcAvailability); |
| 37 DCHECK(value == kAvailabilityNone || | 39 DCHECK(value == kAvailabilityNone || value == kAvailabilityInstalled || |
| 38 value == kAvailabilityInstalled || | 40 value == kAvailabilityOfficiallySupported || |
| 39 value == kAvailabilityOfficiallySupported) | 41 value == kAvailabilityOfficiallySupportedWithActiveDirectory) |
| 40 << "Unknown flag value: " << value; | 42 << "Unknown flag value: " << value; |
| 41 return value == kAvailabilityOfficiallySupported || | 43 return value == kAvailabilityOfficiallySupported || |
| 42 (value == kAvailabilityInstalled && | 44 value == kAvailabilityOfficiallySupportedWithActiveDirectory || |
| 43 base::FeatureList::IsEnabled(kEnableArcFeature)); | 45 (value == kAvailabilityInstalled && |
| 46 base::FeatureList::IsEnabled(kEnableArcFeature)); | |
| 44 } | 47 } |
| 45 | 48 |
| 46 // For transition, fallback to old flags. | 49 // For transition, fallback to old flags. |
| 47 // TODO(hidehiko): Remove this and clean up whole this function, when | 50 // TODO(hidehiko): Remove this and clean up whole this function, when |
| 48 // session_manager supports a new flag. | 51 // session_manager supports a new flag. |
| 49 return command_line->HasSwitch(chromeos::switches::kEnableArc) || | 52 return command_line->HasSwitch(chromeos::switches::kEnableArc) || |
| 50 (command_line->HasSwitch(chromeos::switches::kArcAvailable) && | 53 (command_line->HasSwitch(chromeos::switches::kArcAvailable) && |
| 51 base::FeatureList::IsEnabled(kEnableArcFeature)); | 54 base::FeatureList::IsEnabled(kEnableArcFeature)); |
| 52 } | 55 } |
| 53 | 56 |
| 54 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { | 57 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { |
| 55 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, | 58 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, |
| 56 kAvailabilityOfficiallySupported); | 59 kAvailabilityOfficiallySupported); |
| 57 } | 60 } |
| 58 | 61 |
| 59 bool IsArcKioskMode() { | 62 bool IsArcKioskMode() { |
| 60 return user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); | 63 return user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); |
| 61 } | 64 } |
| 62 | 65 |
| 66 bool IsArcAllowedForActiveDirectoryUsers() { | |
| 67 const auto* command_line = base::CommandLine::ForCurrentProcess(); | |
| 68 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { | |
|
Luis Héctor Chávez
2017/02/07 16:33:03
nit:
if (!command_line->HasSwitch(...))
return
Marton Hunyady
2017/02/07 17:28:48
Done.
| |
| 69 return command_line->GetSwitchValueASCII( | |
| 70 chromeos::switches::kArcAvailability) == | |
| 71 kAvailabilityOfficiallySupportedWithActiveDirectory; | |
| 72 } | |
| 73 return false; | |
| 74 } | |
| 75 | |
| 63 bool IsArcOptInVerificationDisabled() { | 76 bool IsArcOptInVerificationDisabled() { |
| 64 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 77 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 65 return command_line->HasSwitch( | 78 return command_line->HasSwitch( |
| 66 chromeos::switches::kDisableArcOptInVerification); | 79 chromeos::switches::kDisableArcOptInVerification); |
| 67 } | 80 } |
| 68 | 81 |
| 69 } // namespace arc | 82 } // namespace arc |
| OLD | NEW |