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 "base/memory/ref_counted.h" | |
13 #include "net/base/io_buffer.h" | |
14 #include "net/filter/filter_source_stream.h" | |
15 #include "ui/base/template_expressions.h" | |
16 | |
17 namespace content { | |
18 | |
19 class NET_EXPORT_PRIVATE I18nSourceStream : public net::FilterSourceStream { | |
20 public: | |
21 ~I18nSourceStream() override; | |
22 | |
23 // Factory function to create an I18nSourceStream. | |
24 static std::unique_ptr<I18nSourceStream> Create( | |
25 std::unique_ptr<SourceStream> previous, | |
26 SourceStream::SourceType type); | |
Dan Beam
2016/12/01 05:57:22
why can't this just take a TemplateReplacements as
dschuyler
2016/12/01 23:07:26
Done.
| |
27 | |
28 // Specify the dictionary of i18n replacements. | |
29 void SetReplacements(const ui::TemplateReplacements* replacements); | |
Dan Beam
2016/12/01 05:57:22
also, this should be set_replacements() if it stay
dschuyler
2016/12/01 23:07:26
Let's go with removing it.
| |
30 | |
31 private: | |
32 // Accumulated from upstream. | |
33 std::string input_; | |
34 | |
35 // To send downstream. | |
36 std::string output_; | |
37 | |
38 // A map of i18n replacement keys and translations. | |
39 const ui::TemplateReplacements* replacements_; // weak | |
40 | |
41 I18nSourceStream(std::unique_ptr<SourceStream> previous, | |
42 SourceStream::SourceType type); | |
43 | |
44 // SourceStream implementation. | |
45 std::string GetTypeAsString() const override; | |
46 int FilterData(net::IOBuffer* output_buffer, | |
47 int output_buffer_size, | |
48 net::IOBuffer* input_buffer, | |
49 int input_buffer_size, | |
50 int* consumed_bytes, | |
51 bool upstream_end_reached) override; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(I18nSourceStream); | |
54 }; | |
55 | |
56 } // namespace content | |
57 | |
58 #endif // CONTENT_BROWSER_WEBUI_I18N_SOURCE_STREAM_H_ | |
OLD | NEW |