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

Unified Diff: chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc

Issue 1496853002: MD Downloads: fix incognito markers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@thread-bundle
Patch Set: remove DCHECK Created 5 years 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: chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc
diff --git a/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc b/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc
index b163644474913c5ee97c468b61515d6772843280..f67a1cb35063c45ebf2c5d0f20db9136fbf16684 100644
--- a/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc
+++ b/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc
@@ -235,14 +235,7 @@ scoped_ptr<base::DictionaryValue> DownloadsListTracker::CreateDownloadItemValue(
file_value->SetBoolean("file_externally_removed",
download_item->GetFileExternallyRemoved());
file_value->SetBoolean("resume", download_item->CanResume());
-
- bool incognito = false;
- auto* original_manager = GetOriginalNotifierManager();
- if (original_manager) {
- incognito =
- original_manager->GetDownload(download_item->GetId()) == download_item;
- }
- file_value->SetBoolean("otr", incognito);
+ file_value->SetBoolean("otr", IsIncognito(*download_item));
const char* danger_type = "";
base::string16 last_reason_text;
@@ -307,6 +300,11 @@ scoped_ptr<base::DictionaryValue> DownloadsListTracker::CreateDownloadItemValue(
return file_value.Pass();
}
+bool DownloadsListTracker::IsIncognito(const DownloadItem& item) const {
+ return GetOriginalNotifierManager() && GetMainNotifierManager() &&
+ GetMainNotifierManager()->GetDownload(item.GetId()) == &item;
+}
+
const DownloadItem* DownloadsListTracker::GetItemForTesting(size_t index)
const {
if (index >= sorted_visible_items_.size())
@@ -335,9 +333,9 @@ void DownloadsListTracker::Init() {
Profile* profile = Profile::FromBrowserContext(
GetMainNotifierManager()->GetBrowserContext());
if (profile->IsOffTheRecord()) {
+ Profile* original_profile = profile->GetOriginalProfile();
original_notifier_.reset(new AllDownloadItemNotifier(
- BrowserContext::GetDownloadManager(profile->GetOriginalProfile()),
- this));
+ BrowserContext::GetDownloadManager(original_profile), this));
}
RebuildSortedSet();

Powered by Google App Engine
This is Rietveld 408576698