blob: 8461bb59f59a89f3c6a558d527e3aa93ee88dd42 [file] [log] [blame]
// Copyright 2020 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.
#import "ios/web_view/internal/passwords/web_view_password_requirements_service_factory.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "components/password_manager/core/browser/password_requirements_service.h"
#include "ios/web_view/internal/web_view_browser_state.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace ios_web_view {
// static
password_manager::PasswordRequirementsService*
WebViewPasswordRequirementsServiceFactory::GetForBrowserState(
WebViewBrowserState* browser_state,
ServiceAccessType access_type) {
return static_cast<password_manager::PasswordRequirementsService*>(
GetInstance()->GetServiceForBrowserState(browser_state, true));
}
// static
WebViewPasswordRequirementsServiceFactory*
WebViewPasswordRequirementsServiceFactory::GetInstance() {
static base::NoDestructor<WebViewPasswordRequirementsServiceFactory> instance;
return instance.get();
}
WebViewPasswordRequirementsServiceFactory::
WebViewPasswordRequirementsServiceFactory()
: BrowserStateKeyedServiceFactory(
"PasswordRequirementsServiceFactory",
BrowserStateDependencyManager::GetInstance()) {}
WebViewPasswordRequirementsServiceFactory::
~WebViewPasswordRequirementsServiceFactory() {}
std::unique_ptr<KeyedService>
WebViewPasswordRequirementsServiceFactory::BuildServiceInstanceFor(
web::BrowserState* context) const {
return password_manager::CreatePasswordRequirementsService(
context->GetSharedURLLoaderFactory());
}
bool WebViewPasswordRequirementsServiceFactory::ServiceIsNULLWhileTesting()
const {
return true;
}
} // namespace ios_web_view