| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/browser/ui/webui/offline/offline_internals_ui_message_handler.h
" | 5 #include "chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h
" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 case offline_pages::DeletePageResult::NOT_FOUND: | 41 case offline_pages::DeletePageResult::NOT_FOUND: |
| 42 return "Not found"; | 42 return "Not found"; |
| 43 case offline_pages::DeletePageResult::RESULT_COUNT: | 43 case offline_pages::DeletePageResult::RESULT_COUNT: |
| 44 break; | 44 break; |
| 45 } | 45 } |
| 46 NOTREACHED(); | 46 NOTREACHED(); |
| 47 return "Unknown"; | 47 return "Unknown"; |
| 48 } | 48 } |
| 49 | 49 |
| 50 std::string OfflineInternalsUIMessageHandler::GetStringFromDeleteRequestResults( | 50 std::string OfflineInternalsUIMessageHandler::GetStringFromDeleteRequestResults( |
| 51 const offline_pages::RequestQueue::UpdateMultipleRequestResults& results) { | 51 const offline_pages::MultipleItemStatuses& results) { |
| 52 // If any requests failed, return "failure", else "success". | 52 // If any requests failed, return "failure", else "success". |
| 53 for (const auto& result : results) { | 53 for (const auto& result : results) { |
| 54 if (result.second == | 54 if (result.second == offline_pages::ItemActionStatus::STORE_ERROR) |
| 55 offline_pages::RequestQueue::UpdateRequestResult::STORE_FAILURE) { | |
| 56 return "Store failure, could not delete one or more requests"; | 55 return "Store failure, could not delete one or more requests"; |
| 57 } | |
| 58 } | 56 } |
| 59 | 57 |
| 60 return "Success"; | 58 return "Success"; |
| 61 } | 59 } |
| 62 | 60 |
| 63 std::string OfflineInternalsUIMessageHandler::GetStringFromSavePageStatus() { | 61 std::string OfflineInternalsUIMessageHandler::GetStringFromSavePageStatus() { |
| 64 return "Available"; | 62 return "Available"; |
| 65 } | 63 } |
| 66 | 64 |
| 67 void OfflineInternalsUIMessageHandler::HandleDeleteSelectedPages( | 65 void OfflineInternalsUIMessageHandler::HandleDeleteSelectedPages( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void OfflineInternalsUIMessageHandler::HandleDeletedPagesCallback( | 115 void OfflineInternalsUIMessageHandler::HandleDeletedPagesCallback( |
| 118 std::string callback_id, | 116 std::string callback_id, |
| 119 offline_pages::DeletePageResult result) { | 117 offline_pages::DeletePageResult result) { |
| 120 ResolveJavascriptCallback( | 118 ResolveJavascriptCallback( |
| 121 base::StringValue(callback_id), | 119 base::StringValue(callback_id), |
| 122 base::StringValue(GetStringFromDeletePageResult(result))); | 120 base::StringValue(GetStringFromDeletePageResult(result))); |
| 123 } | 121 } |
| 124 | 122 |
| 125 void OfflineInternalsUIMessageHandler::HandleDeletedRequestsCallback( | 123 void OfflineInternalsUIMessageHandler::HandleDeletedRequestsCallback( |
| 126 std::string callback_id, | 124 std::string callback_id, |
| 127 const offline_pages::RequestQueue::UpdateMultipleRequestResults& results) { | 125 const offline_pages::MultipleItemStatuses& results) { |
| 128 ResolveJavascriptCallback( | 126 ResolveJavascriptCallback( |
| 129 base::StringValue(callback_id), | 127 base::StringValue(callback_id), |
| 130 base::StringValue(GetStringFromDeleteRequestResults(results))); | 128 base::StringValue(GetStringFromDeleteRequestResults(results))); |
| 131 } | 129 } |
| 132 | 130 |
| 133 void OfflineInternalsUIMessageHandler::HandleStoredPagesCallback( | 131 void OfflineInternalsUIMessageHandler::HandleStoredPagesCallback( |
| 134 std::string callback_id, | 132 std::string callback_id, |
| 135 const offline_pages::MultipleOfflinePageItemResult& pages) { | 133 const offline_pages::MultipleOfflinePageItemResult& pages) { |
| 136 base::ListValue results; | 134 base::ListValue results; |
| 137 | 135 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 338 |
| 341 // Get the offline page model associated with this web ui. | 339 // Get the offline page model associated with this web ui. |
| 342 Profile* profile = Profile::FromWebUI(web_ui()); | 340 Profile* profile = Profile::FromWebUI(web_ui()); |
| 343 offline_page_model_ = | 341 offline_page_model_ = |
| 344 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile); | 342 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile); |
| 345 request_coordinator_ = | 343 request_coordinator_ = |
| 346 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile); | 344 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile); |
| 347 } | 345 } |
| 348 | 346 |
| 349 } // namespace offline_internals | 347 } // namespace offline_internals |
| OLD | NEW |