OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 |
| 5 #ifndef CONTENT_BROWSER_WEBUI_I18N_SOURCE_STREAM_H_ |
| 6 #define CONTENT_BROWSER_WEBUI_I18N_SOURCE_STREAM_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "content/common/content_export.h" |
| 13 #include "net/filter/filter_source_stream.h" |
| 14 #include "ui/base/template_expressions.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class CONTENT_EXPORT I18nSourceStream : public net::FilterSourceStream { |
| 19 public: |
| 20 ~I18nSourceStream() override; |
| 21 |
| 22 // Factory function to create an I18nSourceStream. |
| 23 // |replacements| is a dictionary of i18n replacements. |
| 24 static std::unique_ptr<I18nSourceStream> Create( |
| 25 std::unique_ptr<SourceStream> previous, |
| 26 SourceStream::SourceType type, |
| 27 const ui::TemplateReplacements* replacements); |
| 28 |
| 29 private: |
| 30 I18nSourceStream(std::unique_ptr<SourceStream> previous, |
| 31 SourceStream::SourceType type, |
| 32 const ui::TemplateReplacements* replacements); |
| 33 |
| 34 // SourceStream implementation. |
| 35 std::string GetTypeAsString() const override; |
| 36 int FilterData(net::IOBuffer* output_buffer, |
| 37 int output_buffer_size, |
| 38 net::IOBuffer* input_buffer, |
| 39 int input_buffer_size, |
| 40 int* consumed_bytes, |
| 41 bool upstream_end_reached) override; |
| 42 |
| 43 // Accumulated from upstream. |
| 44 std::string input_; |
| 45 |
| 46 // To send downstream. |
| 47 std::string output_; |
| 48 |
| 49 // A map of i18n replacement keys and translations. |
| 50 const ui::TemplateReplacements* replacements_; // weak |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(I18nSourceStream); |
| 53 }; |
| 54 |
| 55 } // namespace content |
| 56 |
| 57 #endif // CONTENT_BROWSER_WEBUI_I18N_SOURCE_STREAM_H_ |
OLD | NEW |