diff --git a/atom/browser/common_web_contents_delegate.cc b/atom/browser/common_web_contents_delegate.cc index 4075cc9571a0..049b6dcf7a08 100644 --- a/atom/browser/common_web_contents_delegate.cc +++ b/atom/browser/common_web_contents_delegate.cc @@ -180,12 +180,12 @@ void CommonWebContentsDelegate::SetOwnerWindow(NativeWindow* owner_window) { void CommonWebContentsDelegate::SetOwnerWindow( content::WebContents* web_contents, NativeWindow* owner_window) { owner_window_ = owner_window ? owner_window->GetWeakPtr() : nullptr; - NativeWindowRelay* relay = new NativeWindowRelay(owner_window_); + auto relay = base::MakeUnique(owner_window_); if (owner_window) { - web_contents->SetUserData(relay->key, relay); + web_contents->SetUserData(relay->key, std::move(relay)); } else { web_contents->RemoveUserData(relay->key); - delete relay; + relay.reset(); } } diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index cc621625818f..81ce0c1e0646 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -13,6 +13,7 @@ #include "atom/common/native_mate_converters/value_converter.h" #include "atom/common/options_switches.h" #include "base/command_line.h" +#include "base/memory/ptr_util.h" #include "base/strings/string_number_conversions.h" #include "cc/base/switches.h" #include "content/public/browser/render_process_host.h" @@ -44,7 +45,7 @@ WebContentsPreferences::WebContentsPreferences( copied.Delete("session"); mate::ConvertFromV8(isolate, copied.GetHandle(), &web_preferences_); - web_contents->SetUserData(UserDataKey(), this); + web_contents->SetUserData(UserDataKey(), base::WrapUnique(this)); instances_.push_back(this); }