Commit 5b7cdc87 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Switch to the unique_ptr version of content::URLDataSource::Add().

Change a bunch of WebUIs to use the non-deprecated version.

Change-Id: I1d918500b59ea92f642fda08bdfb020a56acaf26
Reviewed-on: https://chromium-review.googlesource.com/1194979Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587198}
parent 1bc75d7b
...@@ -39,17 +39,17 @@ void RegisterViewerSource(Profile* profile) { ...@@ -39,17 +39,17 @@ void RegisterViewerSource(Profile* profile) {
std::unique_ptr<DistillerUIHandle> ui_handle; std::unique_ptr<DistillerUIHandle> ui_handle;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
ui_handle.reset(new dom_distiller::android::DistillerUIHandleAndroid()); ui_handle =
std::make_unique<dom_distiller::android::DistillerUIHandleAndroid>();
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
// Set the JavaScript world ID. // Set the JavaScript world ID.
if (!DistillerJavaScriptWorldIdIsSet()) { if (!DistillerJavaScriptWorldIdIsSet())
SetDistillerJavaScriptWorldId(ISOLATED_WORLD_ID_CHROME_INTERNAL); SetDistillerJavaScriptWorldId(ISOLATED_WORLD_ID_CHROME_INTERNAL);
}
content::URLDataSource::Add( content::URLDataSource::Add(
profile, new DomDistillerViewerSource(lazy_service, kDomDistillerScheme, profile, std::make_unique<DomDistillerViewerSource>(
std::move(ui_handle))); lazy_service, kDomDistillerScheme, std::move(ui_handle)));
} }
} // namespace dom_distiller } // namespace dom_distiller
...@@ -743,7 +743,8 @@ void ProfileImpl::DoFinalInit() { ...@@ -743,7 +743,8 @@ void ProfileImpl::DoFinalInit() {
signin_ui_util::InitializePrefsForProfile(this); signin_ui_util::InitializePrefsForProfile(this);
#endif #endif
content::URLDataSource::Add(this, new PrefsInternalsSource(this)); content::URLDataSource::Add(this,
std::make_unique<PrefsInternalsSource>(this));
ScheduleUpdateCTPolicy(); ScheduleUpdateCTPolicy();
} }
......
...@@ -55,9 +55,9 @@ AppLauncherPageUI::AppLauncherPageUI(content::WebUI* web_ui) ...@@ -55,9 +55,9 @@ AppLauncherPageUI::AppLauncherPageUI(content::WebUI* web_ui)
// earlier. // earlier.
web_ui->AddMessageHandler(std::make_unique<ThemeHandler>()); web_ui->AddMessageHandler(std::make_unique<ThemeHandler>());
std::unique_ptr<HTMLSource> html_source( content::URLDataSource::Add(
new HTMLSource(GetProfile()->GetOriginalProfile())); GetProfile(),
content::URLDataSource::Add(GetProfile(), html_source.release()); std::make_unique<HTMLSource>(GetProfile()->GetOriginalProfile()));
} }
AppLauncherPageUI::~AppLauncherPageUI() { AppLauncherPageUI::~AppLauncherPageUI() {
......
...@@ -245,7 +245,8 @@ void BrowsingHistoryHandler::RegisterMessages() { ...@@ -245,7 +245,8 @@ void BrowsingHistoryHandler::RegisterMessages() {
this, local_history, sync_service); this, local_history, sync_service);
// Create our favicon data source. // Create our favicon data source.
content::URLDataSource::Add(profile, new FaviconSource(profile)); content::URLDataSource::Add(profile,
std::make_unique<FaviconSource>(profile));
web_ui()->RegisterMessageCallback( web_ui()->RegisterMessageCallback(
"queryHistory", "queryHistory",
......
...@@ -408,7 +408,8 @@ CaptivePortalBlockingPage* CreateCaptivePortalBlockingPage( ...@@ -408,7 +408,8 @@ CaptivePortalBlockingPage* CreateCaptivePortalBlockingPage(
InterstitialUI::InterstitialUI(content::WebUI* web_ui) InterstitialUI::InterstitialUI(content::WebUI* web_ui)
: WebUIController(web_ui) { : WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui); Profile* profile = Profile::FromWebUI(web_ui);
content::URLDataSource::Add(profile, new InterstitialHTMLSource()); content::URLDataSource::Add(profile,
std::make_unique<InterstitialHTMLSource>());
} }
InterstitialUI::~InterstitialUI() { InterstitialUI::~InterstitialUI() {
......
...@@ -157,8 +157,7 @@ MdDownloadsUI::MdDownloadsUI(content::WebUI* web_ui) : WebUIController(web_ui) { ...@@ -157,8 +157,7 @@ MdDownloadsUI::MdDownloadsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
// Set up the chrome://downloads/ source. // Set up the chrome://downloads/ source.
content::WebUIDataSource* source = CreateDownloadsUIHTMLSource(profile); content::WebUIDataSource* source = CreateDownloadsUIHTMLSource(profile);
content::WebUIDataSource::Add(profile, source); content::WebUIDataSource::Add(profile, source);
ThemeSource* theme = new ThemeSource(profile); content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
content::URLDataSource::Add(profile, theme);
} }
// static // static
......
...@@ -58,8 +58,8 @@ NewTabUI::NewTabUI(content::WebUI* web_ui) : content::WebUIController(web_ui) { ...@@ -58,8 +58,8 @@ NewTabUI::NewTabUI(content::WebUI* web_ui) : content::WebUIController(web_ui) {
web_ui->AddMessageHandler(std::make_unique<ThemeHandler>()); web_ui->AddMessageHandler(std::make_unique<ThemeHandler>());
// content::URLDataSource assumes the ownership of the html source. // content::URLDataSource assumes the ownership of the html source.
content::URLDataSource::Add( content::URLDataSource::Add(profile, std::make_unique<NewTabHTMLSource>(
profile, new NewTabHTMLSource(profile->GetOriginalProfile())); profile->GetOriginalProfile()));
pref_change_registrar_.Init(profile->GetPrefs()); pref_change_registrar_.Init(profile->GetPrefs());
pref_change_registrar_.Add(bookmarks::prefs::kShowBookmarkBar, pref_change_registrar_.Add(bookmarks::prefs::kShowBookmarkBar,
......
...@@ -597,7 +597,7 @@ PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) ...@@ -597,7 +597,7 @@ PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui)
} }
// Set up the chrome://theme/ source. // Set up the chrome://theme/ source.
content::URLDataSource::Add(profile, new ThemeSource(profile)); content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
g_print_preview_request_id_map.Get().Set(id_, -1); g_print_preview_request_id_map.Get().Set(id_, -1);
} }
......
...@@ -45,8 +45,7 @@ MDUserManagerUI::MDUserManagerUI(content::WebUI* web_ui) ...@@ -45,8 +45,7 @@ MDUserManagerUI::MDUserManagerUI(content::WebUI* web_ui)
content::WebUIDataSource::Add(profile, CreateUIDataSource(localized_strings)); content::WebUIDataSource::Add(profile, CreateUIDataSource(localized_strings));
// Set up the chrome://theme/ source // Set up the chrome://theme/ source
ThemeSource* theme = new ThemeSource(profile); content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
content::URLDataSource::Add(profile, theme);
} }
MDUserManagerUI::~MDUserManagerUI() {} MDUserManagerUI::~MDUserManagerUI() {}
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/browser/ui/webui/theme_handler.h" #include "chrome/browser/ui/webui/theme_handler.h"
#include <memory>
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -49,8 +51,7 @@ void ThemeHandler::Observe(int type, ...@@ -49,8 +51,7 @@ void ThemeHandler::Observe(int type,
void ThemeHandler::InitializeCSSCaches() { void ThemeHandler::InitializeCSSCaches() {
Profile* profile = GetProfile(); Profile* profile = GetProfile();
ThemeSource* theme = new ThemeSource(profile); content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
content::URLDataSource::Add(profile, theme);
} }
Profile* ThemeHandler::GetProfile() const { Profile* ThemeHandler::GetProfile() const {
......
...@@ -171,8 +171,7 @@ VersionUI::VersionUI(content::WebUI* web_ui) ...@@ -171,8 +171,7 @@ VersionUI::VersionUI(content::WebUI* web_ui)
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
// Set up the chrome://theme/ source. // Set up the chrome://theme/ source.
ThemeSource* theme = new ThemeSource(profile); content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
content::URLDataSource::Add(profile, theme);
#endif #endif
WebUIDataSource::Add(profile, CreateVersionUIDataSource()); WebUIDataSource::Add(profile, CreateVersionUIDataSource());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment