| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/reading_list/reading_list_model_impl.h" | 5 #include "ios/chrome/browser/reading_list/reading_list_model_impl.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "components/prefs/pref_service.h" | 8 #include "components/prefs/pref_service.h" |
| 9 #include "ios/chrome/browser/reading_list/reading_list_model_storage.h" | 9 #include "ios/chrome/browser/reading_list/reading_list_model_storage.h" |
| 10 #include "ios/chrome/browser/reading_list/reading_list_pref_names.h" | 10 #include "ios/chrome/browser/reading_list/reading_list_pref_names.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } | 227 } |
| 228 result->SetTitle(title); | 228 result->SetTitle(title); |
| 229 if (storage_layer_ && !IsPerformingBatchUpdates()) | 229 if (storage_layer_ && !IsPerformingBatchUpdates()) |
| 230 storage_layer_->SavePersistentReadList(read_); | 230 storage_layer_->SavePersistentReadList(read_); |
| 231 for (auto& observer : observers_) | 231 for (auto& observer : observers_) |
| 232 observer.ReadingListDidApplyChanges(this); | 232 observer.ReadingListDidApplyChanges(this); |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 void ReadingListModelImpl::SetEntryDistilledURL(const GURL& url, | 237 void ReadingListModelImpl::SetEntryDistilledPath( |
| 238 const GURL& distilled_url) { | 238 const GURL& url, |
| 239 const base::FilePath& distilled_path) { |
| 239 DCHECK(loaded()); | 240 DCHECK(loaded()); |
| 240 const ReadingListEntry entry(url, std::string()); | 241 const ReadingListEntry entry(url, std::string()); |
| 241 | 242 |
| 242 auto result = std::find(unread_.begin(), unread_.end(), entry); | 243 auto result = std::find(unread_.begin(), unread_.end(), entry); |
| 243 if (result != unread_.end()) { | 244 if (result != unread_.end()) { |
| 244 for (auto& observer : observers_) { | 245 for (auto& observer : observers_) { |
| 245 observer.ReadingListWillUpdateUnreadEntry( | 246 observer.ReadingListWillUpdateUnreadEntry( |
| 246 this, std::distance(unread_.begin(), result)); | 247 this, std::distance(unread_.begin(), result)); |
| 247 } | 248 } |
| 248 result->SetDistilledURL(distilled_url); | 249 result->SetDistilledPath(distilled_path); |
| 249 if (storage_layer_ && !IsPerformingBatchUpdates()) | 250 if (storage_layer_ && !IsPerformingBatchUpdates()) |
| 250 storage_layer_->SavePersistentUnreadList(unread_); | 251 storage_layer_->SavePersistentUnreadList(unread_); |
| 251 for (auto& observer : observers_) | 252 for (auto& observer : observers_) |
| 252 observer.ReadingListDidApplyChanges(this); | 253 observer.ReadingListDidApplyChanges(this); |
| 253 return; | 254 return; |
| 254 } | 255 } |
| 255 | 256 |
| 256 result = std::find(read_.begin(), read_.end(), entry); | 257 result = std::find(read_.begin(), read_.end(), entry); |
| 257 if (result != read_.end()) { | 258 if (result != read_.end()) { |
| 258 for (auto& observer : observers_) { | 259 for (auto& observer : observers_) { |
| 259 observer.ReadingListWillUpdateReadEntry( | 260 observer.ReadingListWillUpdateReadEntry( |
| 260 this, std::distance(read_.begin(), result)); | 261 this, std::distance(read_.begin(), result)); |
| 261 } | 262 } |
| 262 result->SetDistilledURL(distilled_url); | 263 result->SetDistilledPath(distilled_path); |
| 263 if (storage_layer_ && !IsPerformingBatchUpdates()) | 264 if (storage_layer_ && !IsPerformingBatchUpdates()) |
| 264 storage_layer_->SavePersistentReadList(read_); | 265 storage_layer_->SavePersistentReadList(read_); |
| 265 for (auto& observer : observers_) | 266 for (auto& observer : observers_) |
| 266 observer.ReadingListDidApplyChanges(this); | 267 observer.ReadingListDidApplyChanges(this); |
| 267 return; | 268 return; |
| 268 } | 269 } |
| 269 } | 270 } |
| 270 | 271 |
| 271 void ReadingListModelImpl::SetEntryDistilledState( | 272 void ReadingListModelImpl::SetEntryDistilledState( |
| 272 const GURL& url, | 273 const GURL& url, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 has_unseen); | 322 has_unseen); |
| 322 } | 323 } |
| 323 | 324 |
| 324 bool ReadingListModelImpl::GetPersistentHasUnseen() { | 325 bool ReadingListModelImpl::GetPersistentHasUnseen() { |
| 325 if (!pref_service_) { | 326 if (!pref_service_) { |
| 326 return false; | 327 return false; |
| 327 } | 328 } |
| 328 return pref_service_->GetBoolean( | 329 return pref_service_->GetBoolean( |
| 329 reading_list::prefs::kReadingListHasUnseenEntries); | 330 reading_list::prefs::kReadingListHasUnseenEntries); |
| 330 } | 331 } |
| OLD | NEW |