OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/common/extensions/extension_localization_peer.h" | 5 #include "chrome/common/extensions/extension_localization_peer.h" |
6 | 6 |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/common/extensions/extension_message_bundle.h" | 9 #include "chrome/common/extensions/extension_message_bundle.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const webkit_glue::ResourceResponseInfo& info, | 59 const webkit_glue::ResourceResponseInfo& info, |
60 bool content_filtered) { | 60 bool content_filtered) { |
61 response_info_ = info; | 61 response_info_ = info; |
62 } | 62 } |
63 | 63 |
64 void ExtensionLocalizationPeer::OnReceivedData(const char* data, int len) { | 64 void ExtensionLocalizationPeer::OnReceivedData(const char* data, int len) { |
65 data_.append(data, len); | 65 data_.append(data, len); |
66 } | 66 } |
67 | 67 |
68 void ExtensionLocalizationPeer::OnCompletedRequest( | 68 void ExtensionLocalizationPeer::OnCompletedRequest( |
69 const URLRequestStatus& status, | 69 const net::URLRequestStatus& status, |
70 const std::string& security_info, | 70 const std::string& security_info, |
71 const base::Time& completion_time) { | 71 const base::Time& completion_time) { |
72 // Make sure we delete ourselves at the end of this call. | 72 // Make sure we delete ourselves at the end of this call. |
73 scoped_ptr<ExtensionLocalizationPeer> this_deleter(this); | 73 scoped_ptr<ExtensionLocalizationPeer> this_deleter(this); |
74 | 74 |
75 // Give sub-classes a chance at altering the data. | 75 // Give sub-classes a chance at altering the data. |
76 if (status.status() != URLRequestStatus::SUCCESS) { | 76 if (status.status() != net::URLRequestStatus::SUCCESS) { |
77 // We failed to load the resource. | 77 // We failed to load the resource. |
78 original_peer_->OnReceivedResponse(response_info_, true); | 78 original_peer_->OnReceivedResponse(response_info_, true); |
79 URLRequestStatus status(URLRequestStatus::CANCELED, net::ERR_ABORTED); | 79 net::URLRequestStatus status(net::URLRequestStatus::CANCELED, |
| 80 net::ERR_ABORTED); |
80 original_peer_->OnCompletedRequest(status, security_info, completion_time); | 81 original_peer_->OnCompletedRequest(status, security_info, completion_time); |
81 return; | 82 return; |
82 } | 83 } |
83 | 84 |
84 ReplaceMessages(); | 85 ReplaceMessages(); |
85 | 86 |
86 original_peer_->OnReceivedResponse(response_info_, true); | 87 original_peer_->OnReceivedResponse(response_info_, true); |
87 if (!data_.empty()) | 88 if (!data_.empty()) |
88 original_peer_->OnReceivedData(data_.data(), | 89 original_peer_->OnReceivedData(data_.data(), |
89 static_cast<int>(data_.size())); | 90 static_cast<int>(data_.size())); |
(...skipping 22 matching lines...) Expand all Loading... |
112 | 113 |
113 l10n_messages = GetL10nMessagesMap(extension_id); | 114 l10n_messages = GetL10nMessagesMap(extension_id); |
114 } | 115 } |
115 | 116 |
116 std::string error; | 117 std::string error; |
117 if (ExtensionMessageBundle::ReplaceMessagesWithExternalDictionary( | 118 if (ExtensionMessageBundle::ReplaceMessagesWithExternalDictionary( |
118 *l10n_messages, &data_, &error)) { | 119 *l10n_messages, &data_, &error)) { |
119 data_.resize(data_.size()); | 120 data_.resize(data_.size()); |
120 } | 121 } |
121 } | 122 } |
OLD | NEW |