#ifndef IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_H_
#define IOS_WEB_VIEW_INTERNAL_APP_APPLICATION_CONTEXT_H_
#include <memory>
#include <string>
#include "base/memory/scoped_refptr.h"
#include "base/no_destructor.h"
#include "base/sequence_checker.h"
#include "ios/web/public/init/network_context_owner.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/mojom/network_service.mojom.h"
namespace component_updater {
class ComponentUpdateService;
}
namespace net {
class NetLog;
class URLRequestContextGetter;
}
namespace network {
class NetworkChangeManager;
class NetworkConnectionTracker;
class SharedURLLoaderFactory;
class WeakWrapperSharedURLLoaderFactory;
namespace mojom {
class NetworkContext;
}
}
namespace os_crypt_async {
class OSCryptAsync;
}
class PrefService;
class SafeBrowsingService;
namespace ios_web_view {
class WebViewIOThread;
class ApplicationContext {
public:
static ApplicationContext* GetInstance();
ApplicationContext(const ApplicationContext&) = delete;
ApplicationContext& operator=(const ApplicationContext&) = delete;
PrefService* GetLocalState();
net::URLRequestContextGetter* GetSystemURLRequestContext();
scoped_refptr<network::SharedURLLoaderFactory> GetSharedURLLoaderFactory();
network::mojom::NetworkContext* GetSystemNetworkContext();
network::NetworkConnectionTracker* GetNetworkConnectionTracker();
const std::string& GetApplicationLocale();
net::NetLog* GetNetLog();
component_updater::ComponentUpdateService* GetComponentUpdateService();
os_crypt_async::OSCryptAsync* GetOSCryptAsync();
void PreCreateThreads();
void PostCreateThreads();
void SaveState();
void PostDestroyThreads();
SafeBrowsingService* GetSafeBrowsingService();
void ShutdownSafeBrowsingServiceIfNecessary();
private:
friend class base::NoDestructor<ApplicationContext>;
ApplicationContext();
~ApplicationContext();
WebViewIOThread* GetWebViewIOThread();
void SetApplicationLocale(const std::string& locale);
SEQUENCE_CHECKER(sequence_checker_);
std::unique_ptr<PrefService> local_state_;
std::unique_ptr<WebViewIOThread> web_view_io_thread_;
std::string application_locale_;
mojo::Remote<network::mojom::NetworkContext> network_context_;
mojo::Remote<network::mojom::URLLoaderFactory> url_loader_factory_;
scoped_refptr<network::WeakWrapperSharedURLLoaderFactory>
shared_url_loader_factory_;
std::unique_ptr<web::NetworkContextOwner> network_context_owner_;
std::unique_ptr<network::NetworkChangeManager> network_change_manager_;
std::unique_ptr<network::NetworkConnectionTracker>
network_connection_tracker_;
std::unique_ptr<component_updater::ComponentUpdateService> component_updater_;
scoped_refptr<SafeBrowsingService> safe_browsing_service_;
std::unique_ptr<os_crypt_async::OSCryptAsync> os_crypt_async_;
};
}
#endif