| 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 "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" | 15 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_index.h" | 16 #include "chrome/browser/bookmarks/bookmark_index.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_model_observer.h" | 17 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
| 17 #include "chrome/browser/bookmarks/bookmark_storage.h" | 18 #include "chrome/browser/bookmarks/bookmark_storage.h" |
| 18 #include "chrome/browser/bookmarks/bookmark_utils.h" | 19 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/favicon/favicon_changed_details.h" | 21 #include "chrome/browser/favicon/favicon_changed_details.h" |
| 21 #include "chrome/browser/favicon/favicon_service.h" | 22 #include "chrome/browser/favicon/favicon_service.h" |
| 22 #include "chrome/browser/favicon/favicon_service_factory.h" | 23 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 23 #include "chrome/browser/history/history_service.h" | 24 #include "chrome/browser/history/history_service.h" |
| 24 #include "chrome/browser/history/history_service_factory.h" | 25 #include "chrome/browser/history/history_service_factory.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/common/favicon/favicon_types.h" | 27 #include "chrome/common/favicon/favicon_types.h" |
| 27 #include "components/bookmarks/core/browser/bookmark_title_match.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "components/bookmarks/core/browser/bookmark_match.h" |
| 28 #include "content/public/browser/notification_details.h" | 30 #include "content/public/browser/notification_details.h" |
| 29 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
| 30 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "ui/gfx/favicon_size.h" | 34 #include "ui/gfx/favicon_size.h" |
| 33 #include "ui/gfx/image/image_util.h" | 35 #include "ui/gfx/image/image_util.h" |
| 34 | 36 |
| 35 using base::Time; | 37 using base::Time; |
| 36 | 38 |
| 37 namespace { | 39 namespace { |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 AsMutable(parent)->set_date_folder_modified(time); | 609 AsMutable(parent)->set_date_folder_modified(time); |
| 608 | 610 |
| 609 if (store_.get()) | 611 if (store_.get()) |
| 610 store_->ScheduleSave(); | 612 store_->ScheduleSave(); |
| 611 } | 613 } |
| 612 | 614 |
| 613 void BookmarkModel::ResetDateFolderModified(const BookmarkNode* node) { | 615 void BookmarkModel::ResetDateFolderModified(const BookmarkNode* node) { |
| 614 SetDateFolderModified(node, Time()); | 616 SetDateFolderModified(node, Time()); |
| 615 } | 617 } |
| 616 | 618 |
| 617 void BookmarkModel::GetBookmarksWithTitlesMatching( | 619 void BookmarkModel::GetBookmarksMatching( |
| 618 const base::string16& text, | 620 const base::string16& text, |
| 619 size_t max_count, | 621 size_t max_count, |
| 620 std::vector<BookmarkTitleMatch>* matches) { | 622 std::vector<BookmarkMatch>* matches) { |
| 621 if (!loaded_) | 623 if (!loaded_) |
| 622 return; | 624 return; |
| 623 | 625 |
| 624 index_->GetBookmarksWithTitlesMatching(text, max_count, matches); | 626 index_->GetBookmarksMatching(text, max_count, matches); |
| 625 } | 627 } |
| 626 | 628 |
| 627 void BookmarkModel::ClearStore() { | 629 void BookmarkModel::ClearStore() { |
| 628 registrar_.RemoveAll(); | 630 registrar_.RemoveAll(); |
| 629 store_ = NULL; | 631 store_ = NULL; |
| 630 } | 632 } |
| 631 | 633 |
| 632 void BookmarkModel::SetPermanentNodeVisible(BookmarkNode::Type type, | 634 void BookmarkModel::SetPermanentNodeVisible(BookmarkNode::Type type, |
| 633 bool value) { | 635 bool value) { |
| 634 DCHECK(loaded_); | 636 DCHECK(loaded_); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 return next_node_id_++; | 958 return next_node_id_++; |
| 957 } | 959 } |
| 958 | 960 |
| 959 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { | 961 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { |
| 960 BookmarkPermanentNode* bb_node = | 962 BookmarkPermanentNode* bb_node = |
| 961 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); | 963 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); |
| 962 BookmarkPermanentNode* other_node = | 964 BookmarkPermanentNode* other_node = |
| 963 CreatePermanentNode(BookmarkNode::OTHER_NODE); | 965 CreatePermanentNode(BookmarkNode::OTHER_NODE); |
| 964 BookmarkPermanentNode* mobile_node = | 966 BookmarkPermanentNode* mobile_node = |
| 965 CreatePermanentNode(BookmarkNode::MOBILE); | 967 CreatePermanentNode(BookmarkNode::MOBILE); |
| 966 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, | 968 return new BookmarkLoadDetails( |
| 967 new BookmarkIndex(profile_), | 969 bb_node, other_node, mobile_node, |
| 968 next_node_id_); | 970 new BookmarkIndex( |
| 971 profile_, |
| 972 profile_ ? |
| 973 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : |
| 974 std::string()), |
| 975 next_node_id_); |
| 969 } | 976 } |
| OLD | NEW |