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 #ifndef CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_MESSAGE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_MESSAGE_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_MESSAGE_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_MESSAGE_HANDLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "components/offline_pages/core/background/request_coordinator.h" | 14 #include "components/offline_pages/core/background/request_coordinator.h" |
15 #include "components/offline_pages/core/background/save_page_request.h" | 15 #include "components/offline_pages/core/background/save_page_request.h" |
16 #include "components/offline_pages/core/offline_page_model.h" | 16 #include "components/offline_pages/core/offline_page_model.h" |
17 #include "components/offline_pages/core/offline_store_types.h" | 17 #include "components/offline_pages/core/offline_store_types.h" |
| 18 #include "components/offline_pages/core/prefetch/prefetch_types.h" |
18 #include "content/public/browser/web_ui_message_handler.h" | 19 #include "content/public/browser/web_ui_message_handler.h" |
19 | 20 |
20 namespace offline_pages { | 21 namespace offline_pages { |
21 class PrefetchService; | 22 class PrefetchService; |
22 enum class GetRequestsResult; | 23 enum class GetRequestsResult; |
| 24 class GeneratePageBundleRequest; |
| 25 class GetOperationRequest; |
23 } | 26 } |
24 | 27 |
25 namespace offline_internals { | 28 namespace offline_internals { |
26 | 29 |
27 // Class acting as a controller of the chrome://offline-internals WebUI. | 30 // Class acting as a controller of the chrome://offline-internals WebUI. |
28 class OfflineInternalsUIMessageHandler : public content::WebUIMessageHandler { | 31 class OfflineInternalsUIMessageHandler : public content::WebUIMessageHandler { |
29 public: | 32 public: |
30 OfflineInternalsUIMessageHandler(); | 33 OfflineInternalsUIMessageHandler(); |
31 ~OfflineInternalsUIMessageHandler() override; | 34 ~OfflineInternalsUIMessageHandler() override; |
32 | 35 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 69 |
67 // Load whether device is currently offline. | 70 // Load whether device is currently offline. |
68 void HandleGetNetworkStatus(const base::ListValue* args); | 71 void HandleGetNetworkStatus(const base::ListValue* args); |
69 | 72 |
70 // Schedules an NWake signal. | 73 // Schedules an NWake signal. |
71 void HandleScheduleNwake(const base::ListValue* args); | 74 void HandleScheduleNwake(const base::ListValue* args); |
72 | 75 |
73 // Cancels an NWake signal. | 76 // Cancels an NWake signal. |
74 void HandleCancelNwake(const base::ListValue* args); | 77 void HandleCancelNwake(const base::ListValue* args); |
75 | 78 |
| 79 // Sends and processes the request to generate page bundle. |
| 80 void HandleGeneratePageBundle(const base::ListValue* args); |
| 81 |
| 82 // Sends and processes a request to get the info about an operation. |
| 83 void HandleGetOperation(const base::ListValue* args); |
| 84 |
76 // Callback for async GetAllPages calls. | 85 // Callback for async GetAllPages calls. |
77 void HandleStoredPagesCallback( | 86 void HandleStoredPagesCallback( |
78 std::string callback_id, | 87 std::string callback_id, |
79 const offline_pages::MultipleOfflinePageItemResult& pages); | 88 const offline_pages::MultipleOfflinePageItemResult& pages); |
80 | 89 |
81 // Callback for async GetRequests calls. | 90 // Callback for async GetRequests calls. |
82 void HandleRequestQueueCallback( | 91 void HandleRequestQueueCallback( |
83 std::string callback_id, | 92 std::string callback_id, |
84 offline_pages::GetRequestsResult result, | 93 offline_pages::GetRequestsResult result, |
85 std::vector<std::unique_ptr<offline_pages::SavePageRequest>> requests); | 94 std::vector<std::unique_ptr<offline_pages::SavePageRequest>> requests); |
86 | 95 |
87 // Callback for DeletePage/DeleteAllPages calls. | 96 // Callback for DeletePage/DeleteAllPages calls. |
88 void HandleDeletedPagesCallback(std::string callback_id, | 97 void HandleDeletedPagesCallback(std::string callback_id, |
89 const offline_pages::DeletePageResult result); | 98 const offline_pages::DeletePageResult result); |
90 | 99 |
91 // Callback for DeleteRequest/DeleteAllRequests calls. | 100 // Callback for DeleteRequest/DeleteAllRequests calls. |
92 void HandleDeletedRequestsCallback( | 101 void HandleDeletedRequestsCallback( |
93 std::string callback_id, | 102 std::string callback_id, |
94 const offline_pages::MultipleItemStatuses& results); | 103 const offline_pages::MultipleItemStatuses& results); |
95 | 104 |
96 // Turns a DeletePageResult enum into logical string. | 105 // Callback for GeneratePageBundle/GetOperation request calls. |
97 std::string GetStringFromDeletePageResult( | 106 void HandlePrefetchRequestCallback( |
98 offline_pages::DeletePageResult value); | 107 std::string callback_id, |
| 108 offline_pages::PrefetchRequestStatus status, |
| 109 const std::string& operation_name, |
| 110 const std::vector<offline_pages::RenderPageInfo>& pages); |
99 | 111 |
100 // Summarizes the MultipleItemStatuses vector with a string. | 112 // Callback for GetOperation calls. |
101 std::string GetStringFromDeleteRequestResults( | 113 void HandleGetOperationCallback( |
102 const offline_pages::MultipleItemStatuses& result); | 114 std::string callback_id, |
103 | 115 offline_pages::PrefetchRequestStatus status, |
104 // Turns a SavePageRequest::Status into logical string. | 116 const std::vector<offline_pages::RenderPageInfo>& pages); |
105 std::string GetStringFromSavePageStatus(); | |
106 | 117 |
107 // Offline page model to call methods on. | 118 // Offline page model to call methods on. |
108 offline_pages::OfflinePageModel* offline_page_model_; | 119 offline_pages::OfflinePageModel* offline_page_model_; |
109 | 120 |
110 // Request coordinator for background offline actions. | 121 // Request coordinator for background offline actions. |
111 offline_pages::RequestCoordinator* request_coordinator_; | 122 offline_pages::RequestCoordinator* request_coordinator_; |
112 | 123 |
113 // Prefetch service for prefetching service logs and actions. | 124 // Prefetch service for prefetching service logs and actions. |
114 offline_pages::PrefetchService* prefetch_service_; | 125 offline_pages::PrefetchService* prefetch_service_; |
115 | 126 |
| 127 std::unique_ptr<offline_pages::GeneratePageBundleRequest> |
| 128 generate_page_bundle_request_; |
| 129 std::unique_ptr<offline_pages::GetOperationRequest> get_operation_request_; |
| 130 |
116 // Factory for creating references in callbacks. | 131 // Factory for creating references in callbacks. |
117 base::WeakPtrFactory<OfflineInternalsUIMessageHandler> weak_ptr_factory_; | 132 base::WeakPtrFactory<OfflineInternalsUIMessageHandler> weak_ptr_factory_; |
118 | 133 |
119 DISALLOW_COPY_AND_ASSIGN(OfflineInternalsUIMessageHandler); | 134 DISALLOW_COPY_AND_ASSIGN(OfflineInternalsUIMessageHandler); |
120 }; | 135 }; |
121 | 136 |
122 } // namespace offline_internals | 137 } // namespace offline_internals |
123 | 138 |
124 #endif // CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_MESSAGE_HANDLER_
H_ | 139 #endif // CHROME_BROWSER_UI_WEBUI_OFFLINE_OFFLINE_INTERNALS_UI_MESSAGE_HANDLER_
H_ |
OLD | NEW |