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 271b4af6747a41ddfa725508333732d1a86ce72d..e6c73198f52ccd098883aaf6e7e00fbbd1ceec0f 100644 |
--- a/components/offline_pages/downloads/download_notifying_observer.cc |
+++ b/components/offline_pages/downloads/download_notifying_observer.cc |
@@ -4,13 +4,22 @@ |
#include "components/offline_pages/downloads/download_notifying_observer.h" |
+#include "base/guid.h" |
#include "components/offline_pages/background/request_coordinator.h" |
#include "components/offline_pages/background/save_page_request.h" |
+#include "components/offline_pages/client_namespace_constants.h" |
#include "components/offline_pages/downloads/offline_page_download_notifier.h" |
namespace offline_pages { |
namespace { |
int kUserDataKey; // Only address is used. |
+ |
+bool IsVisibleInUI(const ClientId& client_id) { |
Dmitry Titov
2016/08/30 16:35:09
Any reason not to make this function public static
dewittj
2016/08/30 16:52:24
Done.
|
+ const std::string& name_space = client_id.name_space; |
+ return (name_space == kAsyncNamespace || name_space == kDownloadNamespace) && |
+ base::IsValidGUID(client_id.id); |
+} |
+ |
} // namespace |
DownloadNotifyingObserver::DownloadNotifyingObserver( |
@@ -42,11 +51,15 @@ void DownloadNotifyingObserver::CreateAndStartObserving( |
void DownloadNotifyingObserver::OnAdded(const SavePageRequest& request) { |
DCHECK(notifier_.get()); |
+ if (!IsVisibleInUI(request.client_id())) |
+ return; |
notifier_->NotifyDownloadProgress(DownloadUIItem(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 |
@@ -57,6 +70,8 @@ void DownloadNotifyingObserver::OnCompleted( |
const SavePageRequest& request, |
RequestCoordinator::SavePageStatus status) { |
DCHECK(notifier_.get()); |
+ if (!IsVisibleInUI(request.client_id())) |
+ return; |
if (status == RequestCoordinator::SavePageStatus::SUCCESS) |
notifier_->NotifyDownloadSuccessful(DownloadUIItem(request)); |
else if (status == RequestCoordinator::SavePageStatus::REMOVED) |