| OLD | NEW |
| 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 "ios/chrome/browser/bookmarks/bookmarks_utils.h" | 5 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "components/bookmarks/browser/bookmark_model.h" | 9 #include "components/bookmarks/browser/bookmark_model.h" |
| 10 #include "components/prefs/pref_service.h" | 10 #include "components/prefs/pref_service.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 if (!bookmark_model->loaded()) | 28 if (!bookmark_model->loaded()) |
| 29 return false; | 29 return false; |
| 30 | 30 |
| 31 bookmark_model->RemoveAllUserBookmarks(); | 31 bookmark_model->RemoveAllUserBookmarks(); |
| 32 | 32 |
| 33 for (int i = 0; i < bookmark_model->root_node()->child_count(); ++i) { | 33 for (int i = 0; i < bookmark_model->root_node()->child_count(); ++i) { |
| 34 if (!bookmark_model->client()->CanBeEditedByUser( | 34 if (!bookmark_model->client()->CanBeEditedByUser( |
| 35 bookmark_model->root_node()->GetChild(i))) | 35 bookmark_model->root_node()->GetChild(i))) |
| 36 continue; | 36 continue; |
| 37 CHECK(bookmark_model->root_node()->GetChild(i)->empty()) | 37 // Failed to remove all user bookmarks. |
| 38 << "Failed to remove all user bookmarks."; | 38 CHECK(bookmark_model->root_node()->GetChild(i)->empty()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // The default save folder is reset to the generic one. | 41 // The default save folder is reset to the generic one. |
| 42 browser_state->GetPrefs()->SetInt64(prefs::kIosBookmarkFolderDefault, -1); | 42 browser_state->GetPrefs()->SetInt64(prefs::kIosBookmarkFolderDefault, -1); |
| 43 | 43 |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 std::vector<const BookmarkNode*> PrimaryPermanentNodes(BookmarkModel* model) { | 47 std::vector<const BookmarkNode*> PrimaryPermanentNodes(BookmarkModel* model) { |
| 48 DCHECK(model->loaded()); | 48 DCHECK(model->loaded()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 const std::vector<const BookmarkNode*> root_folders(RootLevelFolders(model)); | 89 const std::vector<const BookmarkNode*> root_folders(RootLevelFolders(model)); |
| 90 const BookmarkNode* top = node; | 90 const BookmarkNode* top = node; |
| 91 while (top && | 91 while (top && |
| 92 std::find(root_folders.begin(), root_folders.end(), top) == | 92 std::find(root_folders.begin(), root_folders.end(), top) == |
| 93 root_folders.end()) { | 93 root_folders.end()) { |
| 94 top = top->parent(); | 94 top = top->parent(); |
| 95 } | 95 } |
| 96 return top; | 96 return top; |
| 97 } | 97 } |
| OLD | NEW |