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 kAvailabilityInstalledOnlyKioskSupported[] = | |
| 28 "installed-only-kiosk-supported"; | |
| 29 constexpr char kAvailabilityOfficiallySupported[] = "officially-supported"; | 27 constexpr char kAvailabilityOfficiallySupported[] = "officially-supported"; |
| 30 constexpr char kAvailabilityOfficiallySupportedWithActiveDirectory[] = | 28 constexpr char kAvailabilityOfficiallySupportedWithActiveDirectory[] = |
| 31 "officially-supported-with-active-directory"; | 29 "officially-supported-with-active-directory"; |
| 32 | 30 |
| 33 } // namespace | 31 } // namespace |
| 34 | 32 |
| 35 bool IsArcAvailable() { | 33 bool IsArcAvailable() { |
| 36 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 34 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 37 | 35 |
| 38 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { | 36 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { |
| 39 std::string value = command_line->GetSwitchValueASCII( | 37 std::string value = command_line->GetSwitchValueASCII( |
| 40 chromeos::switches::kArcAvailability); | 38 chromeos::switches::kArcAvailability); |
| 41 DCHECK(value == kAvailabilityNone || | 39 DCHECK(value == kAvailabilityNone || |
| 42 value == kAvailabilityInstalled || | 40 value == kAvailabilityInstalled || |
| 43 value == kAvailabilityInstalledOnlyKioskSupported || | |
| 44 value == kAvailabilityOfficiallySupported || | 41 value == kAvailabilityOfficiallySupported || |
| 45 value == kAvailabilityOfficiallySupportedWithActiveDirectory) | 42 value == kAvailabilityOfficiallySupportedWithActiveDirectory) |
| 46 << "Unknown flag value: " << value; | 43 << "Unknown flag value: " << value; |
| 47 return value == kAvailabilityOfficiallySupported || | 44 return value == kAvailabilityOfficiallySupported || |
| 48 value == kAvailabilityOfficiallySupportedWithActiveDirectory || | 45 value == kAvailabilityOfficiallySupportedWithActiveDirectory || |
| 49 ((value == kAvailabilityInstalled || | 46 (value == kAvailabilityInstalled && |
| 50 value == kAvailabilityInstalledOnlyKioskSupported) && | |
| 51 base::FeatureList::IsEnabled(kEnableArcFeature)); | 47 base::FeatureList::IsEnabled(kEnableArcFeature)); |
| 52 } | 48 } |
| 53 | 49 |
| 54 // For transition, fallback to old flags. | 50 // For transition, fallback to old flags. |
| 55 // TODO(hidehiko): Remove this and clean up whole this function, when | 51 // TODO(hidehiko): Remove this and clean up whole this function, when |
| 56 // session_manager supports a new flag. | 52 // session_manager supports a new flag. |
| 57 return command_line->HasSwitch(chromeos::switches::kEnableArc) || | 53 return command_line->HasSwitch(chromeos::switches::kEnableArc) || |
| 58 (command_line->HasSwitch(chromeos::switches::kArcAvailable) && | 54 (command_line->HasSwitch(chromeos::switches::kArcAvailable) && |
| 59 base::FeatureList::IsEnabled(kEnableArcFeature)); | 55 base::FeatureList::IsEnabled(kEnableArcFeature)); |
| 60 } | 56 } |
| 61 | 57 |
| 62 bool IsArcKioskAvailable() { | 58 bool IsArcKioskAvailable() { |
| 63 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 59 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 64 | 60 |
| 65 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { | 61 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { |
| 66 std::string value = | 62 std::string value = |
| 67 command_line->GetSwitchValueASCII(chromeos::switches::kArcAvailability); | 63 command_line->GetSwitchValueASCII(chromeos::switches::kArcAvailability); |
| 68 if (value == kAvailabilityInstalledOnlyKioskSupported) | 64 if (value == kAvailabilityInstalled) |
| 69 return true; | 65 return true; |
|
hidehiko
2017/03/02 06:38:49
Could you add "return IsArcAvailable();" here, too
elijahtaylor1
2017/03/02 19:13:35
I will do this, but IMO this adds a cleanup task.
| |
| 70 } | 66 } |
| 71 | 67 |
| 68 // TODO(hidehiko): Remove this when session_manager supports the new flag. | |
| 69 if (command_line->HasSwitch(chromeos::switches::kArcAvailable)) { | |
|
hidehiko
2017/03/02 06:38:49
nit: could you elide brace for consistency?
elijahtaylor1
2017/03/02 19:13:35
Done.
| |
| 70 return true; | |
| 71 } | |
| 72 | |
| 72 // If not special kiosk device case, use general ARC check. | 73 // If not special kiosk device case, use general ARC check. |
| 73 return IsArcAvailable(); | 74 return IsArcAvailable(); |
| 74 } | 75 } |
| 75 | 76 |
| 76 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { | 77 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { |
| 77 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, | 78 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, |
| 78 kAvailabilityOfficiallySupported); | 79 kAvailabilityOfficiallySupported); |
| 79 } | 80 } |
| 80 | 81 |
| 81 bool IsArcKioskMode() { | 82 bool IsArcKioskMode() { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 94 kAvailabilityOfficiallySupportedWithActiveDirectory; | 95 kAvailabilityOfficiallySupportedWithActiveDirectory; |
| 95 } | 96 } |
| 96 | 97 |
| 97 bool IsArcOptInVerificationDisabled() { | 98 bool IsArcOptInVerificationDisabled() { |
| 98 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 99 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 99 return command_line->HasSwitch( | 100 return command_line->HasSwitch( |
| 100 chromeos::switches::kDisableArcOptInVerification); | 101 chromeos::switches::kDisableArcOptInVerification); |
| 101 } | 102 } |
| 102 | 103 |
| 103 } // namespace arc | 104 } // namespace arc |
| OLD | NEW |