#ifndef EXTENSIONS_RENDERER_EXTENSION_LOCALIZATION_THROTTLE_H_
#define EXTENSIONS_RENDERER_EXTENSION_LOCALIZATION_THROTTLE_H_
#include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "third_party/blink/public/common/loader/url_loader_throttle.h"
namespace blink {
class WebURL;
}
namespace extensions {
class ExtensionLocalizationThrottle : public blink::URLLoaderThrottle {
public:
static std::unique_ptr<ExtensionLocalizationThrottle> MaybeCreate(
const blink::WebURL& request_url);
~ExtensionLocalizationThrottle() override;
void DetachFromCurrentSequence() override;
void WillProcessResponse(const GURL& response_url,
network::mojom::URLResponseHead* response_head,
bool* defer) override;
void ForceCreateDataPipeErrorForTest() { force_error_for_test_ = true; }
private:
ExtensionLocalizationThrottle();
void DeferredCancelWithError(int error_code);
bool force_error_for_test_ = false;
base::WeakPtrFactory<ExtensionLocalizationThrottle> weak_factory_{this};
};
}
#endif