Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: chrome/browser/bookmarks/bookmark_model.cc

Issue 184663002: Omnibox: Make URLs of Bookmarks Searchable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ALL_MATCHES (in response to recent changes) Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "components/bookmarks/core/browser/bookmark_title_match.h" 27 #include "chrome/common/pref_names.h"
28 #include "components/bookmarks/core/browser/bookmark_match.h"
27 #include "components/favicon_base/favicon_types.h" 29 #include "components/favicon_base/favicon_types.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/component_strings.h" 32 #include "grit/component_strings.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
(...skipping 26 matching lines...) Expand all
63 } 65 }
64 66
65 private: 67 private:
66 icu::Collator* collator_; 68 icu::Collator* collator_;
67 }; 69 };
68 70
69 } // namespace 71 } // namespace
70 72
71 // BookmarkModel -------------------------------------------------------------- 73 // BookmarkModel --------------------------------------------------------------
72 74
73 BookmarkModel::BookmarkModel(Profile* profile) 75 BookmarkModel::BookmarkModel(Profile* profile,
76 bool index_urls)
74 : profile_(profile), 77 : profile_(profile),
75 loaded_(false), 78 loaded_(false),
76 root_(GURL()), 79 root_(GURL()),
77 bookmark_bar_node_(NULL), 80 bookmark_bar_node_(NULL),
78 other_node_(NULL), 81 other_node_(NULL),
79 mobile_node_(NULL), 82 mobile_node_(NULL),
80 next_node_id_(1), 83 next_node_id_(1),
81 observers_(ObserverList<BookmarkModelObserver>::NOTIFY_EXISTING_ONLY), 84 observers_(ObserverList<BookmarkModelObserver>::NOTIFY_EXISTING_ONLY),
85 index_urls_(index_urls),
82 loaded_signal_(true, false), 86 loaded_signal_(true, false),
83 extensive_changes_(0) { 87 extensive_changes_(0) {
84 if (!profile_) { 88 if (!profile_) {
85 // Profile is null during testing. 89 // Profile is null during testing.
86 DoneLoading(CreateLoadDetails()); 90 DoneLoading(CreateLoadDetails());
87 } 91 }
88 } 92 }
89 93
90 BookmarkModel::~BookmarkModel() { 94 BookmarkModel::~BookmarkModel() {
91 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, 95 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 AsMutable(parent)->set_date_folder_modified(time); 606 AsMutable(parent)->set_date_folder_modified(time);
603 607
604 if (store_.get()) 608 if (store_.get())
605 store_->ScheduleSave(); 609 store_->ScheduleSave();
606 } 610 }
607 611
608 void BookmarkModel::ResetDateFolderModified(const BookmarkNode* node) { 612 void BookmarkModel::ResetDateFolderModified(const BookmarkNode* node) {
609 SetDateFolderModified(node, Time()); 613 SetDateFolderModified(node, Time());
610 } 614 }
611 615
612 void BookmarkModel::GetBookmarksWithTitlesMatching( 616 void BookmarkModel::GetBookmarksMatching(
613 const base::string16& text, 617 const base::string16& text,
614 size_t max_count, 618 size_t max_count,
615 std::vector<BookmarkTitleMatch>* matches) { 619 std::vector<BookmarkMatch>* matches) {
616 if (!loaded_) 620 if (!loaded_)
617 return; 621 return;
618 622
619 index_->GetBookmarksWithTitlesMatching(text, max_count, matches); 623 index_->GetBookmarksMatching(text, max_count, matches);
620 } 624 }
621 625
622 void BookmarkModel::ClearStore() { 626 void BookmarkModel::ClearStore() {
623 registrar_.RemoveAll(); 627 registrar_.RemoveAll();
624 store_ = NULL; 628 store_ = NULL;
625 } 629 }
626 630
627 void BookmarkModel::SetPermanentNodeVisible(BookmarkNode::Type type, 631 void BookmarkModel::SetPermanentNodeVisible(BookmarkNode::Type type,
628 bool value) { 632 bool value) {
629 DCHECK(loaded_); 633 DCHECK(loaded_);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 return next_node_id_++; 942 return next_node_id_++;
939 } 943 }
940 944
941 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { 945 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() {
942 BookmarkPermanentNode* bb_node = 946 BookmarkPermanentNode* bb_node =
943 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); 947 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR);
944 BookmarkPermanentNode* other_node = 948 BookmarkPermanentNode* other_node =
945 CreatePermanentNode(BookmarkNode::OTHER_NODE); 949 CreatePermanentNode(BookmarkNode::OTHER_NODE);
946 BookmarkPermanentNode* mobile_node = 950 BookmarkPermanentNode* mobile_node =
947 CreatePermanentNode(BookmarkNode::MOBILE); 951 CreatePermanentNode(BookmarkNode::MOBILE);
948 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, 952 return new BookmarkLoadDetails(
949 new BookmarkIndex(profile_), 953 bb_node, other_node, mobile_node,
950 next_node_id_); 954 new BookmarkIndex(
955 profile_,
956 index_urls_,
957 profile_ ?
958 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) :
959 std::string()),
960 next_node_id_);
951 } 961 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.h ('k') | chrome/browser/bookmarks/bookmark_model_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698