Chromium Code Reviews| Index: components/offline_pages/downloads/download_notifying_observer.cc |
| diff --git a/components/offline_pages/downloads/download_notifying_observer.cc b/components/offline_pages/downloads/download_notifying_observer.cc |
| index 397bcc975a867fbd9fff675cb620921857ca9662..9647edf655e7f920c801ec58bd7779ba05170ebd 100644 |
| --- a/components/offline_pages/downloads/download_notifying_observer.cc |
| +++ b/components/offline_pages/downloads/download_notifying_observer.cc |
| @@ -47,17 +47,21 @@ void DownloadNotifyingObserver::OnAdded(const SavePageRequest& request) { |
| DCHECK(notifier_.get()); |
| if (!IsVisibleInUI(request.client_id())) |
| return; |
| + |
| + // Calling Progress ensures notification is created in lieu of specific |
| + // Add/Create call. |
| notifier_->NotifyDownloadProgress(DownloadUIItem(request)); |
| + |
| + // Now we need to update the notification if it is not active/offlining. |
| + if (request.request_state() != SavePageRequest::RequestState::OFFLINING) |
| + NotifyRequestStateChange(request); |
| } |
| void DownloadNotifyingObserver::OnChanged(const SavePageRequest& request) { |
| DCHECK(notifier_.get()); |
| if (!IsVisibleInUI(request.client_id())) |
| return; |
| - if (request.request_state() == SavePageRequest::RequestState::PAUSED) |
| - notifier_->NotifyDownloadPaused(DownloadUIItem(request)); |
| - else |
| - notifier_->NotifyDownloadProgress(DownloadUIItem(request)); |
| + NotifyRequestStateChange(request); |
| } |
| void DownloadNotifyingObserver::OnCompleted( |
| @@ -79,4 +83,14 @@ bool DownloadNotifyingObserver::IsVisibleInUI(const ClientId& page) { |
| base::IsValidGUID(page.id); |
| } |
| +void DownloadNotifyingObserver::NotifyRequestStateChange( |
| + const SavePageRequest& request) { |
| + if (request.request_state() == SavePageRequest::RequestState::PAUSED) |
| + notifier_->NotifyDownloadPaused(DownloadUIItem(request)); |
| + else if (request.request_state() == SavePageRequest::RequestState::AVAILABLE) |
|
Pete Williamson
2016/11/29 23:26:16
Why does available imply interrupted? Does this o
dougarnett
2016/11/29 23:57:36
Done. Added method comment plus interface comments
|
| + notifier_->NotifyDownloadInterrupted(DownloadUIItem(request)); |
| + else |
| + notifier_->NotifyDownloadProgress(DownloadUIItem(request)); |
| +} |
| + |
| } // namespace offline_pages |