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
40
41
42
43
44
ash / webui / os_feedback_ui / resources / mojo_interface_provider.ts [blame]
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {assert} from 'chrome://resources/js/assert.js';
import {FeedbackServiceProvider, FeedbackServiceProviderInterface, HelpContentProvider, HelpContentProviderInterface} from './os_feedback_ui.mojom-webui.js';
/**
* @fileoverview
* Provides singleton access to mojo interfaces with the ability
* to override them with test/fake implementations.
*/
let feedbackServiceProvider: FeedbackServiceProviderInterface|null = null;
let helpContentProvider: HelpContentProviderInterface|null = null;
export function setFeedbackServiceProviderForTesting(
testProvider: FeedbackServiceProviderInterface|null) {
feedbackServiceProvider = testProvider;
}
export function setHelpContentProviderForTesting(
testProvider: HelpContentProviderInterface|null) {
helpContentProvider = testProvider;
}
export function getFeedbackServiceProvider(): FeedbackServiceProviderInterface {
if (!feedbackServiceProvider) {
feedbackServiceProvider = FeedbackServiceProvider.getRemote();
}
assert(feedbackServiceProvider);
return feedbackServiceProvider;
}
export function getHelpContentProvider(): HelpContentProviderInterface {
if (!helpContentProvider) {
helpContentProvider = HelpContentProvider.getRemote();
}
assert(helpContentProvider);
return helpContentProvider;
}