workflow.dart 1.06 KB
Newer Older
1 2 3 4 5 6 7 8
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../base/context.dart';
import '../base/platform.dart';
import '../base/process_manager.dart';
import '../doctor.dart';
9
import '../features.dart';
10 11 12 13 14 15 16 17 18
import 'chrome.dart';

/// The  web workflow instance.
WebWorkflow get webWorkflow => context.get<WebWorkflow>();

class WebWorkflow extends Workflow {
  const WebWorkflow();

  @override
19
  bool get appliesToHostPlatform => featureFlags.isWebEnabled && (platform.isWindows || platform.isMacOS || platform.isLinux);
20 21

  @override
22
  bool get canLaunchDevices => featureFlags.isWebEnabled && canFindChrome();
23 24

  @override
25
  bool get canListDevices => featureFlags.isWebEnabled && canFindChrome();
26 27 28 29 30 31 32 33

  @override
  bool get canListEmulators => false;
}

/// Whether we can locate the chrome executable.
bool canFindChrome() {
  final String chrome = findChromeExecutable();
34
  try {
35
    return processManager.canRun(chrome);
36 37
  } on ArgumentError {
    return false;
38 39
  }
}