OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/extensions/extension_localization_peer.h" | 5 #include "chrome/renderer/extensions/extension_localization_peer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
14 #include "extensions/common/constants.h" | 14 #include "extensions/common/constants.h" |
15 #include "extensions/common/extension_messages.h" | 15 #include "extensions/common/extension_messages.h" |
16 #include "extensions/common/message_bundle.h" | 16 #include "extensions/common/message_bundle.h" |
17 #include "ipc/ipc_sender.h" | 17 #include "ipc/ipc_sender.h" |
18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
19 #include "net/http/http_response_headers.h" | 19 #include "net/http/http_response_headers.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 class StringData final : public content::RequestPeer::ReceivedData { | 23 class StringData final : public content::RequestPeer::ReceivedData { |
24 public: | 24 public: |
25 explicit StringData(const std::string& data) : data_(data) {} | 25 explicit StringData(const std::string& data) : data_(data) {} |
26 void Append(const char* data, int length) { data_.append(data, length); } | 26 void Append(const char* data, int length) { data_.append(data, length); } |
27 | 27 |
28 const char* payload() const override { return data_.data(); } | 28 const char* payload() const override { return data_.data(); } |
29 int length() const override { return data_.size(); } | 29 int length() const override { return data_.size(); } |
30 int encoded_length() const override { return -1; } | 30 int encoded_length() const override { return -1; } |
Kunihiko Sakamoto
2016/07/01 10:12:35
encoded_data_length?
Adam Rice
2016/07/04 02:44:18
Done. Sorry for making you act as a human compiler
| |
31 // The original data has substitutions applied, so the original | |
32 // encoded_body_length no longer applies. | |
33 int encoded_body_length() const override { return data.size(); } | |
Kunihiko Sakamoto
2016/07/01 10:12:35
s/data/data_/
Adam Rice
2016/07/04 02:44:18
Done.
| |
31 | 34 |
32 private: | 35 private: |
33 std::string data_; | 36 std::string data_; |
34 | 37 |
35 DISALLOW_COPY_AND_ASSIGN(StringData); | 38 DISALLOW_COPY_AND_ASSIGN(StringData); |
36 }; | 39 }; |
37 | 40 |
38 } // namespace | 41 } // namespace |
39 | 42 |
40 ExtensionLocalizationPeer::ExtensionLocalizationPeer( | 43 ExtensionLocalizationPeer::ExtensionLocalizationPeer( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 | 140 |
138 l10n_messages = extensions::GetL10nMessagesMap(extension_id); | 141 l10n_messages = extensions::GetL10nMessagesMap(extension_id); |
139 } | 142 } |
140 | 143 |
141 std::string error; | 144 std::string error; |
142 if (extensions::MessageBundle::ReplaceMessagesWithExternalDictionary( | 145 if (extensions::MessageBundle::ReplaceMessagesWithExternalDictionary( |
143 *l10n_messages, &data_, &error)) { | 146 *l10n_messages, &data_, &error)) { |
144 data_.resize(data_.size()); | 147 data_.resize(data_.size()); |
145 } | 148 } |
146 } | 149 } |
OLD | NEW |