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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 base::DictionaryValue* offline_page = new base::DictionaryValue(); | 137 base::DictionaryValue* offline_page = new base::DictionaryValue(); |
138 results.Append(offline_page); | 138 results.Append(offline_page); |
139 offline_page->SetString("onlineUrl", page.url.spec()); | 139 offline_page->SetString("onlineUrl", page.url.spec()); |
140 offline_page->SetString("namespace", page.client_id.name_space); | 140 offline_page->SetString("namespace", page.client_id.name_space); |
141 offline_page->SetDouble("size", page.file_size); | 141 offline_page->SetDouble("size", page.file_size); |
142 offline_page->SetString("id", std::to_string(page.offline_id)); | 142 offline_page->SetString("id", std::to_string(page.offline_id)); |
143 offline_page->SetString("filePath", page.file_path.MaybeAsASCII()); | 143 offline_page->SetString("filePath", page.file_path.MaybeAsASCII()); |
144 offline_page->SetDouble("creationTime", page.creation_time.ToJsTime()); | 144 offline_page->SetDouble("creationTime", page.creation_time.ToJsTime()); |
145 offline_page->SetDouble("lastAccessTime", page.last_access_time.ToJsTime()); | 145 offline_page->SetDouble("lastAccessTime", page.last_access_time.ToJsTime()); |
146 offline_page->SetInteger("accessCount", page.access_count); | 146 offline_page->SetInteger("accessCount", page.access_count); |
147 offline_page->SetString("isExpired", page.IsExpired() ? "Yes" : "No"); | |
148 offline_page->SetString("originalUrl", page.original_url.spec()); | 147 offline_page->SetString("originalUrl", page.original_url.spec()); |
149 } | 148 } |
150 ResolveJavascriptCallback(base::StringValue(callback_id), results); | 149 ResolveJavascriptCallback(base::StringValue(callback_id), results); |
151 } | 150 } |
152 | 151 |
153 void OfflineInternalsUIMessageHandler::HandleRequestQueueCallback( | 152 void OfflineInternalsUIMessageHandler::HandleRequestQueueCallback( |
154 std::string callback_id, | 153 std::string callback_id, |
155 offline_pages::GetRequestsResult result, | 154 offline_pages::GetRequestsResult result, |
156 std::vector<std::unique_ptr<offline_pages::SavePageRequest>> requests) { | 155 std::vector<std::unique_ptr<offline_pages::SavePageRequest>> requests) { |
157 base::ListValue save_page_requests; | 156 base::ListValue save_page_requests; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 188 } |
190 } | 189 } |
191 | 190 |
192 void OfflineInternalsUIMessageHandler::HandleGetStoredPages( | 191 void OfflineInternalsUIMessageHandler::HandleGetStoredPages( |
193 const base::ListValue* args) { | 192 const base::ListValue* args) { |
194 AllowJavascript(); | 193 AllowJavascript(); |
195 std::string callback_id; | 194 std::string callback_id; |
196 CHECK(args->GetString(0, &callback_id)); | 195 CHECK(args->GetString(0, &callback_id)); |
197 | 196 |
198 if (offline_page_model_) { | 197 if (offline_page_model_) { |
199 offline_page_model_->GetAllPagesWithExpired( | 198 offline_page_model_->GetAllPages( |
200 base::Bind(&OfflineInternalsUIMessageHandler::HandleStoredPagesCallback, | 199 base::Bind(&OfflineInternalsUIMessageHandler::HandleStoredPagesCallback, |
201 weak_ptr_factory_.GetWeakPtr(), callback_id)); | 200 weak_ptr_factory_.GetWeakPtr(), callback_id)); |
202 } else { | 201 } else { |
203 base::ListValue results; | 202 base::ListValue results; |
204 ResolveJavascriptCallback(base::StringValue(callback_id), results); | 203 ResolveJavascriptCallback(base::StringValue(callback_id), results); |
205 } | 204 } |
206 } | 205 } |
207 | 206 |
208 void OfflineInternalsUIMessageHandler::HandleSetRecordPageModel( | 207 void OfflineInternalsUIMessageHandler::HandleSetRecordPageModel( |
209 const base::ListValue* args) { | 208 const base::ListValue* args) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 339 |
341 // Get the offline page model associated with this web ui. | 340 // Get the offline page model associated with this web ui. |
342 Profile* profile = Profile::FromWebUI(web_ui()); | 341 Profile* profile = Profile::FromWebUI(web_ui()); |
343 offline_page_model_ = | 342 offline_page_model_ = |
344 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile); | 343 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile); |
345 request_coordinator_ = | 344 request_coordinator_ = |
346 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile); | 345 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile); |
347 } | 346 } |
348 | 347 |
349 } // namespace offline_internals | 348 } // namespace offline_internals |
OLD | NEW |