1 // Copyright 2024 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/device_bound_sessions/session_service.h" 6 7 #include <memory> 8 9 #include "net/base/features.h" 10 #include "net/device_bound_sessions/registration_fetcher.h" 11 #include "net/device_bound_sessions/session.h" 12 #include "net/device_bound_sessions/session_service_impl.h" 13 #include "net/device_bound_sessions/unexportable_key_service_factory.h" 14 #include "net/url_request/url_request_context.h" 15 16 namespace net::device_bound_sessions { 17 Create(const URLRequestContext * request_context)18std::unique_ptr<SessionService> SessionService::Create( 19 const URLRequestContext* request_context) { 20 #if BUILDFLAG(ENABLE_DEVICE_BOUND_SESSIONS) 21 unexportable_keys::UnexportableKeyService* service = 22 UnexportableKeyServiceFactory::GetInstance()->GetShared(); 23 if (!service) { 24 return nullptr; 25 } 26 27 SessionStore* session_store = request_context->device_bound_session_store(); 28 auto session_service = std::make_unique<SessionServiceImpl>( 29 *service, request_context, session_store); 30 // Loads saved sessions if `session_store` is not null. 31 session_service->LoadSessionsAsync(); 32 return session_service; 33 #else 34 return nullptr; 35 #endif 36 } 37 38 } // namespace net::device_bound_sessions 39