summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_ui.cc
blob: 18ff22fb3239c2b8a9581eeb90380a8cd26c31ad (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 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.

#include "chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_ui.h"

#include <memory>
#include <utility>

#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_page_handler.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "content/public/browser/web_ui_data_source.h"

namespace chromeos {
namespace machine_learning {

MachineLearningInternalsUI::MachineLearningInternalsUI(
    content::WebUI* const web_ui)
    : ui::MojoWebUIController(web_ui) {
  content::WebUIDataSource* const source = content::WebUIDataSource::Create(
      chrome::kChromeUIMachineLearningInternalsHost);

  source->AddResourcePath(
      "chromeos/services/machine_learning/public/mojom/tensor.mojom-lite.js",
      IDR_MACHINE_LEARNING_INTERNALS_TENSOR_MOJO_JS);
  source->AddResourcePath(
      "chromeos/services/machine_learning/public/mojom/model.mojom-lite.js",
      IDR_MACHINE_LEARNING_INTERNALS_MODEL_MOJO_JS);
  source->AddResourcePath(
      "chromeos/services/machine_learning/public/mojom/"
      "graph_executor.mojom-lite.js",
      IDR_MACHINE_LEARNING_INTERNALS_GRAPH_EXECUTOR_MOJO_JS);
  source->AddResourcePath(
      "chromeos/services/machine_learning/public/"
      "mojom/machine_learning_service.mojom-lite.js",
      IDR_MACHINE_LEARNING_INTERNALS_MACHINE_LEARNING_SERVICE_MOJO_JS);
  source->AddResourcePath(
      "chrome/browser/ui/webui/chromeos/machine_learning/"
      "machine_learning_internals_page_handler.mojom-lite.js",
      IDR_MACHINE_LEARNING_INTERNALS_PAGE_HANDLER_MOJO_JS);
  source->AddResourcePath("machine_learning_internals.js",
                          IDR_MACHINE_LEARNING_INTERNALS_JS);
  source->AddResourcePath("machine_learning_internals_utils.js",
                          IDR_MACHINE_LEARNING_INTERNALS_UTILS_JS);
  source->AddResourcePath("test_model_tab.js",
                          IDR_MACHINE_LEARNING_INTERNALS_TEST_MODEL_TAB_JS);
  source->SetDefaultResource(IDR_MACHINE_LEARNING_INTERNALS_HTML);

  content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
  AddHandlerToRegistry(base::BindRepeating(
      &MachineLearningInternalsUI::BindMachineLearningInternalsPageHandler,
      base::Unretained(this)));
}

MachineLearningInternalsUI::~MachineLearningInternalsUI() = default;

void MachineLearningInternalsUI::BindMachineLearningInternalsPageHandler(
    mojo::PendingReceiver<mojom::PageHandler> receiver) {
  page_handler_ = std::make_unique<MachineLearningInternalsPageHandler>(
      std::move(receiver));
}

}  // namespace machine_learning
}  // namespace chromeos