OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/bookmarks/bookmark_model.h" | 5 #include "chrome/browser/bookmarks/bookmark_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/i18n/string_compare.h" | 12 #include "base/i18n/string_compare.h" |
| 13 #include "base/prefs/pref_service.h" |
13 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" | 17 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" |
17 #include "chrome/browser/bookmarks/bookmark_index.h" | 18 #include "chrome/browser/bookmarks/bookmark_index.h" |
| 19 #include "chrome/browser/bookmarks/bookmark_match.h" |
18 #include "chrome/browser/bookmarks/bookmark_model_observer.h" | 20 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
19 #include "chrome/browser/bookmarks/bookmark_storage.h" | 21 #include "chrome/browser/bookmarks/bookmark_storage.h" |
20 #include "chrome/browser/bookmarks/bookmark_title_match.h" | |
21 #include "chrome/browser/bookmarks/bookmark_utils.h" | 22 #include "chrome/browser/bookmarks/bookmark_utils.h" |
22 #include "chrome/browser/chrome_notification_types.h" | 23 #include "chrome/browser/chrome_notification_types.h" |
23 #include "chrome/browser/favicon/favicon_changed_details.h" | 24 #include "chrome/browser/favicon/favicon_changed_details.h" |
24 #include "chrome/browser/favicon/favicon_service.h" | 25 #include "chrome/browser/favicon/favicon_service.h" |
25 #include "chrome/browser/favicon/favicon_service_factory.h" | 26 #include "chrome/browser/favicon/favicon_service_factory.h" |
26 #include "chrome/browser/history/history_service.h" | 27 #include "chrome/browser/history/history_service.h" |
27 #include "chrome/browser/history/history_service_factory.h" | 28 #include "chrome/browser/history/history_service_factory.h" |
28 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/common/favicon/favicon_types.h" | 30 #include "chrome/common/favicon/favicon_types.h" |
| 31 #include "chrome/common/pref_names.h" |
30 #include "content/public/browser/notification_details.h" | 32 #include "content/public/browser/notification_details.h" |
31 #include "content/public/browser/notification_source.h" | 33 #include "content/public/browser/notification_source.h" |
32 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
33 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
34 #include "ui/gfx/favicon_size.h" | 36 #include "ui/gfx/favicon_size.h" |
35 #include "ui/gfx/image/image_util.h" | 37 #include "ui/gfx/image/image_util.h" |
36 | 38 |
37 using base::Time; | 39 using base::Time; |
38 | 40 |
39 namespace { | 41 namespace { |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 AsMutable(parent)->set_date_folder_modified(time); | 723 AsMutable(parent)->set_date_folder_modified(time); |
722 | 724 |
723 if (store_.get()) | 725 if (store_.get()) |
724 store_->ScheduleSave(); | 726 store_->ScheduleSave(); |
725 } | 727 } |
726 | 728 |
727 void BookmarkModel::ResetDateFolderModified(const BookmarkNode* node) { | 729 void BookmarkModel::ResetDateFolderModified(const BookmarkNode* node) { |
728 SetDateFolderModified(node, Time()); | 730 SetDateFolderModified(node, Time()); |
729 } | 731 } |
730 | 732 |
731 void BookmarkModel::GetBookmarksWithTitlesMatching( | 733 void BookmarkModel::GetBookmarksMatching( |
732 const base::string16& text, | 734 const base::string16& text, |
733 size_t max_count, | 735 size_t max_count, |
734 std::vector<BookmarkTitleMatch>* matches) { | 736 std::vector<BookmarkMatch>* matches) { |
735 if (!loaded_) | 737 if (!loaded_) |
736 return; | 738 return; |
737 | 739 |
738 index_->GetBookmarksWithTitlesMatching(text, max_count, matches); | 740 index_->GetBookmarksMatching(text, max_count, matches); |
739 } | 741 } |
740 | 742 |
741 void BookmarkModel::ClearStore() { | 743 void BookmarkModel::ClearStore() { |
742 registrar_.RemoveAll(); | 744 registrar_.RemoveAll(); |
743 store_ = NULL; | 745 store_ = NULL; |
744 } | 746 } |
745 | 747 |
746 void BookmarkModel::SetPermanentNodeVisible(BookmarkNode::Type type, | 748 void BookmarkModel::SetPermanentNodeVisible(BookmarkNode::Type type, |
747 bool value) { | 749 bool value) { |
748 DCHECK(loaded_); | 750 DCHECK(loaded_); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 return next_node_id_++; | 1071 return next_node_id_++; |
1070 } | 1072 } |
1071 | 1073 |
1072 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { | 1074 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { |
1073 BookmarkPermanentNode* bb_node = | 1075 BookmarkPermanentNode* bb_node = |
1074 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); | 1076 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); |
1075 BookmarkPermanentNode* other_node = | 1077 BookmarkPermanentNode* other_node = |
1076 CreatePermanentNode(BookmarkNode::OTHER_NODE); | 1078 CreatePermanentNode(BookmarkNode::OTHER_NODE); |
1077 BookmarkPermanentNode* mobile_node = | 1079 BookmarkPermanentNode* mobile_node = |
1078 CreatePermanentNode(BookmarkNode::MOBILE); | 1080 CreatePermanentNode(BookmarkNode::MOBILE); |
1079 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, | 1081 return new BookmarkLoadDetails( |
1080 new BookmarkIndex(profile_), | 1082 bb_node, other_node, mobile_node, |
1081 next_node_id_); | 1083 new BookmarkIndex(profile_, |
| 1084 profile_->GetPrefs()->GetString( |
| 1085 prefs::kAcceptLanguages)), |
| 1086 next_node_id_); |
1082 } | 1087 } |
OLD | NEW |