fake_pdf_stream_delegate.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_PDF_BROWSER_FAKE_PDF_STREAM_DELEGATE_H_
  5. #define COMPONENTS_PDF_BROWSER_FAKE_PDF_STREAM_DELEGATE_H_
  6. #include "components/pdf/browser/pdf_stream_delegate.h"
  7. #include "third_party/abseil-cpp/absl/types/optional.h"
  8. namespace pdf {
  9. class FakePdfStreamDelegate : public PdfStreamDelegate {
  10. public:
  11. static constexpr char kDefaultStreamUrl[] =
  12. "chrome-extension://id/stream-url";
  13. static constexpr char kDefaultOriginalUrl[] = "https://example.test/fake.pdf";
  14. FakePdfStreamDelegate();
  15. FakePdfStreamDelegate(const FakePdfStreamDelegate&) = delete;
  16. FakePdfStreamDelegate& operator=(const FakePdfStreamDelegate&) = delete;
  17. ~FakePdfStreamDelegate() override;
  18. // `PdfStreamDelegate`:
  19. absl::optional<GURL> MapToOriginalUrl(content::WebContents* contents,
  20. const GURL& stream_url) override;
  21. absl::optional<StreamInfo> GetStreamInfo(
  22. content::WebContents* contents) override;
  23. void clear_stream_info() { stream_info_.reset(); }
  24. private:
  25. absl::optional<StreamInfo> stream_info_;
  26. };
  27. } // namespace pdf
  28. #endif // COMPONENTS_PDF_BROWSER_FAKE_PDF_STREAM_DELEGATE_H_