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

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: 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(),
300 callback));
301 }
302
286 bool OfflinePageModel::HasOfflinePages() const { 303 bool OfflinePageModel::HasOfflinePages() const {
287 DCHECK(is_loaded_); 304 DCHECK(is_loaded_);
288 // Check that at least one page is not marked for deletion. Because we have 305 // 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()|. 306 // pages marked for deletion, we cannot simply invert result of |empty()|.
290 for (const auto& id_page_pair : offline_pages_) { 307 for (const auto& id_page_pair : offline_pages_) {
291 if (!id_page_pair.second.IsMarkedForDeletion()) 308 if (!id_page_pair.second.IsMarkedForDeletion())
292 return true; 309 return true;
293 } 310 }
294 return false; 311 return false;
295 } 312 }
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 748 }
732 749
733 void OfflinePageModel::CacheLoadedData( 750 void OfflinePageModel::CacheLoadedData(
734 const std::vector<OfflinePageItem>& offline_pages) { 751 const std::vector<OfflinePageItem>& offline_pages) {
735 offline_pages_.clear(); 752 offline_pages_.clear();
736 for (const auto& offline_page : offline_pages) 753 for (const auto& offline_page : offline_pages)
737 offline_pages_[offline_page.bookmark_id] = offline_page; 754 offline_pages_[offline_page.bookmark_id] = offline_page;
738 } 755 }
739 756
740 } // namespace offline_pages 757 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698