blob: 661ba8234994b11dbd46f11fe5ebd59f6432f0ff (
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
|
// Copyright 2018 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/explore_sites_internals/explore_sites_internals_ui.h"
#include "base/bind.h"
#include "build/build_config.h"
#include "chrome/browser/android/chrome_feature_list.h"
#include "chrome/browser/android/explore_sites/explore_sites_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/explore_sites_internals/explore_sites_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 explore_sites {
ExploreSitesInternalsUI::ExploreSitesInternalsUI(content::WebUI* web_ui)
: ui::MojoWebUIController(web_ui) {
content::WebUIDataSource* source = content::WebUIDataSource::Create(
chrome::kChromeUIExploreSitesInternalsHost);
source->AddResourcePath("explore_sites_internals.css",
IDR_EXPLORE_SITES_INTERNALS_CSS);
source->AddResourcePath("explore_sites_internals.js",
IDR_EXPLORE_SITES_INTERNALS_JS);
source->AddResourcePath("explore_sites_internals.mojom-lite.js",
IDR_EXPLORE_SITES_INTERNALS_MOJO_JS);
source->SetDefaultResource(IDR_EXPLORE_SITES_INTERNALS_HTML);
Profile* profile = Profile::FromWebUI(web_ui);
explore_sites_service_ =
ExploreSitesServiceFactory::GetForBrowserContext(profile);
content::WebUIDataSource::Add(profile, source);
// "BindExploreSitesInternalsPageHandler" will be invoked by
// explore_sites_internals.js, which is only possible while this object is
// alive, so this base::Unretained is safe.
AddHandlerToRegistry(base::BindRepeating(
&ExploreSitesInternalsUI::BindExploreSitesInternalsPageHandler,
base::Unretained(this)));
}
ExploreSitesInternalsUI::~ExploreSitesInternalsUI() {}
void ExploreSitesInternalsUI::BindExploreSitesInternalsPageHandler(
explore_sites_internals::mojom::PageHandlerRequest request) {
page_handler_ = std::make_unique<ExploreSitesInternalsPageHandler>(
std::move(request), explore_sites_service_, Profile::FromWebUI(web_ui()));
}
} // namespace explore_sites
|