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

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

Issue 2180973002: [Offline pages] Adapting OfflinePageDownloadBridge to DownloadUIAdapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ui-adapter
Patch Set: Minor updates Created 4 years, 5 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
« no previous file with comments | « components/offline_pages/downloads/download_ui_adapter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/downloads/download_ui_adapter.cc
diff --git a/components/offline_pages/downloads/download_ui_adapter.cc b/components/offline_pages/downloads/download_ui_adapter.cc
index efdc35242fdcca4e9254f423ad5480c24c0c9144..776fd8cd79b691e167cd48adfc895c7e9d622056 100644
--- a/components/offline_pages/downloads/download_ui_adapter.cc
+++ b/components/offline_pages/downloads/download_ui_adapter.cc
@@ -15,6 +15,10 @@
namespace offline_pages {
+namespace {
+const char kDownloadUIAdapterKey[] = "download-ui-adapter";
+}
+
DownloadUIAdapter::DownloadUIAdapter(OfflinePageModel* model)
: model_(model),
is_loaded_(false),
@@ -23,6 +27,18 @@ DownloadUIAdapter::DownloadUIAdapter(OfflinePageModel* model)
DownloadUIAdapter::~DownloadUIAdapter() { }
+// static
+DownloadUIAdapter* DownloadUIAdapter::FromOfflinePageModel(
+ OfflinePageModel* offline_page_model) {
+ DownloadUIAdapter* adapter = static_cast<DownloadUIAdapter*>(
+ offline_page_model->GetUserData(kDownloadUIAdapterKey));
+ if (!adapter) {
+ adapter = new DownloadUIAdapter(offline_page_model);
+ offline_page_model->SetUserData(kDownloadUIAdapterKey, adapter);
+ }
+ return adapter;
+}
+
void DownloadUIAdapter::AddObserver(Observer* observer) {
DCHECK(observer);
if (!observers_.might_have_observers())
« no previous file with comments | « components/offline_pages/downloads/download_ui_adapter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698