2017-12-05 15:59:15 +09:00
|
|
|
// Copyright (c) 2017 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 13:46:59 -07:00
|
|
|
#include "shell/browser/session_preferences.h"
|
2017-12-05 15:59:15 +09:00
|
|
|
|
2020-07-13 18:13:34 -07:00
|
|
|
#include "base/logging.h"
|
2019-09-18 15:58:00 -04:00
|
|
|
#include "base/memory/ptr_util.h"
|
2021-07-01 17:51:37 -07:00
|
|
|
#include "content/public/browser/browser_context.h"
|
2019-09-18 15:58:00 -04:00
|
|
|
|
2017-12-05 15:59:15 +09:00
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
// static
|
|
|
|
int SessionPreferences::kLocatorKey = 0;
|
|
|
|
|
2023-06-09 11:20:43 -05:00
|
|
|
// static
|
|
|
|
void SessionPreferences::CreateForBrowserContext(
|
|
|
|
content::BrowserContext* context) {
|
|
|
|
DCHECK(context);
|
|
|
|
context->SetUserData(&kLocatorKey,
|
|
|
|
base::WrapUnique(new SessionPreferences{}));
|
2017-12-05 15:59:15 +09:00
|
|
|
}
|
|
|
|
|
2023-06-09 11:20:43 -05:00
|
|
|
SessionPreferences::SessionPreferences() = default;
|
2019-09-16 18:12:00 -04:00
|
|
|
SessionPreferences::~SessionPreferences() = default;
|
2017-12-05 15:59:15 +09:00
|
|
|
|
|
|
|
// static
|
|
|
|
SessionPreferences* SessionPreferences::FromBrowserContext(
|
|
|
|
content::BrowserContext* context) {
|
|
|
|
return static_cast<SessionPreferences*>(context->GetUserData(&kLocatorKey));
|
|
|
|
}
|
|
|
|
|
2025-02-05 14:18:24 -05:00
|
|
|
bool SessionPreferences::HasServiceWorkerPreloadScript() {
|
|
|
|
const auto& preloads = preload_scripts();
|
|
|
|
auto it = std::find_if(
|
|
|
|
preloads.begin(), preloads.end(), [](const PreloadScript& script) {
|
|
|
|
return script.script_type == PreloadScript::ScriptType::kServiceWorker;
|
|
|
|
});
|
|
|
|
return it != preloads.end();
|
|
|
|
}
|
|
|
|
|
2017-12-05 15:59:15 +09:00
|
|
|
} // namespace electron
|