forked from chromium/chromium
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebUI: Migrate HistoryClustersInternalsUI to WebUIConfig.
Bug: 40222519 Change-Id: I891b72a6acc9195f0ac7723526e822561b507f01 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5972761 Reviewed-by: Rebekah Potter <rbpotter@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Commit-Queue: Teresa Mao <temao@chromium.org> Cr-Commit-Position: refs/heads/main@{#1376677}
- Loading branch information
Showing
6 changed files
with
83 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
chrome/browser/ui/webui/history_clusters/history_clusters_internals_ui_config.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2024 The Chromium Authors | ||
// 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/history_clusters/history_clusters_internals_ui_config.h" | ||
|
||
#include "chrome/browser/history/history_service_factory.h" | ||
#include "chrome/browser/history_clusters/history_clusters_service_factory.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/ui/webui/webui_util.h" | ||
#include "components/history_clusters/history_clusters_internals/webui/history_clusters_internals_ui.h" | ||
#include "components/history_clusters/history_clusters_internals/webui/url_constants.h" | ||
#include "content/public/browser/web_contents.h" | ||
#include "content/public/browser/web_ui_data_source.h" | ||
|
||
namespace history_clusters_internals { | ||
|
||
// TODO(crbug.com/40222519): Move SetupWebUIDataSource() to a location | ||
// accessible from components/, such as in //ui/base/webui, so that the only | ||
// 'wrapping' in this Config class is HistoryClustersServiceFactory. | ||
void SetUpWebUIDataSource(content::WebUI* web_ui, | ||
const char* web_ui_host, | ||
base::span<const webui::ResourcePath> resources, | ||
int default_resource) { | ||
content::WebUIDataSource* source = content::WebUIDataSource::CreateAndAdd( | ||
web_ui->GetWebContents()->GetBrowserContext(), web_ui_host); | ||
webui::SetupWebUIDataSource(source, resources, default_resource); | ||
} | ||
|
||
HistoryClustersInternalsUIConfig::HistoryClustersInternalsUIConfig() | ||
: WebUIConfig( | ||
content::kChromeUIScheme, | ||
history_clusters_internals::kChromeUIHistoryClustersInternalsHost) {} | ||
|
||
HistoryClustersInternalsUIConfig::~HistoryClustersInternalsUIConfig() = default; | ||
|
||
std::unique_ptr<content::WebUIController> | ||
HistoryClustersInternalsUIConfig::CreateWebUIController(content::WebUI* web_ui, | ||
const GURL& url) { | ||
Profile* profile = Profile::FromWebUI(web_ui); | ||
return std::make_unique<HistoryClustersInternalsUI>( | ||
web_ui, HistoryClustersServiceFactory::GetForBrowserContext(profile), | ||
HistoryServiceFactory::GetForProfile(profile, | ||
ServiceAccessType::EXPLICIT_ACCESS), | ||
base::BindOnce( | ||
&SetUpWebUIDataSource, web_ui, | ||
history_clusters_internals::kChromeUIHistoryClustersInternalsHost)); | ||
} | ||
|
||
} // namespace history_clusters_internals |
26 changes: 26 additions & 0 deletions
26
chrome/browser/ui/webui/history_clusters/history_clusters_internals_ui_config.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2024 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_UI_WEBUI_HISTORY_CLUSTERS_HISTORY_CLUSTERS_INTERNALS_UI_CONFIG_H_ | ||
#define CHROME_BROWSER_UI_WEBUI_HISTORY_CLUSTERS_HISTORY_CLUSTERS_INTERNALS_UI_CONFIG_H_ | ||
|
||
#include "content/public/browser/webui_config.h" | ||
#include "content/public/common/url_constants.h" | ||
|
||
namespace history_clusters_internals { | ||
|
||
class HistoryClustersInternalsUIConfig : public content::WebUIConfig { | ||
public: | ||
HistoryClustersInternalsUIConfig(); | ||
~HistoryClustersInternalsUIConfig() override; | ||
|
||
// content::WebUIConfig: | ||
std::unique_ptr<content::WebUIController> CreateWebUIController( | ||
content::WebUI* web_ui, | ||
const GURL& url) override; | ||
}; | ||
|
||
} // namespace history_clusters_internals | ||
|
||
#endif // CHROME_BROWSER_UI_WEBUI_HISTORY_CLUSTERS_HISTORY_CLUSTERS_INTERNALS_UI_CONFIG_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters