Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: components/offline_pages/downloads/download_notifying_observer.cc

Issue 2342443006: [Offline pages] Use the new policy bits (Closed)
Patch Set: i think i got it! Made sure it compiles Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 c399065e168e98125965a3500f8a24c55c14bb54..397bcc975a867fbd9fff675cb620921857ca9662 100644
--- a/components/offline_pages/downloads/download_notifying_observer.cc
+++ b/components/offline_pages/downloads/download_notifying_observer.cc
@@ -6,6 +6,7 @@
#include "components/offline_pages/background/request_coordinator.h"
#include "components/offline_pages/background/save_page_request.h"
+#include "components/offline_pages/client_policy_controller.h"
#include "components/offline_pages/downloads/download_ui_adapter.h"
#include "components/offline_pages/downloads/offline_page_download_notifier.h"
@@ -15,8 +16,9 @@ int kUserDataKey; // Only address is used.
} // namespace
DownloadNotifyingObserver::DownloadNotifyingObserver(
- std::unique_ptr<OfflinePageDownloadNotifier> notifier)
- : notifier_(std::move(notifier)) {}
+ std::unique_ptr<OfflinePageDownloadNotifier> notifier,
+ ClientPolicyController* policy_controller)
+ : notifier_(std::move(notifier)), policy_controller_(policy_controller) {}
DownloadNotifyingObserver::~DownloadNotifyingObserver() {}
@@ -34,8 +36,8 @@ void DownloadNotifyingObserver::CreateAndStartObserving(
std::unique_ptr<OfflinePageDownloadNotifier> notifier) {
DCHECK(request_coordinator);
DCHECK(notifier.get());
- DownloadNotifyingObserver* observer =
- new DownloadNotifyingObserver(std::move(notifier));
+ DownloadNotifyingObserver* observer = new DownloadNotifyingObserver(
+ std::move(notifier), request_coordinator->GetPolicyController());
request_coordinator->AddObserver(observer);
// |request_coordinator| takes ownership of observer here.
request_coordinator->SetUserData(&kUserDataKey, observer);
@@ -43,14 +45,14 @@ void DownloadNotifyingObserver::CreateAndStartObserving(
void DownloadNotifyingObserver::OnAdded(const SavePageRequest& request) {
DCHECK(notifier_.get());
- if (!DownloadUIAdapter::IsVisibleInUI(request.client_id()))
+ if (!IsVisibleInUI(request.client_id()))
return;
notifier_->NotifyDownloadProgress(DownloadUIItem(request));
}
void DownloadNotifyingObserver::OnChanged(const SavePageRequest& request) {
DCHECK(notifier_.get());
- if (!DownloadUIAdapter::IsVisibleInUI(request.client_id()))
+ if (!IsVisibleInUI(request.client_id()))
return;
if (request.request_state() == SavePageRequest::RequestState::PAUSED)
notifier_->NotifyDownloadPaused(DownloadUIItem(request));
@@ -62,7 +64,7 @@ void DownloadNotifyingObserver::OnCompleted(
const SavePageRequest& request,
RequestCoordinator::BackgroundSavePageResult status) {
DCHECK(notifier_.get());
- if (!DownloadUIAdapter::IsVisibleInUI(request.client_id()))
+ if (!IsVisibleInUI(request.client_id()))
return;
if (status == RequestCoordinator::BackgroundSavePageResult::SUCCESS)
notifier_->NotifyDownloadSuccessful(DownloadUIItem(request));
@@ -71,4 +73,10 @@ void DownloadNotifyingObserver::OnCompleted(
else
notifier_->NotifyDownloadFailed(DownloadUIItem(request));
}
+
+bool DownloadNotifyingObserver::IsVisibleInUI(const ClientId& page) {
+ return policy_controller_->IsSupportedByDownload(page.name_space) &&
+ base::IsValidGUID(page.id);
+}
+
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698