| 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 "components/offline_pages/core/downloads/download_ui_adapter.h" | 5 #include "components/offline_pages/core/downloads/download_ui_adapter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/guid.h" | 8 #include "base/guid.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 --observers_count_; | 72 --observers_count_; |
| 73 // Once the last observer is gone, clear cached data. | 73 // Once the last observer is gone, clear cached data. |
| 74 if (observers_count_ == 0) | 74 if (observers_count_ == 0) |
| 75 ClearCache(); | 75 ClearCache(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void DownloadUIAdapter::OfflinePageModelLoaded(OfflinePageModel* model) { | 78 void DownloadUIAdapter::OfflinePageModelLoaded(OfflinePageModel* model) { |
| 79 // This signal is not used here. | 79 // This signal is not used here. |
| 80 } | 80 } |
| 81 | 81 |
| 82 void DownloadUIAdapter::OfflinePageModelChanged(OfflinePageModel* model) { | 82 void DownloadUIAdapter::OfflinePageAdded(OfflinePageModel* model, |
| 83 const OfflinePageItem& added_page) { |
| 83 DCHECK(model == model_); | 84 DCHECK(model == model_); |
| 84 model_->GetAllPages(base::Bind(&DownloadUIAdapter::OnOfflinePagesChanged, | 85 model_->GetAllPages(base::Bind(&DownloadUIAdapter::OnOfflinePagesChanged, |
| 85 weak_ptr_factory_.GetWeakPtr())); | 86 weak_ptr_factory_.GetWeakPtr())); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void DownloadUIAdapter::OfflinePageDeleted(int64_t offline_id, | 89 void DownloadUIAdapter::OfflinePageDeleted(int64_t offline_id, |
| 89 const ClientId& client_id) { | 90 const ClientId& client_id) { |
| 90 if (!IsVisibleInUI(client_id)) | 91 if (!IsVisibleInUI(client_id)) |
| 91 return; | 92 return; |
| 92 std::string guid = client_id.id; | 93 std::string guid = client_id.id; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // TODO(dimich): Consider adding UMA to record user actions. | 205 // TODO(dimich): Consider adding UMA to record user actions. |
| 205 } | 206 } |
| 206 | 207 |
| 207 bool DownloadUIAdapter::IsVisibleInUI(const ClientId& client_id) { | 208 bool DownloadUIAdapter::IsVisibleInUI(const ClientId& client_id) { |
| 208 const std::string& name_space = client_id.name_space; | 209 const std::string& name_space = client_id.name_space; |
| 209 return model_->GetPolicyController()->IsSupportedByDownload(name_space) && | 210 return model_->GetPolicyController()->IsSupportedByDownload(name_space) && |
| 210 base::IsValidGUID(client_id.id); | 211 base::IsValidGUID(client_id.id); |
| 211 } | 212 } |
| 212 | 213 |
| 213 } // namespace offline_pages | 214 } // namespace offline_pages |
| OLD | NEW |