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

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: 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/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
(...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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 AsMutable(parent)->set_date_folder_modified(time); 611 AsMutable(parent)->set_date_folder_modified(time);
608 612
609 if (store_.get()) 613 if (store_.get())
610 store_->ScheduleSave(); 614 store_->ScheduleSave();
611 } 615 }
612 616
613 void BookmarkModel::ResetDateFolderModified(const BookmarkNode* node) { 617 void BookmarkModel::ResetDateFolderModified(const BookmarkNode* node) {
614 SetDateFolderModified(node, Time()); 618 SetDateFolderModified(node, Time());
615 } 619 }
616 620
617 void BookmarkModel::GetBookmarksWithTitlesMatching( 621 void BookmarkModel::GetBookmarksMatching(
618 const base::string16& text, 622 const base::string16& text,
619 size_t max_count, 623 size_t max_count,
620 std::vector<BookmarkTitleMatch>* matches) { 624 std::vector<BookmarkMatch>* matches) {
621 if (!loaded_) 625 if (!loaded_)
622 return; 626 return;
623 627
624 index_->GetBookmarksWithTitlesMatching(text, max_count, matches); 628 index_->GetBookmarksMatching(text, max_count, matches);
625 } 629 }
626 630
627 void BookmarkModel::ClearStore() { 631 void BookmarkModel::ClearStore() {
628 registrar_.RemoveAll(); 632 registrar_.RemoveAll();
629 store_ = NULL; 633 store_ = NULL;
630 } 634 }
631 635
632 void BookmarkModel::SetPermanentNodeVisible(BookmarkNode::Type type, 636 void BookmarkModel::SetPermanentNodeVisible(BookmarkNode::Type type,
633 bool value) { 637 bool value) {
634 DCHECK(loaded_); 638 DCHECK(loaded_);
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 return next_node_id_++; 960 return next_node_id_++;
957 } 961 }
958 962
959 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { 963 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() {
960 BookmarkPermanentNode* bb_node = 964 BookmarkPermanentNode* bb_node =
961 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); 965 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR);
962 BookmarkPermanentNode* other_node = 966 BookmarkPermanentNode* other_node =
963 CreatePermanentNode(BookmarkNode::OTHER_NODE); 967 CreatePermanentNode(BookmarkNode::OTHER_NODE);
964 BookmarkPermanentNode* mobile_node = 968 BookmarkPermanentNode* mobile_node =
965 CreatePermanentNode(BookmarkNode::MOBILE); 969 CreatePermanentNode(BookmarkNode::MOBILE);
966 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, 970 return new BookmarkLoadDetails(
967 new BookmarkIndex(profile_), 971 bb_node, other_node, mobile_node,
968 next_node_id_); 972 new BookmarkIndex(
973 profile_,
974 index_urls_,
975 profile_ ?
976 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) :
977 std::string()),
978 next_node_id_);
969 } 979 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698