| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/appcache/appcache_internals_ui.h" | 5 #include "content/browser/appcache/appcache_internals_ui.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 } | 415 } |
| 416 | 416 |
| 417 void AppCacheInternalsUI::OnAllAppCacheInfoReady( | 417 void AppCacheInternalsUI::OnAllAppCacheInfoReady( |
| 418 scoped_refptr<AppCacheInfoCollection> collection, | 418 scoped_refptr<AppCacheInfoCollection> collection, |
| 419 const base::FilePath& partition_path) { | 419 const base::FilePath& partition_path) { |
| 420 std::string incognito_path_prefix; | 420 std::string incognito_path_prefix; |
| 421 if (browser_context()->IsOffTheRecord()) | 421 if (browser_context()->IsOffTheRecord()) |
| 422 incognito_path_prefix = "Incognito "; | 422 incognito_path_prefix = "Incognito "; |
| 423 web_ui()->CallJavascriptFunctionUnsafe( | 423 web_ui()->CallJavascriptFunctionUnsafe( |
| 424 kFunctionOnAllAppCacheInfoReady, | 424 kFunctionOnAllAppCacheInfoReady, |
| 425 base::StringValue(incognito_path_prefix + partition_path.AsUTF8Unsafe()), | 425 base::Value(incognito_path_prefix + partition_path.AsUTF8Unsafe()), |
| 426 *GetListValueFromAppCacheInfoCollection(collection.get())); | 426 *GetListValueFromAppCacheInfoCollection(collection.get())); |
| 427 } | 427 } |
| 428 | 428 |
| 429 void AppCacheInternalsUI::OnAppCacheInfoDeleted( | 429 void AppCacheInternalsUI::OnAppCacheInfoDeleted( |
| 430 const base::FilePath& partition_path, | 430 const base::FilePath& partition_path, |
| 431 const std::string& manifest_url, | 431 const std::string& manifest_url, |
| 432 bool deleted) { | 432 bool deleted) { |
| 433 web_ui()->CallJavascriptFunctionUnsafe( | 433 web_ui()->CallJavascriptFunctionUnsafe( |
| 434 kFunctionOnAppCacheInfoDeleted, | 434 kFunctionOnAppCacheInfoDeleted, |
| 435 base::StringValue(partition_path.AsUTF8Unsafe()), | 435 base::Value(partition_path.AsUTF8Unsafe()), base::Value(manifest_url), |
| 436 base::StringValue(manifest_url), base::Value(deleted)); | 436 base::Value(deleted)); |
| 437 } | 437 } |
| 438 | 438 |
| 439 void AppCacheInternalsUI::OnAppCacheDetailsReady( | 439 void AppCacheInternalsUI::OnAppCacheDetailsReady( |
| 440 const base::FilePath& partition_path, | 440 const base::FilePath& partition_path, |
| 441 const std::string& manifest_url, | 441 const std::string& manifest_url, |
| 442 std::unique_ptr<AppCacheResourceInfoVector> resource_info_vector) { | 442 std::unique_ptr<AppCacheResourceInfoVector> resource_info_vector) { |
| 443 if (resource_info_vector) { | 443 if (resource_info_vector) { |
| 444 web_ui()->CallJavascriptFunctionUnsafe( | 444 web_ui()->CallJavascriptFunctionUnsafe( |
| 445 kFunctionOnAppCacheDetailsReady, base::StringValue(manifest_url), | 445 kFunctionOnAppCacheDetailsReady, base::Value(manifest_url), |
| 446 base::StringValue(partition_path.AsUTF8Unsafe()), | 446 base::Value(partition_path.AsUTF8Unsafe()), |
| 447 *GetListValueForAppCacheResourceInfoVector(resource_info_vector.get())); | 447 *GetListValueForAppCacheResourceInfoVector(resource_info_vector.get())); |
| 448 } else { | 448 } else { |
| 449 web_ui()->CallJavascriptFunctionUnsafe( | 449 web_ui()->CallJavascriptFunctionUnsafe( |
| 450 kFunctionOnAppCacheDetailsReady, base::StringValue(manifest_url), | 450 kFunctionOnAppCacheDetailsReady, base::Value(manifest_url), |
| 451 base::StringValue(partition_path.AsUTF8Unsafe())); | 451 base::Value(partition_path.AsUTF8Unsafe())); |
| 452 } | 452 } |
| 453 } | 453 } |
| 454 | 454 |
| 455 void AppCacheInternalsUI::OnFileDetailsReady( | 455 void AppCacheInternalsUI::OnFileDetailsReady( |
| 456 const Proxy::ResponseEnquiry& response_enquiry, | 456 const Proxy::ResponseEnquiry& response_enquiry, |
| 457 scoped_refptr<AppCacheResponseInfo> response_info, | 457 scoped_refptr<AppCacheResponseInfo> response_info, |
| 458 scoped_refptr<net::IOBuffer> response_data, | 458 scoped_refptr<net::IOBuffer> response_data, |
| 459 int data_length) { | 459 int data_length) { |
| 460 std::string headers; | 460 std::string headers; |
| 461 if (response_info->http_response_info()) { | 461 if (response_info->http_response_info()) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 480 std::string hex_dump = base::StringPrintf( | 480 std::string hex_dump = base::StringPrintf( |
| 481 "<hr><pre> Showing %d of %d bytes\n\n", static_cast<int>(data_length), | 481 "<hr><pre> Showing %d of %d bytes\n\n", static_cast<int>(data_length), |
| 482 static_cast<int>(response_info->response_data_size())); | 482 static_cast<int>(response_info->response_data_size())); |
| 483 net::ViewCacheHelper::HexDump(response_data->data(), data_length, &hex_dump); | 483 net::ViewCacheHelper::HexDump(response_data->data(), data_length, &hex_dump); |
| 484 if (data_length < response_info->response_data_size()) | 484 if (data_length < response_info->response_data_size()) |
| 485 hex_dump.append("\nNote: data is truncated..."); | 485 hex_dump.append("\nNote: data is truncated..."); |
| 486 hex_dump.append("</pre>"); | 486 hex_dump.append("</pre>"); |
| 487 web_ui()->CallJavascriptFunctionUnsafe( | 487 web_ui()->CallJavascriptFunctionUnsafe( |
| 488 kFunctionOnFileDetailsReady, | 488 kFunctionOnFileDetailsReady, |
| 489 *GetDictionaryValueForResponseEnquiry(response_enquiry), | 489 *GetDictionaryValueForResponseEnquiry(response_enquiry), |
| 490 base::StringValue(headers), base::StringValue(hex_dump)); | 490 base::Value(headers), base::Value(hex_dump)); |
| 491 } | 491 } |
| 492 | 492 |
| 493 void AppCacheInternalsUI::OnFileDetailsFailed( | 493 void AppCacheInternalsUI::OnFileDetailsFailed( |
| 494 const Proxy::ResponseEnquiry& response_enquiry, | 494 const Proxy::ResponseEnquiry& response_enquiry, |
| 495 int net_result_code) { | 495 int net_result_code) { |
| 496 web_ui()->CallJavascriptFunctionUnsafe( | 496 web_ui()->CallJavascriptFunctionUnsafe( |
| 497 kFunctionOnFileDetailsFailed, | 497 kFunctionOnFileDetailsFailed, |
| 498 *GetDictionaryValueForResponseEnquiry(response_enquiry), | 498 *GetDictionaryValueForResponseEnquiry(response_enquiry), |
| 499 base::Value(net_result_code)); | 499 base::Value(net_result_code)); |
| 500 } | 500 } |
| 501 | 501 |
| 502 AppCacheInternalsUI::Proxy* AppCacheInternalsUI::GetProxyForPartitionPath( | 502 AppCacheInternalsUI::Proxy* AppCacheInternalsUI::GetProxyForPartitionPath( |
| 503 const base::FilePath& partition_path) { | 503 const base::FilePath& partition_path) { |
| 504 for (const scoped_refptr<Proxy>& proxy : appcache_proxies_) { | 504 for (const scoped_refptr<Proxy>& proxy : appcache_proxies_) { |
| 505 if (proxy->partition_path_ == partition_path) | 505 if (proxy->partition_path_ == partition_path) |
| 506 return proxy.get(); | 506 return proxy.get(); |
| 507 } | 507 } |
| 508 NOTREACHED(); | 508 NOTREACHED(); |
| 509 return nullptr; | 509 return nullptr; |
| 510 } | 510 } |
| 511 | 511 |
| 512 } // namespace content | 512 } // namespace content |
| OLD | NEW |