refactor: move SpecialStoragePolicy from brightray to atom (#13944)

This commit is contained in:
Milan Burda 2018-08-21 17:51:04 +02:00 committed by Shelley Vohr
parent fc730cc705
commit 7253c7f843
8 changed files with 25 additions and 23 deletions

View file

@ -10,6 +10,7 @@
#include "atom/browser/atom_permission_manager.h"
#include "atom/browser/browser.h"
#include "atom/browser/request_context_delegate.h"
#include "atom/browser/special_storage_policy.h"
#include "atom/browser/web_view_manager.h"
#include "atom/common/atom_version.h"
#include "atom/common/chrome_version.h"
@ -42,7 +43,8 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
bool in_memory,
const base::DictionaryValue& options)
: brightray::BrowserContext(partition, in_memory),
url_request_context_getter_(nullptr) {
url_request_context_getter_(nullptr),
storage_policy_(new SpecialStoragePolicy) {
// Construct user agent string.
Browser* browser = Browser::Get();
std::string name = RemoveWhitespace(browser->GetName());
@ -98,6 +100,10 @@ content::PermissionManager* AtomBrowserContext::GetPermissionManager() {
return permission_manager_.get();
}
storage::SpecialStoragePolicy* AtomBrowserContext::GetSpecialStoragePolicy() {
return storage_policy_.get();
}
void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) {
pref_registry->RegisterFilePathPref(prefs::kSelectFileLastDirectory,
base::FilePath());

View file

@ -8,14 +8,20 @@
#include <string>
#include <vector>
#include "base/memory/scoped_refptr.h"
#include "brightray/browser/browser_context.h"
namespace storage {
class SpecialStoragePolicy;
}
namespace atom {
class AtomBlobReader;
class AtomDownloadManagerDelegate;
class AtomPermissionManager;
class RequestContextDelegate;
class SpecialStoragePolicy;
class WebViewManager;
class AtomBrowserContext : public brightray::BrowserContext {
@ -35,6 +41,7 @@ class AtomBrowserContext : public brightray::BrowserContext {
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
content::PermissionManager* GetPermissionManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
// brightray::BrowserContext:
void RegisterPrefs(PrefRegistrySimple* pref_registry) override;
@ -58,6 +65,7 @@ class AtomBrowserContext : public brightray::BrowserContext {
std::unique_ptr<AtomDownloadManagerDelegate> download_manager_delegate_;
std::unique_ptr<WebViewManager> guest_manager_;
std::unique_ptr<AtomPermissionManager> permission_manager_;
scoped_refptr<storage::SpecialStoragePolicy> storage_policy_;
std::unique_ptr<AtomBlobReader> blob_reader_;
std::unique_ptr<RequestContextDelegate> request_context_delegate_;
std::string user_agent_;

View file

@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "brightray/browser/special_storage_policy.h"
#include "atom/browser/special_storage_policy.h"
namespace brightray {
namespace atom {
SpecialStoragePolicy::SpecialStoragePolicy() {}
@ -38,4 +38,4 @@ bool SpecialStoragePolicy::ShouldDeleteCookieOnExit(const GURL& origin) {
return false;
}
} // namespace brightray
} // namespace atom

View file

@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BRIGHTRAY_BROWSER_SPECIAL_STORAGE_POLICY_H_
#define BRIGHTRAY_BROWSER_SPECIAL_STORAGE_POLICY_H_
#ifndef ATOM_BROWSER_SPECIAL_STORAGE_POLICY_H_
#define ATOM_BROWSER_SPECIAL_STORAGE_POLICY_H_
#include "storage/browser/quota/special_storage_policy.h"
namespace brightray {
namespace atom {
class SpecialStoragePolicy : public storage::SpecialStoragePolicy {
public:
@ -26,6 +26,6 @@ class SpecialStoragePolicy : public storage::SpecialStoragePolicy {
~SpecialStoragePolicy() override;
};
} // namespace brightray
} // namespace atom
#endif // BRIGHTRAY_BROWSER_SPECIAL_STORAGE_POLICY_H_
#endif // ATOM_BROWSER_SPECIAL_STORAGE_POLICY_H_

View file

@ -11,7 +11,6 @@
#include "brightray/browser/brightray_paths.h"
#include "brightray/browser/browser_client.h"
#include "brightray/browser/inspectable_web_contents_impl.h"
#include "brightray/browser/special_storage_policy.h"
#include "brightray/browser/zoom_level_delegate.h"
#include "brightray/common/application_info.h"
#include "components/prefs/json_pref_store.h"
@ -55,7 +54,6 @@ scoped_refptr<BrowserContext> BrowserContext::Get(const std::string& partition,
BrowserContext::BrowserContext(const std::string& partition, bool in_memory)
: in_memory_(in_memory),
storage_policy_(new SpecialStoragePolicy),
weak_factory_(this) {
if (!PathService::Get(DIR_USER_DATA, &path_)) {
PathService::Get(DIR_APP_DATA, &path_);
@ -160,10 +158,6 @@ content::BrowserPluginGuestManager* BrowserContext::GetGuestManager() {
return nullptr;
}
storage::SpecialStoragePolicy* BrowserContext::GetSpecialStoragePolicy() {
return storage_policy_.get();
}
content::PushMessagingService* BrowserContext::GetPushMessagingService() {
return nullptr;
}

View file

@ -17,10 +17,6 @@
class PrefRegistrySimple;
class PrefService;
namespace storage {
class SpecialStoragePolicy;
}
namespace brightray {
class BrowserContext;
@ -52,7 +48,6 @@ class BrowserContext
content::ResourceContext* GetResourceContext() override;
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
content::PushMessagingService* GetPushMessagingService() override;
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
@ -121,7 +116,6 @@ class BrowserContext
base::FilePath path_;
bool in_memory_;
scoped_refptr<storage::SpecialStoragePolicy> storage_policy_;
std::unique_ptr<PrefService> prefs_;
std::unique_ptr<MediaDeviceIDSalt> media_device_id_salt_;
// Self-destructing class responsible for creating URLRequestContextGetter

View file

@ -81,8 +81,6 @@
'browser/win/win32_notification.h',
'browser/win/windows_toast_notification.cc',
'browser/win/windows_toast_notification.h',
'browser/special_storage_policy.cc',
'browser/special_storage_policy.h',
'browser/url_request_context_getter.cc',
'browser/url_request_context_getter.h',
'browser/views/inspectable_web_contents_view_views.h',

View file

@ -317,6 +317,8 @@
'atom/browser/request_context_delegate.h',
'atom/browser/session_preferences.cc',
'atom/browser/session_preferences.h',
'atom/browser/special_storage_policy.cc',
'atom/browser/special_storage_policy.h',
'atom/browser/ui/accelerator_util.cc',
'atom/browser/ui/accelerator_util.h',
'atom/browser/ui/accelerator_util_mac.mm',