OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/blob/view_blob_internals_job.h" | 5 #include "webkit/blob/view_blob_internals_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/i18n/number_formatting.h" | 10 #include "base/i18n/number_formatting.h" |
11 #include "base/i18n/time_formatting.h" | 11 #include "base/i18n/time_formatting.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "net/base/escape.h" | 17 #include "net/base/escape.h" |
| 18 #include "net/base/net_errors.h" |
18 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
19 #include "webkit/blob/blob_data.h" | 20 #include "webkit/blob/blob_data.h" |
20 #include "webkit/blob/blob_storage_controller.h" | 21 #include "webkit/blob/blob_storage_controller.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 const char kEmptyBlobStorageMessage[] = "No available blob data."; | 25 const char kEmptyBlobStorageMessage[] = "No available blob data."; |
25 const char kRemove[] = "Remove"; | 26 const char kRemove[] = "Remove"; |
26 const char kContentType[] = "Content Type: "; | 27 const char kContentType[] = "Content Type: "; |
27 const char kContentDisposition[] = "Content Disposition: "; | 28 const char kContentDisposition[] = "Content Disposition: "; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 StartsWithASCII(request_->url().query(), "remove=", true)) { | 136 StartsWithASCII(request_->url().query(), "remove=", true)) { |
136 std::string blob_url = request_->url().query().substr(strlen("remove=")); | 137 std::string blob_url = request_->url().query().substr(strlen("remove=")); |
137 blob_url = net::UnescapeURLComponent(blob_url, | 138 blob_url = net::UnescapeURLComponent(blob_url, |
138 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS); | 139 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS); |
139 blob_storage_controller_->RemoveBlob(GURL(blob_url)); | 140 blob_storage_controller_->RemoveBlob(GURL(blob_url)); |
140 } | 141 } |
141 | 142 |
142 StartAsync(); | 143 StartAsync(); |
143 } | 144 } |
144 | 145 |
145 bool ViewBlobInternalsJob::GetData(std::string* mime_type, | 146 int ViewBlobInternalsJob::GetData( |
146 std::string* charset, | 147 std::string* mime_type, |
147 std::string* data) const { | 148 std::string* charset, |
| 149 std::string* data, |
| 150 const net::CompletionCallback& callback) const { |
148 mime_type->assign("text/html"); | 151 mime_type->assign("text/html"); |
149 charset->assign("UTF-8"); | 152 charset->assign("UTF-8"); |
150 | 153 |
151 data->clear(); | 154 data->clear(); |
152 StartHTML(data); | 155 StartHTML(data); |
153 if (blob_storage_controller_->blob_map_.empty()) | 156 if (blob_storage_controller_->blob_map_.empty()) |
154 data->append(kEmptyBlobStorageMessage); | 157 data->append(kEmptyBlobStorageMessage); |
155 else | 158 else |
156 GenerateHTML(data); | 159 GenerateHTML(data); |
157 EndHTML(data); | 160 EndHTML(data); |
158 return true; | 161 return net::OK; |
159 } | 162 } |
160 | 163 |
161 void ViewBlobInternalsJob::GenerateHTML(std::string* out) const { | 164 void ViewBlobInternalsJob::GenerateHTML(std::string* out) const { |
162 for (BlobStorageController::BlobMap::const_iterator iter = | 165 for (BlobStorageController::BlobMap::const_iterator iter = |
163 blob_storage_controller_->blob_map_.begin(); | 166 blob_storage_controller_->blob_map_.begin(); |
164 iter != blob_storage_controller_->blob_map_.end(); | 167 iter != blob_storage_controller_->blob_map_.end(); |
165 ++iter) { | 168 ++iter) { |
166 AddHTMLBoldText(iter->first, out); | 169 AddHTMLBoldText(iter->first, out); |
167 AddHTMLButton(kRemove, iter->first, out); | 170 AddHTMLButton(kRemove, iter->first, out); |
168 GenerateHTMLForBlobData(*iter->second, out); | 171 GenerateHTMLForBlobData(*iter->second, out); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 229 } |
227 | 230 |
228 if (has_multi_items) | 231 if (has_multi_items) |
229 EndHTMLList(out); | 232 EndHTMLList(out); |
230 } | 233 } |
231 | 234 |
232 EndHTMLList(out); | 235 EndHTMLList(out); |
233 } | 236 } |
234 | 237 |
235 } // namespace webkit_blob | 238 } // namespace webkit_blob |
OLD | NEW |