Commit 7e2187f5 authored by Ayu Ishii's avatar Ayu Ishii Committed by Commit Bot

Change TrustedSourcesManager to return unique_ptr instead of raw pointer

Bug: 916176
Change-Id: I3418fdbceea18391bb09e957e4846accf1b28447
Reviewed-on: https://chromium-review.googlesource.com/c/1413072Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Ayu Ishii <ayui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626216}
parent 91ad3c28
...@@ -305,7 +305,7 @@ DownloadPrefs* DownloadPrefs::FromBrowserContext( ...@@ -305,7 +305,7 @@ DownloadPrefs* DownloadPrefs::FromBrowserContext(
bool DownloadPrefs::IsFromTrustedSource(const download::DownloadItem& item) { bool DownloadPrefs::IsFromTrustedSource(const download::DownloadItem& item) {
if (!trusted_sources_manager_) if (!trusted_sources_manager_)
trusted_sources_manager_.reset(TrustedSourcesManager::Create()); trusted_sources_manager_ = TrustedSourcesManager::Create();
return trusted_sources_manager_->IsFromTrustedSource(item.GetURL()); return trusted_sources_manager_->IsFromTrustedSource(item.GetURL());
} }
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_DOWNLOAD_TRUSTED_SOURCES_MANAGER_H_ #ifndef CHROME_BROWSER_DOWNLOAD_TRUSTED_SOURCES_MANAGER_H_
#define CHROME_BROWSER_DOWNLOAD_TRUSTED_SOURCES_MANAGER_H_ #define CHROME_BROWSER_DOWNLOAD_TRUSTED_SOURCES_MANAGER_H_
#include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "net/proxy_resolution/proxy_bypass_rules.h" #include "net/proxy_resolution/proxy_bypass_rules.h"
...@@ -29,7 +31,7 @@ class TrustedSourcesManager { ...@@ -29,7 +31,7 @@ class TrustedSourcesManager {
// the security zone mapping is used instead to determine whether the source // the security zone mapping is used instead to determine whether the source
// is trusted or not. // is trusted or not.
// //
static TrustedSourcesManager* Create(); static std::unique_ptr<TrustedSourcesManager> Create();
// Returns true if the source of this URL is part of the trusted sources. // Returns true if the source of this URL is part of the trusted sources.
virtual bool IsFromTrustedSource(const GURL& url) const; virtual bool IsFromTrustedSource(const GURL& url) const;
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
#include "chrome/browser/download/trusted_sources_manager.h" #include "chrome/browser/download/trusted_sources_manager.h"
#include "base/memory/ptr_util.h"
// static // static
TrustedSourcesManager* TrustedSourcesManager::Create() { std::unique_ptr<TrustedSourcesManager> TrustedSourcesManager::Create() {
return new TrustedSourcesManager; return base::WrapUnique(new TrustedSourcesManager);
} }
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <wrl/client.h> #include <wrl/client.h>
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -49,6 +50,6 @@ bool TrustedSourcesManagerWin::IsFromTrustedSource(const GURL& url) const { ...@@ -49,6 +50,6 @@ bool TrustedSourcesManagerWin::IsFromTrustedSource(const GURL& url) const {
} // namespace } // namespace
// static // static
TrustedSourcesManager* TrustedSourcesManager::Create() { std::unique_ptr<TrustedSourcesManager> TrustedSourcesManager::Create() {
return new TrustedSourcesManagerWin; return base::WrapUnique(new TrustedSourcesManagerWin);
} }
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