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

Side by Side Diff: components/offline_pages/offline_page_model.cc

Issue 1741123002: Add removal filter support for Cookies, Storage, and Content Settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/offline_page_model.h" 5 #include "components/offline_pages/offline_page_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 std::vector<int64_t> bookmark_ids; 276 std::vector<int64_t> bookmark_ids;
277 for (const auto& id_page_pair : offline_pages_) 277 for (const auto& id_page_pair : offline_pages_)
278 bookmark_ids.push_back(id_page_pair.first); 278 bookmark_ids.push_back(id_page_pair.first);
279 DeletePagesByBookmarkId( 279 DeletePagesByBookmarkId(
280 bookmark_ids, 280 bookmark_ids,
281 base::Bind(&OfflinePageModel::OnRemoveAllFilesDoneForClearAll, 281 base::Bind(&OfflinePageModel::OnRemoveAllFilesDoneForClearAll,
282 weak_ptr_factory_.GetWeakPtr(), 282 weak_ptr_factory_.GetWeakPtr(),
283 callback)); 283 callback));
284 } 284 }
285 285
286 void OfflinePageModel::ClearWithURLPredicate(
287 const base::Callback<bool(const GURL&)> predicate,
288 const base::Closure& callback) {
289 DCHECK(is_loaded_);
290
291 std::vector<int64_t> bookmark_ids;
292 for (const auto& id_page_pair : offline_pages_) {
293 if (predicate.Run(GURL(id_page_pair.second.url)))
294 bookmark_ids.push_back(id_page_pair.first);
295 }
296 DeletePagesByBookmarkId(
297 bookmark_ids,
298 base::Bind(&OfflinePageModel::OnRemoveAllFilesDoneForClearAll,
299 weak_ptr_factory_.GetWeakPtr(), callback));
300 }
301
286 bool OfflinePageModel::HasOfflinePages() const { 302 bool OfflinePageModel::HasOfflinePages() const {
287 DCHECK(is_loaded_); 303 DCHECK(is_loaded_);
288 // Check that at least one page is not marked for deletion. Because we have 304 // Check that at least one page is not marked for deletion. Because we have
289 // pages marked for deletion, we cannot simply invert result of |empty()|. 305 // pages marked for deletion, we cannot simply invert result of |empty()|.
290 for (const auto& id_page_pair : offline_pages_) { 306 for (const auto& id_page_pair : offline_pages_) {
291 if (!id_page_pair.second.IsMarkedForDeletion()) 307 if (!id_page_pair.second.IsMarkedForDeletion())
292 return true; 308 return true;
293 } 309 }
294 return false; 310 return false;
295 } 311 }
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 747 }
732 748
733 void OfflinePageModel::CacheLoadedData( 749 void OfflinePageModel::CacheLoadedData(
734 const std::vector<OfflinePageItem>& offline_pages) { 750 const std::vector<OfflinePageItem>& offline_pages) {
735 offline_pages_.clear(); 751 offline_pages_.clear();
736 for (const auto& offline_page : offline_pages) 752 for (const auto& offline_page : offline_pages)
737 offline_pages_[offline_page.bookmark_id] = offline_page; 753 offline_pages_[offline_page.bookmark_id] = offline_page;
738 } 754 }
739 755
740 } // namespace offline_pages 756 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698