fake_pdf_stream_delegate.cc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #include "components/pdf/browser/fake_pdf_stream_delegate.h"
  5. #include <utility>
  6. #include "components/pdf/browser/pdf_stream_delegate.h"
  7. #include "testing/gtest/include/gtest/gtest.h"
  8. #include "third_party/abseil-cpp/absl/types/optional.h"
  9. #include "third_party/skia/include/core/SkColor.h"
  10. #include "url/gurl.h"
  11. namespace pdf {
  12. // static
  13. constexpr char FakePdfStreamDelegate::kDefaultStreamUrl[];
  14. // static
  15. constexpr char FakePdfStreamDelegate::kDefaultOriginalUrl[];
  16. FakePdfStreamDelegate::FakePdfStreamDelegate() {
  17. StreamInfo info;
  18. info.stream_url = GURL(kDefaultStreamUrl);
  19. info.original_url = GURL(kDefaultOriginalUrl);
  20. stream_info_ = std::move(info);
  21. }
  22. FakePdfStreamDelegate::~FakePdfStreamDelegate() = default;
  23. absl::optional<GURL> FakePdfStreamDelegate::MapToOriginalUrl(
  24. content::WebContents* contents,
  25. const GURL& stream_url) {
  26. if (!stream_info_ || stream_info_->stream_url != stream_url)
  27. return absl::nullopt;
  28. return stream_info_->original_url;
  29. }
  30. absl::optional<PdfStreamDelegate::StreamInfo>
  31. FakePdfStreamDelegate::GetStreamInfo(content::WebContents* contents) {
  32. EXPECT_TRUE(contents);
  33. return stream_info_;
  34. }
  35. } // namespace pdf