| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 CHECK(args->GetString(1, &url)); | 280 CHECK(args->GetString(1, &url)); |
| 281 | 281 |
| 282 // To be visible in Downloads UI, these items need a well-formed GUID | 282 // To be visible in Downloads UI, these items need a well-formed GUID |
| 283 // and AsyncNamespace in their ClientId. | 283 // and AsyncNamespace in their ClientId. |
| 284 std::ostringstream id_stream; | 284 std::ostringstream id_stream; |
| 285 id_stream << base::GenerateGUID(); | 285 id_stream << base::GenerateGUID(); |
| 286 | 286 |
| 287 ResolveJavascriptCallback( | 287 ResolveJavascriptCallback( |
| 288 *callback_id, | 288 *callback_id, |
| 289 base::FundamentalValue(request_coordinator_->SavePageLater( | 289 base::FundamentalValue(request_coordinator_->SavePageLater( |
| 290 GURL(url), offline_pages::ClientId(offline_pages::kAsyncNamespace, | 290 GURL(url), offline_pages::ClientId( |
| 291 id_stream.str()), | 291 offline_pages::kAsyncNamespace, id_stream.str()), |
| 292 true))); | 292 true, offline_pages::RequestCoordinator::RequestAvailability:: |
| 293 ENABLED_FOR_OFFLINER) > 0)); |
| 293 } else { | 294 } else { |
| 294 ResolveJavascriptCallback(*callback_id, base::FundamentalValue(false)); | 295 ResolveJavascriptCallback(*callback_id, base::FundamentalValue(false)); |
| 295 } | 296 } |
| 296 } | 297 } |
| 297 | 298 |
| 298 void OfflineInternalsUIMessageHandler::RegisterMessages() { | 299 void OfflineInternalsUIMessageHandler::RegisterMessages() { |
| 299 web_ui()->RegisterMessageCallback( | 300 web_ui()->RegisterMessageCallback( |
| 300 "deleteSelectedPages", | 301 "deleteSelectedPages", |
| 301 base::Bind(&OfflineInternalsUIMessageHandler::HandleDeleteSelectedPages, | 302 base::Bind(&OfflineInternalsUIMessageHandler::HandleDeleteSelectedPages, |
| 302 weak_ptr_factory_.GetWeakPtr())); | 303 weak_ptr_factory_.GetWeakPtr())); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 341 |
| 341 // Get the offline page model associated with this web ui. | 342 // Get the offline page model associated with this web ui. |
| 342 Profile* profile = Profile::FromWebUI(web_ui()); | 343 Profile* profile = Profile::FromWebUI(web_ui()); |
| 343 offline_page_model_ = | 344 offline_page_model_ = |
| 344 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile); | 345 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile); |
| 345 request_coordinator_ = | 346 request_coordinator_ = |
| 346 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile); | 347 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile); |
| 347 } | 348 } |
| 348 | 349 |
| 349 } // namespace offline_internals | 350 } // namespace offline_internals |
| OLD | NEW |