-
Notifications
You must be signed in to change notification settings - Fork 921
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ephemeral storage enabler to debounce throttler.
- Loading branch information
Showing
11 changed files
with
341 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
browser/ephemeral_storage/ephemeral_storage_service_factory.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/ephemeral_storage/ephemeral_storage_service_factory.h" | ||
|
||
#include <memory> | ||
|
||
#include "base/feature_list.h" | ||
#include "brave/components/ephemeral_storage/ephemeral_storage_service.h" | ||
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" | ||
#include "chrome/browser/profiles/incognito_helpers.h" | ||
#include "components/keyed_service/content/browser_context_dependency_manager.h" | ||
#include "net/base/features.h" | ||
|
||
// static | ||
EphemeralStorageServiceFactory* EphemeralStorageServiceFactory::GetInstance() { | ||
return base::Singleton<EphemeralStorageServiceFactory>::get(); | ||
} | ||
|
||
// static | ||
ephemeral_storage::EphemeralStorageService* | ||
EphemeralStorageServiceFactory::GetForContext( | ||
content::BrowserContext* context) { | ||
return static_cast<ephemeral_storage::EphemeralStorageService*>( | ||
GetInstance()->GetServiceForBrowserContext(context, true)); | ||
} | ||
|
||
EphemeralStorageServiceFactory::EphemeralStorageServiceFactory() | ||
: BrowserContextKeyedServiceFactory( | ||
"EphemeralStorageService", | ||
BrowserContextDependencyManager::GetInstance()) {} | ||
|
||
EphemeralStorageServiceFactory::~EphemeralStorageServiceFactory() {} | ||
|
||
KeyedService* EphemeralStorageServiceFactory::BuildServiceInstanceFor( | ||
content::BrowserContext* context) const { | ||
if (!base::FeatureList::IsEnabled( | ||
net::features::kBraveFirstPartyEphemeralStorage)) { | ||
return nullptr; | ||
} | ||
return new ephemeral_storage::EphemeralStorageService( | ||
context, HostContentSettingsMapFactory::GetForProfile(context)); | ||
} | ||
|
||
content::BrowserContext* EphemeralStorageServiceFactory::GetBrowserContextToUse( | ||
content::BrowserContext* context) const { | ||
return chrome::GetBrowserContextOwnInstanceInIncognito(context); | ||
} | ||
|
||
bool EphemeralStorageServiceFactory::ServiceIsCreatedWithBrowserContext() | ||
const { | ||
return false; | ||
} |
36 changes: 36 additions & 0 deletions
36
browser/ephemeral_storage/ephemeral_storage_service_factory.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_EPHEMERAL_STORAGE_EPHEMERAL_STORAGE_SERVICE_FACTORY_H_ | ||
#define BRAVE_BROWSER_EPHEMERAL_STORAGE_EPHEMERAL_STORAGE_SERVICE_FACTORY_H_ | ||
|
||
#include "base/memory/singleton.h" | ||
#include "components/keyed_service/content/browser_context_keyed_service_factory.h" | ||
|
||
namespace ephemeral_storage { | ||
class EphemeralStorageService; | ||
} | ||
|
||
class EphemeralStorageServiceFactory | ||
: public BrowserContextKeyedServiceFactory { | ||
public: | ||
static ephemeral_storage::EphemeralStorageService* GetForContext( | ||
content::BrowserContext* context); | ||
static EphemeralStorageServiceFactory* GetInstance(); | ||
|
||
private: | ||
friend struct base::DefaultSingletonTraits<EphemeralStorageServiceFactory>; | ||
|
||
EphemeralStorageServiceFactory(); | ||
~EphemeralStorageServiceFactory() override; | ||
|
||
KeyedService* BuildServiceInstanceFor( | ||
content::BrowserContext* context) const override; | ||
content::BrowserContext* GetBrowserContextToUse( | ||
content::BrowserContext* context) const override; | ||
bool ServiceIsCreatedWithBrowserContext() const override; | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_EPHEMERAL_STORAGE_EPHEMERAL_STORAGE_SERVICE_FACTORY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
static_library("ephemeral_storage") { | ||
sources = [ | ||
"ephemeral_storage_service.cc", | ||
"ephemeral_storage_service.h", | ||
] | ||
|
||
deps = [ | ||
"//base", | ||
"//components/keyed_service/core", | ||
"//components/prefs", | ||
"//components/security_interstitials/content:security_interstitial_page", | ||
"//components/security_interstitials/core", | ||
"//components/user_prefs", | ||
"//content/public/browser", | ||
"//net", | ||
"//ui/base", | ||
"//url", | ||
] | ||
} |
Oops, something went wrong.