#ifndef CHROME_BROWSER_ENTERPRISE_PROFILE_MANAGEMENT_PROFILE_MANAGEMENT_NAVIGATION_THROTTLE_H_
#define CHROME_BROWSER_ENTERPRISE_PROFILE_MANAGEMENT_PROFILE_MANAGEMENT_NAVIGATION_THROTTLE_H_
#include <memory>
#include "base/containers/flat_map.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/navigation_throttle.h"
class GURL;
namespace profile_management {
class SAMLResponseParser;
class ProfileManagementNavigationThrottle : public content::NavigationThrottle {
public:
static void MaybeCreateAndAdd(content::NavigationThrottleRegistry& registry);
explicit ProfileManagementNavigationThrottle(
content::NavigationThrottleRegistry& registry);
ProfileManagementNavigationThrottle(
const ProfileManagementNavigationThrottle&) = delete;
ProfileManagementNavigationThrottle& operator=(
const ProfileManagementNavigationThrottle&) = delete;
~ProfileManagementNavigationThrottle() override;
ThrottleCheckResult WillProcessResponse() override;
const char* GetNameForLogging() override;
void SetURLsForTesting(const std::string& token_url,
const std::string& unmanaged_url);
void ClearAttributeMapForTesting();
private:
void OnResponseBodyReady(const std::string& body);
void OnManagementDataReceived(
const base::flat_map<std::string, std::string>& attributes);
void PostNavigateTo(const GURL& url);
void NavigateTo(const GURL& url);
void RegisterWithDomain(const std::string& domain);
void RegisterWithToken(const std::string& name, const std::string& token);
std::string token_url_for_testing_;
std::string unmanaged_url_for_testing_;
std::unique_ptr<SAMLResponseParser> saml_response_parser_;
base::WeakPtrFactory<ProfileManagementNavigationThrottle> weak_ptr_factory_{
this};
};
}
#endif