Chromium Code Reviews| 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/downloads/download_ui_adapter.h" | 5 #include "components/offline_pages/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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 --observers_count_; | 73 --observers_count_; |
| 74 // Once the last observer is gone, clear cached data. | 74 // Once the last observer is gone, clear cached data. |
| 75 if (observers_count_ == 0) | 75 if (observers_count_ == 0) |
| 76 ClearCache(); | 76 ClearCache(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void DownloadUIAdapter::OfflinePageModelLoaded(OfflinePageModel* model) { | 79 void DownloadUIAdapter::OfflinePageModelLoaded(OfflinePageModel* model) { |
| 80 // This signal is not used here. | 80 // This signal is not used here. |
| 81 } | 81 } |
| 82 | 82 |
| 83 void DownloadUIAdapter::OfflinePageModelChanged(OfflinePageModel* model) { | 83 void DownloadUIAdapter::OfflinePageAdded(OfflinePageModel* model, |
| 84 const OfflinePageItem& added_page) { | |
| 84 DCHECK(model == model_); | 85 DCHECK(model == model_); |
| 85 model_->GetAllPages( | 86 model_->GetAllPages( |
|
Dmitry Titov
2016/11/15 20:02:30
Now the impl of this should change to do a direct
dewittj
2016/11/15 23:54:19
I had that in here before (see patchset #2), but i
| |
| 86 base::Bind(&DownloadUIAdapter::OnOfflinePagesChanged, | 87 base::Bind(&DownloadUIAdapter::OnOfflinePagesChanged, |
| 87 weak_ptr_factory_.GetWeakPtr())); | 88 weak_ptr_factory_.GetWeakPtr())); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void DownloadUIAdapter::OfflinePageDeleted( | 91 void DownloadUIAdapter::OfflinePageDeleted( |
| 91 int64_t offline_id, const ClientId& client_id) { | 92 int64_t offline_id, const ClientId& client_id) { |
| 92 if (!IsVisibleInUI(client_id)) | 93 if (!IsVisibleInUI(client_id)) |
| 93 return; | 94 return; |
| 94 std::string guid = client_id.id; | 95 std::string guid = client_id.id; |
| 95 DownloadUIItems::const_iterator it = items_.find(guid); | 96 DownloadUIItems::const_iterator it = items_.find(guid); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 // TODO(dimich): Consider adding UMA to record user actions. | 212 // TODO(dimich): Consider adding UMA to record user actions. |
| 212 } | 213 } |
| 213 | 214 |
| 214 bool DownloadUIAdapter::IsVisibleInUI(const ClientId& client_id) { | 215 bool DownloadUIAdapter::IsVisibleInUI(const ClientId& client_id) { |
| 215 const std::string& name_space = client_id.name_space; | 216 const std::string& name_space = client_id.name_space; |
| 216 return model_->GetPolicyController()->IsSupportedByDownload(name_space) && | 217 return model_->GetPolicyController()->IsSupportedByDownload(name_space) && |
| 217 base::IsValidGUID(client_id.id); | 218 base::IsValidGUID(client_id.id); |
| 218 } | 219 } |
| 219 | 220 |
| 220 } // namespace offline_pages | 221 } // namespace offline_pages |
| OLD | NEW |