refactor: move SpecialStoragePolicy from brightray to atom (#13944)
This commit is contained in:
parent
fc730cc705
commit
7253c7f843
8 changed files with 25 additions and 23 deletions
|
@ -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());
|
||||
|
|
|
@ -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_;
|
||||
|
|
41
atom/browser/special_storage_policy.cc
Normal file
41
atom/browser/special_storage_policy.cc
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/special_storage_policy.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
SpecialStoragePolicy::SpecialStoragePolicy() {}
|
||||
|
||||
SpecialStoragePolicy::~SpecialStoragePolicy() {}
|
||||
|
||||
bool SpecialStoragePolicy::IsStorageProtected(const GURL& origin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SpecialStoragePolicy::IsStorageUnlimited(const GURL& origin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SpecialStoragePolicy::IsStorageDurable(const GURL& origin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SpecialStoragePolicy::IsStorageSessionOnly(const GURL& origin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SpecialStoragePolicy::HasSessionOnlyOrigins() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SpecialStoragePolicy::ShouldDeleteCookieOnExit(const GURL& origin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace atom
|
31
atom/browser/special_storage_policy.h
Normal file
31
atom/browser/special_storage_policy.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_SPECIAL_STORAGE_POLICY_H_
|
||||
#define ATOM_BROWSER_SPECIAL_STORAGE_POLICY_H_
|
||||
|
||||
#include "storage/browser/quota/special_storage_policy.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class SpecialStoragePolicy : public storage::SpecialStoragePolicy {
|
||||
public:
|
||||
SpecialStoragePolicy();
|
||||
|
||||
// storage::SpecialStoragePolicy implementation.
|
||||
bool IsStorageProtected(const GURL& origin) override;
|
||||
bool IsStorageUnlimited(const GURL& origin) override;
|
||||
bool IsStorageDurable(const GURL& origin) override;
|
||||
bool HasIsolatedStorage(const GURL& origin) override;
|
||||
bool IsStorageSessionOnly(const GURL& origin) override;
|
||||
bool HasSessionOnlyOrigins() override;
|
||||
bool ShouldDeleteCookieOnExit(const GURL& origin) override;
|
||||
|
||||
protected:
|
||||
~SpecialStoragePolicy() override;
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_SPECIAL_STORAGE_POLICY_H_
|
Loading…
Add table
Add a link
Reference in a new issue