1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39

ash / webui / scanning / resources / mojo_interface_provider.ts [blame]

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {AccessibilityFeatures, AccessibilityFeaturesInterface} from './accessibility_features.mojom-webui.js';
import {ScanService, ScanServiceInterface} from './scanning.mojom-webui.js';

let scanService: ScanServiceInterface|null = null;

let accessibilityFeatures: AccessibilityFeaturesInterface|null = null;

export function setScanServiceForTesting(
    testScanService: ScanServiceInterface) {
  scanService = testScanService;
}

export function getScanService(): ScanServiceInterface {
  if (scanService) {
    return scanService;
  }

  scanService = ScanService.getRemote();
  return scanService;
}

export function setAccessibilityFeaturesForTesting(
    testAccessibilityInterface: AccessibilityFeaturesInterface) {
  accessibilityFeatures = testAccessibilityInterface;
}

export function getAccessibilityFeaturesInterface():
    AccessibilityFeaturesInterface {
  if (accessibilityFeatures) {
    return accessibilityFeatures;
  }

  accessibilityFeatures = AccessibilityFeatures.getRemote();
  return accessibilityFeatures;
}