chore: use std::make_unique/base::MakeRefCounted when possible (#29510)
This commit is contained in:
parent
a4decffe9a
commit
79cb5144ae
38 changed files with 106 additions and 101 deletions
|
@ -878,7 +878,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessOrCreate() {
|
|||
}
|
||||
|
||||
void ProcessSingleton::StartListeningOnSocket() {
|
||||
watcher_ = new LinuxWatcher(this);
|
||||
watcher_ = base::MakeRefCounted<LinuxWatcher>(this);
|
||||
base::PostTask(FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&ProcessSingleton::LinuxWatcher::StartListening,
|
||||
watcher_, sock_));
|
||||
|
|
|
@ -252,7 +252,7 @@ int main(int argc, char* argv[]) {
|
|||
abort();
|
||||
}
|
||||
|
||||
std::unique_ptr<char[]> exec_path(new char[exec_path_size]);
|
||||
auto exec_path = std::make_unique<char[]>(exec_path_size);
|
||||
rv = _NSGetExecutablePath(exec_path.get(), &exec_path_size);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "_NSGetExecutablePath: get path failed\n");
|
||||
|
|
|
@ -158,7 +158,7 @@ int NodeMain(int argc, char* argv[]) {
|
|||
// Feed gin::PerIsolateData with a task runner.
|
||||
argv = uv_setup_args(argc, argv);
|
||||
uv_loop_t* loop = uv_default_loop();
|
||||
scoped_refptr<UvTaskRunner> uv_task_runner(new UvTaskRunner(loop));
|
||||
auto uv_task_runner = base::MakeRefCounted<UvTaskRunner>(loop);
|
||||
base::ThreadTaskRunnerHandle handle(uv_task_runner);
|
||||
|
||||
// Initialize feature list.
|
||||
|
|
|
@ -197,13 +197,13 @@ void GetUploadedReports(
|
|||
#else
|
||||
scoped_refptr<UploadList> CreateCrashUploadList() {
|
||||
#if defined(OS_MAC) || defined(OS_WIN)
|
||||
return new CrashUploadListCrashpad();
|
||||
return base::MakeRefCounted<CrashUploadListCrashpad>();
|
||||
#else
|
||||
base::FilePath crash_dir_path;
|
||||
base::PathService::Get(electron::DIR_CRASH_DUMPS, &crash_dir_path);
|
||||
base::FilePath upload_log_path =
|
||||
crash_dir_path.AppendASCII(CrashUploadList::kReporterLogFilename);
|
||||
return new TextLogUploadList(upload_log_path);
|
||||
return base::MakeRefCounted<TextLogUploadList>(upload_log_path);
|
||||
#endif // defined(OS_MAC) || defined(OS_WIN)
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ namespace api {
|
|||
|
||||
gin::WrapperInfo Menu::kWrapperInfo = {gin::kEmbedderNativeGin};
|
||||
|
||||
Menu::Menu(gin::Arguments* args) : model_(new ElectronMenuModel(this)) {
|
||||
Menu::Menu(gin::Arguments* args)
|
||||
: model_(std::make_unique<ElectronMenuModel>(this)) {
|
||||
model_->AddObserver(this);
|
||||
|
||||
#if defined(OS_MAC)
|
||||
|
|
|
@ -192,7 +192,8 @@ void SystemPreferences::InitializeWindow() {
|
|||
// Creating this listener before the app is ready causes global shortcuts
|
||||
// to not fire
|
||||
if (Browser::Get()->is_ready())
|
||||
color_change_listener_.reset(new gfx::ScopedSysColorChangeListener(this));
|
||||
color_change_listener_ =
|
||||
std::make_unique<gfx::ScopedSysColorChangeListener>(this);
|
||||
else
|
||||
Browser::Get()->AddObserver(this);
|
||||
|
||||
|
@ -259,7 +260,8 @@ void SystemPreferences::OnSysColorChange() {
|
|||
|
||||
void SystemPreferences::OnFinishLaunching(
|
||||
const base::DictionaryValue& launch_info) {
|
||||
color_change_listener_.reset(new gfx::ScopedSysColorChangeListener(this));
|
||||
color_change_listener_ =
|
||||
std::make_unique<gfx::ScopedSysColorChangeListener>(this);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
|
|
@ -537,8 +537,7 @@ FileSystem CreateFileSystemStruct(content::WebContents* web_contents,
|
|||
|
||||
std::unique_ptr<base::DictionaryValue> CreateFileSystemValue(
|
||||
const FileSystem& file_system) {
|
||||
std::unique_ptr<base::DictionaryValue> file_system_value(
|
||||
new base::DictionaryValue());
|
||||
auto file_system_value = std::make_unique<base::DictionaryValue>();
|
||||
file_system_value->SetString("type", file_system.type);
|
||||
file_system_value->SetString("fileSystemName", file_system.file_system_name);
|
||||
file_system_value->SetString("rootURL", file_system.root_url);
|
||||
|
@ -618,7 +617,8 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
: content::WebContentsObserver(web_contents),
|
||||
type_(Type::kRemote),
|
||||
id_(GetAllWebContents().Add(this)),
|
||||
devtools_file_system_indexer_(new DevToolsFileSystemIndexer),
|
||||
devtools_file_system_indexer_(
|
||||
base::MakeRefCounted<DevToolsFileSystemIndexer>()),
|
||||
file_task_runner_(
|
||||
base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()}))
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
|
@ -635,7 +635,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
|
||||
extensions::ElectronExtensionWebContentsObserver::CreateForWebContents(
|
||||
web_contents);
|
||||
script_executor_.reset(new extensions::ScriptExecutor(web_contents));
|
||||
script_executor_ = std::make_unique<extensions::ScriptExecutor>(web_contents);
|
||||
#endif
|
||||
|
||||
auto session = Session::CreateFrom(isolate, GetBrowserContext());
|
||||
|
@ -674,7 +674,8 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
WebContents::WebContents(v8::Isolate* isolate,
|
||||
const gin_helper::Dictionary& options)
|
||||
: id_(GetAllWebContents().Add(this)),
|
||||
devtools_file_system_indexer_(new DevToolsFileSystemIndexer),
|
||||
devtools_file_system_indexer_(
|
||||
base::MakeRefCounted<DevToolsFileSystemIndexer>()),
|
||||
file_task_runner_(
|
||||
base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()}))
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
|
@ -838,7 +839,8 @@ void WebContents::InitWithSessionAndOptions(
|
|||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
extensions::ElectronExtensionWebContentsObserver::CreateForWebContents(
|
||||
web_contents());
|
||||
script_executor_.reset(new extensions::ScriptExecutor(web_contents()));
|
||||
script_executor_ =
|
||||
std::make_unique<extensions::ScriptExecutor>(web_contents());
|
||||
#endif
|
||||
|
||||
AutofillDriverFactory::CreateForWebContents(web_contents());
|
||||
|
@ -904,8 +906,8 @@ void WebContents::InitWithWebContents(content::WebContents* web_contents,
|
|||
web_preferences && web_preferences->IsEnabled(options::kOffscreen);
|
||||
|
||||
// Create InspectableWebContents.
|
||||
inspectable_web_contents_.reset(new InspectableWebContents(
|
||||
web_contents, browser_context->prefs(), is_guest));
|
||||
inspectable_web_contents_ = std::make_unique<InspectableWebContents>(
|
||||
web_contents, browser_context->prefs(), is_guest);
|
||||
inspectable_web_contents_->SetDelegate(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,8 +112,9 @@ void BrowserProcessImpl::PostEarlyInitialization() {
|
|||
user_pref_store->ReadPrefs();
|
||||
prefs_factory.set_user_prefs(user_pref_store);
|
||||
} else {
|
||||
prefs_factory.set_user_prefs(
|
||||
new OverlayUserPrefStore(new InMemoryPrefStore));
|
||||
auto user_pref_store =
|
||||
base::MakeRefCounted<OverlayUserPrefStore>(new InMemoryPrefStore);
|
||||
prefs_factory.set_user_prefs(user_pref_store);
|
||||
}
|
||||
local_state_ = prefs_factory.Create(std::move(pref_registry));
|
||||
}
|
||||
|
|
|
@ -611,7 +611,7 @@ std::string ElectronBrowserClient::GetGeolocationApiKey() {
|
|||
|
||||
scoped_refptr<content::QuotaPermissionContext>
|
||||
ElectronBrowserClient::CreateQuotaPermissionContext() {
|
||||
return new ElectronQuotaPermissionContext;
|
||||
return base::MakeRefCounted<ElectronQuotaPermissionContext>();
|
||||
}
|
||||
|
||||
content::GeneratedCodeCacheSettings
|
||||
|
|
|
@ -103,7 +103,7 @@ ElectronBrowserContext::browser_context_map() {
|
|||
ElectronBrowserContext::ElectronBrowserContext(const std::string& partition,
|
||||
bool in_memory,
|
||||
base::DictionaryValue options)
|
||||
: storage_policy_(new SpecialStoragePolicy),
|
||||
: storage_policy_(base::MakeRefCounted<SpecialStoragePolicy>()),
|
||||
protocol_registry_(new ProtocolRegistry),
|
||||
in_memory_(in_memory),
|
||||
ssl_config_(network::mojom::SSLConfig::New()) {
|
||||
|
@ -184,9 +184,9 @@ void ElectronBrowserContext::InitPrefs() {
|
|||
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) || \
|
||||
BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
auto registry = WrapRefCounted(new user_prefs::PrefRegistrySyncable);
|
||||
auto registry = base::MakeRefCounted<user_prefs::PrefRegistrySyncable>();
|
||||
#else
|
||||
auto registry = WrapRefCounted(new PrefRegistrySimple);
|
||||
auto registry = base::MakeRefCounted<PrefRegistrySimple>();
|
||||
#endif
|
||||
|
||||
registry->RegisterFilePathPref(prefs::kSelectFileLastDirectory,
|
||||
|
|
|
@ -199,11 +199,12 @@ ElectronBrowserMainParts* ElectronBrowserMainParts::self_ = nullptr;
|
|||
|
||||
ElectronBrowserMainParts::ElectronBrowserMainParts(
|
||||
const content::MainFunctionParams& params)
|
||||
: fake_browser_process_(new BrowserProcessImpl),
|
||||
browser_(new Browser),
|
||||
: fake_browser_process_(std::make_unique<BrowserProcessImpl>()),
|
||||
browser_(std::make_unique<Browser>()),
|
||||
node_bindings_(
|
||||
NodeBindings::Create(NodeBindings::BrowserEnvironment::kBrowser)),
|
||||
electron_bindings_(new ElectronBindings(node_bindings_->uv_loop())) {
|
||||
electron_bindings_(
|
||||
std::make_unique<ElectronBindings>(node_bindings_->uv_loop())) {
|
||||
DCHECK(!self_) << "Cannot have two ElectronBrowserMainParts";
|
||||
self_ = this;
|
||||
}
|
||||
|
@ -386,7 +387,7 @@ void ElectronBrowserMainParts::ToolkitInitialized() {
|
|||
UpdateDarkThemeSetting();
|
||||
// Update the native theme when GTK theme changes. The GetNativeTheme
|
||||
// here returns a NativeThemeGtk, which monitors GTK settings.
|
||||
dark_theme_observer_.reset(new DarkThemeObserver);
|
||||
dark_theme_observer_ = std::make_unique<DarkThemeObserver>();
|
||||
linux_ui->GetNativeTheme(nullptr)->AddObserver(dark_theme_observer_.get());
|
||||
views::LinuxUI::SetInstance(std::move(linux_ui));
|
||||
#endif
|
||||
|
@ -401,7 +402,7 @@ void ElectronBrowserMainParts::ToolkitInitialized() {
|
|||
#endif
|
||||
|
||||
#if defined(OS_MAC)
|
||||
views_delegate_.reset(new ViewsDelegateMac);
|
||||
views_delegate_ = std::make_unique<ViewsDelegateMac>();
|
||||
#else
|
||||
views_delegate_ = std::make_unique<ViewsDelegate>();
|
||||
#endif
|
||||
|
|
|
@ -111,9 +111,8 @@ ElectronManagementAPIDelegate::SetEnabledFunctionDelegate(
|
|||
content::BrowserContext* browser_context,
|
||||
const extensions::Extension* extension,
|
||||
base::OnceCallback<void(bool)> callback) const {
|
||||
return std::unique_ptr<ManagementSetEnabledFunctionInstallPromptDelegate>(
|
||||
new ManagementSetEnabledFunctionInstallPromptDelegate(
|
||||
web_contents, browser_context, extension, std::move(callback)));
|
||||
return std::make_unique<ManagementSetEnabledFunctionInstallPromptDelegate>(
|
||||
web_contents, browser_context, extension, std::move(callback));
|
||||
}
|
||||
|
||||
std::unique_ptr<extensions::UninstallDialogDelegate>
|
||||
|
@ -121,9 +120,8 @@ ElectronManagementAPIDelegate::UninstallFunctionDelegate(
|
|||
extensions::ManagementUninstallFunctionBase* function,
|
||||
const extensions::Extension* target_extension,
|
||||
bool show_programmatic_uninstall_ui) const {
|
||||
return std::unique_ptr<extensions::UninstallDialogDelegate>(
|
||||
new ManagementUninstallFunctionUninstallDialogDelegate(
|
||||
function, target_extension, show_programmatic_uninstall_ui));
|
||||
return std::make_unique<ManagementUninstallFunctionUninstallDialogDelegate>(
|
||||
function, target_extension, show_programmatic_uninstall_ui);
|
||||
}
|
||||
|
||||
bool ElectronManagementAPIDelegate::CreateAppShortcutFunctionDelegate(
|
||||
|
|
|
@ -62,10 +62,9 @@ void StreamsPrivateAPI::SendExecuteMimeTypeHandlerEvent(
|
|||
auto* api_contents = electron::api::WebContents::From(web_contents);
|
||||
if (api_contents)
|
||||
tab_id = api_contents->ID();
|
||||
std::unique_ptr<extensions::StreamContainer> stream_container(
|
||||
new extensions::StreamContainer(
|
||||
tab_id, embedded, handler_url, extension_id,
|
||||
std::move(transferrable_loader), original_url));
|
||||
auto stream_container = std::make_unique<extensions::StreamContainer>(
|
||||
tab_id, embedded, handler_url, extension_id,
|
||||
std::move(transferrable_loader), original_url);
|
||||
extensions::MimeHandlerStreamManager::Get(browser_context)
|
||||
->AddStream(view_id, std::move(stream_container), frame_tree_node_id,
|
||||
render_process_id, render_frame_id);
|
||||
|
|
|
@ -72,7 +72,7 @@ ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
|
|||
base::DictionaryValue* details_value = NULL;
|
||||
if (!args_->GetDictionary(1, &details_value))
|
||||
return set_init_result(VALIDATION_FAILURE);
|
||||
std::unique_ptr<InjectDetails> details(new InjectDetails());
|
||||
auto details = std::make_unique<InjectDetails>();
|
||||
if (!InjectDetails::Populate(*details_value, details.get()))
|
||||
return set_init_result(VALIDATION_FAILURE);
|
||||
|
||||
|
@ -180,7 +180,7 @@ ExtensionFunction::ResponseAction TabsGetFunction::Run() {
|
|||
|
||||
tabs::Tab tab;
|
||||
|
||||
tab.id.reset(new int(tab_id));
|
||||
tab.id = std::make_unique<int>(tab_id);
|
||||
// TODO(nornagon): in Chrome, the tab URL is only available to extensions
|
||||
// that have the "tabs" (or "activeTab") permission. We should do the same
|
||||
// permission check here.
|
||||
|
@ -249,9 +249,8 @@ ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() {
|
|||
contents->GetZoomController()->zoom_mode();
|
||||
api::tabs::ZoomSettings zoom_settings;
|
||||
ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
|
||||
zoom_settings.default_zoom_factor.reset(
|
||||
new double(blink::PageZoomLevelToZoomFactor(
|
||||
zoom_controller->GetDefaultZoomLevel())));
|
||||
zoom_settings.default_zoom_factor = std::make_unique<double>(
|
||||
blink::PageZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()));
|
||||
|
||||
return RespondNow(
|
||||
ArgumentList(api::tabs::GetZoomSettings::Results::Create(zoom_settings)));
|
||||
|
|
|
@ -92,7 +92,7 @@ void ElectronExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
|
|||
if (!browser_context_->IsOffTheRecord())
|
||||
LoadComponentExtensions();
|
||||
|
||||
management_policy_.reset(new ManagementPolicy);
|
||||
management_policy_ = std::make_unique<ManagementPolicy>();
|
||||
}
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> ParseManifest(
|
||||
|
@ -160,7 +160,7 @@ scoped_refptr<ValueStoreFactory> ElectronExtensionSystem::store_factory() {
|
|||
|
||||
InfoMap* ElectronExtensionSystem::info_map() {
|
||||
if (!info_map_.get())
|
||||
info_map_ = new InfoMap;
|
||||
info_map_ = base::MakeRefCounted<InfoMap>();
|
||||
return info_map_.get();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,14 +57,15 @@ using extensions::ExtensionsBrowserClient;
|
|||
namespace electron {
|
||||
|
||||
ElectronExtensionsBrowserClient::ElectronExtensionsBrowserClient()
|
||||
: api_client_(new extensions::ElectronExtensionsAPIClient),
|
||||
process_manager_delegate_(new extensions::ElectronProcessManagerDelegate),
|
||||
extension_cache_(new extensions::NullExtensionCache()) {
|
||||
: api_client_(std::make_unique<extensions::ElectronExtensionsAPIClient>()),
|
||||
process_manager_delegate_(
|
||||
std::make_unique<extensions::ElectronProcessManagerDelegate>()),
|
||||
extension_cache_(std::make_unique<extensions::NullExtensionCache>()) {
|
||||
// Electron does not have a concept of channel, so leave UNKNOWN to
|
||||
// enable all channel-dependent extension APIs.
|
||||
extensions::SetCurrentChannel(version_info::Channel::UNKNOWN);
|
||||
resource_manager_.reset(
|
||||
new extensions::ElectronComponentExtensionResourceManager());
|
||||
resource_manager_ =
|
||||
std::make_unique<extensions::ElectronComponentExtensionResourceManager>();
|
||||
|
||||
AddAPIProvider(
|
||||
std::make_unique<extensions::CoreExtensionsBrowserAPIProvider>());
|
||||
|
@ -245,7 +246,7 @@ ElectronExtensionsBrowserClient::GetProcessManagerDelegate() const {
|
|||
std::unique_ptr<extensions::ExtensionHostDelegate>
|
||||
ElectronExtensionsBrowserClient::
|
||||
CreateExtensionHostDelegate() { // TODO(samuelmaddock):
|
||||
return base::WrapUnique(new extensions::ElectronExtensionHostDelegate);
|
||||
return std::make_unique<extensions::ElectronExtensionHostDelegate>();
|
||||
}
|
||||
|
||||
bool ElectronExtensionsBrowserClient::DidVersionUpdate(
|
||||
|
@ -348,7 +349,7 @@ ElectronExtensionsBrowserClient::GetExtensionWebContentsObserver(
|
|||
|
||||
extensions::KioskDelegate* ElectronExtensionsBrowserClient::GetKioskDelegate() {
|
||||
if (!kiosk_delegate_)
|
||||
kiosk_delegate_.reset(new ElectronKioskDelegate());
|
||||
kiosk_delegate_ = std::make_unique<ElectronKioskDelegate>();
|
||||
return kiosk_delegate_.get();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) {
|
|||
|
||||
NativeWindow::NativeWindow(const gin_helper::Dictionary& options,
|
||||
NativeWindow* parent)
|
||||
: widget_(new views::Widget), parent_(parent) {
|
||||
: widget_(std::make_unique<views::Widget>()), parent_(parent) {
|
||||
++next_id_;
|
||||
|
||||
options.Get(options::kFrame, &has_frame_);
|
||||
|
|
|
@ -145,8 +145,9 @@ class NativeWindowClientView : public views::ClientView {
|
|||
NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
|
||||
NativeWindow* parent)
|
||||
: NativeWindow(options, parent),
|
||||
root_view_(new RootView(this)),
|
||||
keyboard_event_handler_(new views::UnhandledKeyboardEventHandler) {
|
||||
root_view_(std::make_unique<RootView>(this)),
|
||||
keyboard_event_handler_(
|
||||
std::make_unique<views::UnhandledKeyboardEventHandler>()) {
|
||||
options.Get(options::kTitle, &title_);
|
||||
|
||||
bool menu_bar_autohide;
|
||||
|
@ -747,8 +748,8 @@ bool NativeWindowViews::MoveAbove(const std::string& sourceId) {
|
|||
}
|
||||
|
||||
void NativeWindowViews::MoveTop() {
|
||||
// TODO(julien.isorce): fix chromium in order to use existing
|
||||
// widget()->StackAtTop().
|
||||
// TODO(julien.isorce): fix chromium in order to use existing
|
||||
// widget()->StackAtTop().
|
||||
#if defined(OS_WIN)
|
||||
gfx::Point pos = GetPosition();
|
||||
gfx::Size size = GetSize();
|
||||
|
|
|
@ -97,15 +97,17 @@ network::mojom::URLResponseHeadPtr ToResponseHead(
|
|||
head->mime_type = "text/html";
|
||||
head->charset = "utf-8";
|
||||
if (dict.IsEmpty()) {
|
||||
head->headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK");
|
||||
head->headers =
|
||||
base::MakeRefCounted<net::HttpResponseHeaders>("HTTP/1.1 200 OK");
|
||||
return head;
|
||||
}
|
||||
|
||||
int status_code = net::HTTP_OK;
|
||||
dict.Get("statusCode", &status_code);
|
||||
head->headers = new net::HttpResponseHeaders(base::StringPrintf(
|
||||
"HTTP/1.1 %d %s", status_code,
|
||||
net::GetHttpReasonPhrase(static_cast<net::HttpStatusCode>(status_code))));
|
||||
head->headers = base::MakeRefCounted<net::HttpResponseHeaders>(
|
||||
base::StringPrintf("HTTP/1.1 %d %s", status_code,
|
||||
net::GetHttpReasonPhrase(
|
||||
static_cast<net::HttpStatusCode>(status_code))));
|
||||
|
||||
dict.Get("charset", &head->charset);
|
||||
bool has_mime_type = dict.Get("mimeType", &head->mime_type);
|
||||
|
|
|
@ -820,8 +820,9 @@ void ProxyingURLLoaderFactory::CreateLoaderAndStart(
|
|||
// make ServiceWorker work with file:// URLs, we have to intercept its
|
||||
// requests here.
|
||||
if (IsForServiceWorkerScript() && request.url.SchemeIsFile()) {
|
||||
asar::CreateAsarURLLoader(request, std::move(loader), std::move(client),
|
||||
new net::HttpResponseHeaders(""));
|
||||
asar::CreateAsarURLLoader(
|
||||
request, std::move(loader), std::move(client),
|
||||
base::MakeRefCounted<net::HttpResponseHeaders>(""));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -214,7 +214,8 @@ void SystemNetworkContextManager::DeleteInstance() {
|
|||
SystemNetworkContextManager::SystemNetworkContextManager(
|
||||
PrefService* pref_service)
|
||||
: proxy_config_monitor_(pref_service) {
|
||||
shared_url_loader_factory_ = new URLLoaderFactoryForSystem(this);
|
||||
shared_url_loader_factory_ =
|
||||
base::MakeRefCounted<URLLoaderFactoryForSystem>(this);
|
||||
}
|
||||
|
||||
SystemNetworkContextManager::~SystemNetworkContextManager() {
|
||||
|
|
|
@ -52,8 +52,7 @@ NotificationPresenter* NotificationPresenter::Create() {
|
|||
return new NotificationPresenterWin7;
|
||||
if (!WindowsToastNotification::Initialize())
|
||||
return nullptr;
|
||||
std::unique_ptr<NotificationPresenterWin> presenter(
|
||||
new NotificationPresenterWin);
|
||||
auto presenter = std::make_unique<NotificationPresenterWin>();
|
||||
if (!presenter->Init())
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -183,9 +183,9 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
|
|||
frame_rate_(frame_rate),
|
||||
size_(initial_size),
|
||||
painting_(painting),
|
||||
cursor_manager_(new content::CursorManager(this)),
|
||||
cursor_manager_(std::make_unique<content::CursorManager>(this)),
|
||||
mouse_wheel_phase_handler_(this),
|
||||
backing_(new SkBitmap) {
|
||||
backing_(std::make_unique<SkBitmap>()) {
|
||||
DCHECK(render_widget_host_);
|
||||
DCHECK(!render_widget_host_->GetView());
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
certChain:(CFArrayRef)certChain
|
||||
secPolicy:(SecPolicyRef)secPolicy {
|
||||
if ((self = [super init])) {
|
||||
promise_.reset(new gin_helper::Promise<void>(std::move(promise)));
|
||||
promise_ = std::make_unique<gin_helper::Promise<void>>(std::move(promise));
|
||||
panel_ = panel;
|
||||
cert_ = cert;
|
||||
trust_ = trust;
|
||||
|
|
|
@ -43,8 +43,8 @@ class TCPServerSocketFactory : public content::DevToolsSocketFactory {
|
|||
private:
|
||||
// content::ServerSocketFactory.
|
||||
std::unique_ptr<net::ServerSocket> CreateForHttpServer() override {
|
||||
std::unique_ptr<net::ServerSocket> socket(
|
||||
new net::TCPServerSocket(nullptr, net::NetLogSource()));
|
||||
auto socket =
|
||||
std::make_unique<net::TCPServerSocket>(nullptr, net::NetLogSource());
|
||||
if (socket->ListenWithAddressAndPort(address_, port_, 10) != net::OK)
|
||||
return std::unique_ptr<net::ServerSocket>();
|
||||
|
||||
|
@ -77,8 +77,7 @@ std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory() {
|
|||
DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
|
||||
}
|
||||
}
|
||||
return std::unique_ptr<content::DevToolsSocketFactory>(
|
||||
new TCPServerSocketFactory("127.0.0.1", port));
|
||||
return std::make_unique<TCPServerSocketFactory>("127.0.0.1", port);
|
||||
}
|
||||
|
||||
const char kBrowserCloseMethod[] = "Browser.close";
|
||||
|
|
|
@ -46,12 +46,11 @@ std::unique_ptr<views::StatusIconLinux> CreateLinuxStatusIcon(
|
|||
if (AppIndicatorIcon::CouldOpen()) {
|
||||
++indicators_count;
|
||||
|
||||
return std::unique_ptr<views::StatusIconLinux>(new AppIndicatorIcon(
|
||||
return std::make_unique<AppIndicatorIcon>(
|
||||
base::StringPrintf("%s%d", id_prefix, indicators_count), image,
|
||||
tool_tip));
|
||||
tool_tip);
|
||||
} else {
|
||||
return std::unique_ptr<views::StatusIconLinux>(
|
||||
new GtkStatusIcon(image, tool_tip));
|
||||
return std::make_unique<GtkStatusIcon>(image, tool_tip);
|
||||
}
|
||||
return nullptr;
|
||||
#endif
|
||||
|
|
|
@ -614,8 +614,7 @@ void InspectableWebContents::AddDevToolsExtensionsToClient() {
|
|||
web_contents_->GetMainFrame()->GetProcess()->GetID(),
|
||||
url::Origin::Create(extension->url()));
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> extension_info(
|
||||
new base::DictionaryValue());
|
||||
auto extension_info = std::make_unique<base::DictionaryValue>();
|
||||
extension_info->SetString("startPage", devtools_page_url.spec());
|
||||
extension_info->SetString("name", extension->name());
|
||||
extension_info->SetBoolean(
|
||||
|
|
|
@ -91,8 +91,7 @@ std::unique_ptr<base::DictionaryValue> BuildTargetDescriptor(
|
|||
int routing_id,
|
||||
ui::AXMode accessibility_mode,
|
||||
base::ProcessHandle handle = base::kNullProcessHandle) {
|
||||
std::unique_ptr<base::DictionaryValue> target_data(
|
||||
new base::DictionaryValue());
|
||||
auto target_data = std::make_unique<base::DictionaryValue>();
|
||||
target_data->SetInteger(kProcessIdField, process_id);
|
||||
target_data->SetInteger(kRoutingIdField, routing_id);
|
||||
target_data->SetString(kUrlField, url.spec());
|
||||
|
@ -135,8 +134,7 @@ std::unique_ptr<base::DictionaryValue> BuildTargetDescriptor(
|
|||
|
||||
std::unique_ptr<base::DictionaryValue> BuildTargetDescriptor(
|
||||
electron::NativeWindow* window) {
|
||||
std::unique_ptr<base::DictionaryValue> target_data(
|
||||
new base::DictionaryValue());
|
||||
auto target_data = std::make_unique<base::DictionaryValue>();
|
||||
target_data->SetInteger(kSessionIdField, window->window_id());
|
||||
target_data->SetString(kNameField, window->GetTitle());
|
||||
target_data->SetString(kTypeField, kBrowser);
|
||||
|
@ -259,7 +257,7 @@ void HandleAccessibilityRequestCallback(
|
|||
// Always dump the Accessibility tree.
|
||||
data.SetString(kInternal, kOn);
|
||||
|
||||
std::unique_ptr<base::ListValue> rvh_list(new base::ListValue());
|
||||
auto rvh_list = std::make_unique<base::ListValue>();
|
||||
std::unique_ptr<content::RenderWidgetHostIterator> widgets(
|
||||
content::RenderWidgetHost::GetRenderWidgetHosts());
|
||||
|
||||
|
@ -293,7 +291,7 @@ void HandleAccessibilityRequestCallback(
|
|||
|
||||
data.Set(kPagesField, std::move(rvh_list));
|
||||
|
||||
std::unique_ptr<base::ListValue> window_list(new base::ListValue());
|
||||
auto window_list = std::make_unique<base::ListValue>();
|
||||
for (auto* window : electron::WindowList::GetWindows()) {
|
||||
window_list->Append(BuildTargetDescriptor(window));
|
||||
}
|
||||
|
@ -383,7 +381,7 @@ void ElectronAccessibilityUIMessageHandler::RequestNativeUITree(
|
|||
}
|
||||
|
||||
// No browser with the specified |id| was found.
|
||||
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
|
||||
auto result = std::make_unique<base::DictionaryValue>();
|
||||
result->SetInteger(kSessionIdField, window_id);
|
||||
result->SetString(kTypeField, kBrowser);
|
||||
result->SetString(kErrorField, "Window no longer exists.");
|
||||
|
|
|
@ -210,9 +210,9 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
|
|||
if (pos.IsOrigin())
|
||||
rect.set_origin(display::Screen::GetScreen()->GetCursorScreenPoint());
|
||||
|
||||
menu_runner_.reset(
|
||||
new views::MenuRunner(menu_model != nullptr ? menu_model : menu_model_,
|
||||
views::MenuRunner::HAS_MNEMONICS));
|
||||
menu_runner_ = std::make_unique<views::MenuRunner>(
|
||||
menu_model != nullptr ? menu_model : menu_model_,
|
||||
views::MenuRunner::HAS_MNEMONICS);
|
||||
menu_runner_->RunMenuAt(nullptr, nullptr, rect,
|
||||
views::MenuAnchorPosition::kTopLeft,
|
||||
ui::MENU_SOURCE_MOUSE);
|
||||
|
|
|
@ -40,7 +40,7 @@ bool ShouldUseGlobalMenuBar() {
|
|||
return false;
|
||||
|
||||
dbus::Bus::Options options;
|
||||
scoped_refptr<dbus::Bus> bus(new dbus::Bus(options));
|
||||
auto bus = base::MakeRefCounted<dbus::Bus>(options);
|
||||
|
||||
dbus::ObjectProxy* object_proxy =
|
||||
bus->GetObjectProxy(DBUS_SERVICE_DBUS, dbus::ObjectPath(DBUS_PATH_DBUS));
|
||||
|
|
|
@ -108,7 +108,7 @@ void WebContentsPermissionHelper::RequestMediaAccessPermission(
|
|||
&MediaAccessAllowed, request, std::move(response_callback)));
|
||||
|
||||
base::DictionaryValue details;
|
||||
std::unique_ptr<base::ListValue> media_types(new base::ListValue);
|
||||
auto media_types = std::make_unique<base::ListValue>();
|
||||
if (request.audio_type ==
|
||||
blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE) {
|
||||
media_types->AppendString("audio");
|
||||
|
|
|
@ -315,7 +315,7 @@ bool Converter<scoped_refptr<network::ResourceRequestBody>>::FromV8(
|
|||
auto list = std::make_unique<base::ListValue>();
|
||||
if (!ConvertFromV8(isolate, val, list.get()))
|
||||
return false;
|
||||
*out = new network::ResourceRequestBody();
|
||||
*out = base::MakeRefCounted<network::ResourceRequestBody>();
|
||||
for (size_t i = 0; i < list->GetSize(); ++i) {
|
||||
base::DictionaryValue* dict = nullptr;
|
||||
std::string type;
|
||||
|
|
|
@ -391,7 +391,7 @@ std::unique_ptr<base::Value> V8ValueConverter::FromV8Array(
|
|||
val->CreationContext() != isolate->GetCurrentContext())
|
||||
scope = std::make_unique<v8::Context::Scope>(val->CreationContext());
|
||||
|
||||
std::unique_ptr<base::ListValue> result(new base::ListValue());
|
||||
auto result = std::make_unique<base::ListValue>();
|
||||
|
||||
// Only fields with integer keys are carried over to the ListValue.
|
||||
for (uint32_t i = 0; i < val->Length(); ++i) {
|
||||
|
|
|
@ -220,9 +220,9 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
|
|||
// Make the promise a shared_ptr so that when the original promise is
|
||||
// freed the proxy promise is correctly freed as well instead of being
|
||||
// left dangling
|
||||
std::shared_ptr<gin_helper::Promise<v8::Local<v8::Value>>> proxied_promise(
|
||||
new gin_helper::Promise<v8::Local<v8::Value>>(
|
||||
destination_context->GetIsolate()));
|
||||
auto proxied_promise =
|
||||
std::make_shared<gin_helper::Promise<v8::Local<v8::Value>>>(
|
||||
destination_context->GetIsolate());
|
||||
v8::Local<v8::Promise> proxied_promise_handle =
|
||||
proxied_promise->GetHandle();
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ bool IsDevToolsExtension(content::RenderFrame* render_frame) {
|
|||
ElectronRendererClient::ElectronRendererClient()
|
||||
: node_bindings_(
|
||||
NodeBindings::Create(NodeBindings::BrowserEnvironment::kRenderer)),
|
||||
electron_bindings_(new ElectronBindings(node_bindings_->uv_loop())) {}
|
||||
electron_bindings_(
|
||||
std::make_unique<ElectronBindings>(node_bindings_->uv_loop())) {}
|
||||
|
||||
ElectronRendererClient::~ElectronRendererClient() = default;
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ void ElectronExtensionsDispatcherDelegate::RegisterNativeHandlers(
|
|||
extensions::ScriptContext* context) {
|
||||
module_system->RegisterNativeHandler(
|
||||
"lazy_background_page",
|
||||
std::unique_ptr<NativeHandler>(
|
||||
new extensions::LazyBackgroundPageNativeHandler(context)));
|
||||
std::make_unique<extensions::LazyBackgroundPageNativeHandler>(context));
|
||||
}
|
||||
|
||||
void ElectronExtensionsDispatcherDelegate::PopulateSourceMap(
|
||||
|
|
|
@ -179,7 +179,8 @@ void RendererClientBase::RenderThreadStarted() {
|
|||
extensions_client_.reset(CreateExtensionsClient());
|
||||
extensions::ExtensionsClient::Set(extensions_client_.get());
|
||||
|
||||
extensions_renderer_client_.reset(new ElectronExtensionsRendererClient);
|
||||
extensions_renderer_client_ =
|
||||
std::make_unique<ElectronExtensionsRendererClient>();
|
||||
extensions::ExtensionsRendererClient::Set(extensions_renderer_client_.get());
|
||||
|
||||
thread->AddObserver(extensions_renderer_client_->GetDispatcher());
|
||||
|
@ -187,7 +188,7 @@ void RendererClientBase::RenderThreadStarted() {
|
|||
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
// Enables printing from Chrome PDF viewer.
|
||||
pdf_print_client_.reset(new ChromePDFPrintClient());
|
||||
pdf_print_client_ = std::make_unique<ChromePDFPrintClient>();
|
||||
pdf::PepperPDFHost::SetPrintClient(pdf_print_client_.get());
|
||||
#endif
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ WebWorkerObserver* WebWorkerObserver::GetCurrent() {
|
|||
WebWorkerObserver::WebWorkerObserver()
|
||||
: node_bindings_(
|
||||
NodeBindings::Create(NodeBindings::BrowserEnvironment::kWorker)),
|
||||
electron_bindings_(new ElectronBindings(node_bindings_->uv_loop())) {
|
||||
electron_bindings_(
|
||||
std::make_unique<ElectronBindings>(node_bindings_->uv_loop())) {
|
||||
lazy_tls.Pointer()->Set(this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue