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 "ash/shared/app_types.h" | 9 #include "ash/shared/app_types.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 const base::Feature kEnableArcFeature{"EnableARC", | 24 const base::Feature kEnableArcFeature{"EnableARC", |
| 25 base::FEATURE_DISABLED_BY_DEFAULT}; | 25 base::FEATURE_DISABLED_BY_DEFAULT}; |
| 26 | 26 |
| 27 // Possible values for --arc-availability flag. | 27 // Possible values for --arc-availability flag. |
| 28 constexpr char kAvailabilityNone[] = "none"; | 28 constexpr char kAvailabilityNone[] = "none"; |
| 29 constexpr char kAvailabilityInstalled[] = "installed"; | 29 constexpr char kAvailabilityInstalled[] = "installed"; |
| 30 constexpr char kAvailabilityOfficiallySupported[] = "officially-supported"; | 30 constexpr char kAvailabilityOfficiallySupported[] = "officially-supported"; |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 ARC_AVAILABILITY_POLICY_STATUS arc_availability_policy_status = UNKNOWN; | |
|
hidehiko
2017/05/25 12:41:55
Please move this into anonymous namespace.
sytle:
igorcov
2017/05/31 17:25:35
Done.
| |
| 35 | |
| 34 bool IsArcAvailable() { | 36 bool IsArcAvailable() { |
| 35 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 37 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
|
hidehiko
2017/05/25 12:41:56
Please DCHECK arc_availability_policy_status is no
igorcov
2017/05/31 17:25:35
Can't DCHECK that, because this function is called
hidehiko
2017/06/01 16:07:15
I think this is must-have thing. Otherwise IsArcAv
| |
| 36 | 38 |
| 37 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { | 39 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { |
| 38 std::string value = command_line->GetSwitchValueASCII( | 40 std::string value = command_line->GetSwitchValueASCII( |
| 39 chromeos::switches::kArcAvailability); | 41 chromeos::switches::kArcAvailability); |
| 40 DCHECK(value == kAvailabilityNone || value == kAvailabilityInstalled || | 42 DCHECK(value == kAvailabilityNone || value == kAvailabilityInstalled || |
| 41 value == kAvailabilityOfficiallySupported) | 43 value == kAvailabilityOfficiallySupported || |
| 44 value == kAvailabilityOfficiallySupportedWithMigration) | |
| 42 << "Unknown flag value: " << value; | 45 << "Unknown flag value: " << value; |
| 46 | |
| 47 // In the case of supported with migration, the ARC availability is defined | |
|
hidehiko
2017/05/25 12:41:55
Please add detailed unit tests for new behavior.
igorcov
2017/05/31 17:25:35
Done.
| |
| 48 // by the policy in case the device is managed, or is available if the | |
| 49 // device is consumer owned. | |
| 50 // TODO(igorcov): Remove this after migration. crbug.com/725493 | |
| 51 if (value == kAvailabilityOfficiallySupportedWithMigration) { | |
| 52 if (arc_availability_policy_status == AVAILABLE) | |
|
hidehiko
2017/05/25 12:41:55
nit: return arc_availability_policy_status == AVAI
igorcov
2017/05/31 17:25:35
Done.
| |
| 53 return true; | |
| 54 else | |
| 55 return false; | |
| 56 } | |
| 57 | |
| 43 return value == kAvailabilityOfficiallySupported || | 58 return value == kAvailabilityOfficiallySupported || |
| 44 (value == kAvailabilityInstalled && | 59 (value == kAvailabilityInstalled && |
| 45 base::FeatureList::IsEnabled(kEnableArcFeature)); | 60 base::FeatureList::IsEnabled(kEnableArcFeature)); |
| 46 } | 61 } |
| 47 | 62 |
| 48 // For transition, fallback to old flags. | 63 // For transition, fallback to old flags. |
| 49 // TODO(hidehiko): Remove this and clean up whole this function, when | 64 // TODO(hidehiko): Remove this and clean up whole this function, when |
| 50 // session_manager supports a new flag. | 65 // session_manager supports a new flag. |
| 51 return command_line->HasSwitch(chromeos::switches::kEnableArc) || | 66 return command_line->HasSwitch(chromeos::switches::kEnableArc) || |
| 52 (command_line->HasSwitch(chromeos::switches::kArcAvailable) && | 67 (command_line->HasSwitch(chromeos::switches::kArcAvailable) && |
| 53 base::FeatureList::IsEnabled(kEnableArcFeature)); | 68 base::FeatureList::IsEnabled(kEnableArcFeature)); |
| 54 } | 69 } |
| 55 | 70 |
| 71 void SetArcAvailabilityPolicyStatus(ARC_AVAILABILITY_POLICY_STATUS status) { | |
| 72 arc_availability_policy_status = status; | |
|
hidehiko
2017/05/25 12:41:55
To ensure this is called exact once,
DCHECK_EQ(UNK
| |
| 73 } | |
| 74 | |
| 75 ARC_AVAILABILITY_POLICY_STATUS GetArcAvailabilityPolicyStatus() { | |
| 76 return arc_availability_policy_status; | |
| 77 } | |
| 78 | |
| 56 bool ShouldArcAlwaysStart() { | 79 bool ShouldArcAlwaysStart() { |
| 57 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 80 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 58 chromeos::switches::kArcAlwaysStart); | 81 chromeos::switches::kArcAlwaysStart); |
| 59 } | 82 } |
| 60 | 83 |
| 61 void SetArcAlwaysStartForTesting() { | 84 void SetArcAlwaysStartForTesting() { |
| 62 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 85 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 63 chromeos::switches::kArcAlwaysStart); | 86 chromeos::switches::kArcAlwaysStart); |
| 64 } | 87 } |
| 65 | 88 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 } | 122 } |
| 100 | 123 |
| 101 bool IsArcAppWindow(aura::Window* window) { | 124 bool IsArcAppWindow(aura::Window* window) { |
| 102 if (!window) | 125 if (!window) |
| 103 return false; | 126 return false; |
| 104 return window->GetProperty(aura::client::kAppType) == | 127 return window->GetProperty(aura::client::kAppType) == |
| 105 static_cast<int>(ash::AppType::ARC_APP); | 128 static_cast<int>(ash::AppType::ARC_APP); |
| 106 } | 129 } |
| 107 | 130 |
| 108 } // namespace arc | 131 } // namespace arc |
| OLD | NEW |