OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bookmarks/browser/bookmark_utils.h" | 5 #include "components/bookmarks/browser/bookmark_utils.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/i18n/case_conversion.h" | 13 #include "base/i18n/case_conversion.h" |
14 #include "base/i18n/string_search.h" | 14 #include "base/i18n/string_search.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" |
16 #include "base/metrics/user_metrics_action.h" | 17 #include "base/metrics/user_metrics_action.h" |
17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
20 #include "base/time/time.h" | 21 #include "base/time/time.h" |
21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
22 #include "components/bookmarks/browser/bookmark_client.h" | 23 #include "components/bookmarks/browser/bookmark_client.h" |
23 #include "components/bookmarks/browser/bookmark_model.h" | 24 #include "components/bookmarks/browser/bookmark_model.h" |
24 #include "components/bookmarks/browser/scoped_group_bookmark_actions.h" | 25 #include "components/bookmarks/browser/scoped_group_bookmark_actions.h" |
25 #include "components/bookmarks/common/bookmark_pref_names.h" | 26 #include "components/bookmarks/common/bookmark_pref_names.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 455 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
455 RegisterManagedBookmarksPrefs(registry); | 456 RegisterManagedBookmarksPrefs(registry); |
456 } | 457 } |
457 | 458 |
458 void RegisterManagedBookmarksPrefs(PrefRegistrySimple* registry) { | 459 void RegisterManagedBookmarksPrefs(PrefRegistrySimple* registry) { |
459 // Don't sync this, as otherwise, due to a limitation in sync, it | 460 // Don't sync this, as otherwise, due to a limitation in sync, it |
460 // will cause a deadlock (see http://crbug.com/97955). If we truly | 461 // will cause a deadlock (see http://crbug.com/97955). If we truly |
461 // want to sync the expanded state of folders, it should be part of | 462 // want to sync the expanded state of folders, it should be part of |
462 // bookmark sync itself (i.e., a property of the sync folder nodes). | 463 // bookmark sync itself (i.e., a property of the sync folder nodes). |
463 registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, | 464 registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, |
464 new base::ListValue); | 465 base::MakeUnique<base::ListValue>()); |
465 registry->RegisterListPref(prefs::kManagedBookmarks); | 466 registry->RegisterListPref(prefs::kManagedBookmarks); |
466 registry->RegisterStringPref( | 467 registry->RegisterStringPref( |
467 prefs::kManagedBookmarksFolderName, std::string()); | 468 prefs::kManagedBookmarksFolderName, std::string()); |
468 registry->RegisterListPref(prefs::kSupervisedBookmarks); | 469 registry->RegisterListPref(prefs::kSupervisedBookmarks); |
469 } | 470 } |
470 | 471 |
471 const BookmarkNode* GetParentForNewNodes( | 472 const BookmarkNode* GetParentForNewNodes( |
472 const BookmarkNode* parent, | 473 const BookmarkNode* parent, |
473 const std::vector<const BookmarkNode*>& selection, | 474 const std::vector<const BookmarkNode*>& selection, |
474 int* index) { | 475 int* index) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 if (!HasUserCreatedBookmarks(model)) | 590 if (!HasUserCreatedBookmarks(model)) |
590 return model->mobile_node(); | 591 return model->mobile_node(); |
591 #endif | 592 #endif |
592 std::vector<const BookmarkNode*> nodes = | 593 std::vector<const BookmarkNode*> nodes = |
593 GetMostRecentlyModifiedUserFolders(model, 1); | 594 GetMostRecentlyModifiedUserFolders(model, 1); |
594 DCHECK(!nodes.empty()); // This list is always padded with default folders. | 595 DCHECK(!nodes.empty()); // This list is always padded with default folders. |
595 return nodes[0]; | 596 return nodes[0]; |
596 } | 597 } |
597 | 598 |
598 } // namespace bookmarks | 599 } // namespace bookmarks |
OLD | NEW |