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