Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: content/browser/webui/i18n_source_stream.h

Issue 2544683002: [MD settings] i18n source stream filtering (Closed)
Patch Set: review nits Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/webui/i18n_source_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // How much of the |output_| has been sent.
50 size_t drain_offset_;
51
52 // A map of i18n replacement keys and translations.
53 const ui::TemplateReplacements* replacements_; // weak
54
55 DISALLOW_COPY_AND_ASSIGN(I18nSourceStream);
56 };
57
58 } // namespace content
59
60 #endif // CONTENT_BROWSER_WEBUI_I18N_SOURCE_STREAM_H_
OLDNEW
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/webui/i18n_source_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698