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 "chrome/browser/bookmarks/chrome_bookmark_client.h" | 5 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
6 | 6 |
| 7 #include "base/bind.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/favicon/favicon_changed_details.h" | 10 #include "chrome/browser/favicon/favicon_changed_details.h" |
10 #include "chrome/browser/favicon/favicon_service.h" | 11 #include "chrome/browser/favicon/favicon_service.h" |
11 #include "chrome/browser/favicon/favicon_service_factory.h" | 12 #include "chrome/browser/favicon/favicon_service_factory.h" |
12 #include "chrome/browser/history/history_service.h" | 13 #include "chrome/browser/history/history_service.h" |
13 #include "chrome/browser/history/history_service_factory.h" | 14 #include "chrome/browser/history/history_service_factory.h" |
14 #include "chrome/browser/history/url_database.h" | 15 #include "chrome/browser/history/url_database.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "components/bookmarks/browser/bookmark_model.h" | 17 #include "components/bookmarks/browser/bookmark_model.h" |
(...skipping 75 matching lines...) Loading... |
92 // fetch the URLRow, it is safe to assume that its |typed_count| is 0. | 93 // fetch the URLRow, it is safe to assume that its |typed_count| is 0. |
93 history::URLRow url; | 94 history::URLRow url; |
94 if (url_db && url_db->GetRowForURL((*i)->url(), &url)) | 95 if (url_db && url_db->GetRowForURL((*i)->url(), &url)) |
95 typed_count = url.typed_count(); | 96 typed_count = url.typed_count(); |
96 | 97 |
97 NodeTypedCountPair pair(*i, typed_count); | 98 NodeTypedCountPair pair(*i, typed_count); |
98 node_typed_count_pairs->push_back(pair); | 99 node_typed_count_pairs->push_back(pair); |
99 } | 100 } |
100 } | 101 } |
101 | 102 |
| 103 bool ChromeBookmarkClient::IsPermanentNodeVisible( |
| 104 const BookmarkPermanentNode* node) { |
| 105 DCHECK(node->type() == BookmarkNode::BOOKMARK_BAR || |
| 106 node->type() == BookmarkNode::OTHER_NODE || |
| 107 node->type() == BookmarkNode::MOBILE); |
| 108 #if !defined(OS_IOS) |
| 109 return node->type() != BookmarkNode::MOBILE; |
| 110 #else |
| 111 return node->type() == BookmarkNode::MOBILE; |
| 112 #endif |
| 113 } |
| 114 |
102 void ChromeBookmarkClient::RecordAction(const base::UserMetricsAction& action) { | 115 void ChromeBookmarkClient::RecordAction(const base::UserMetricsAction& action) { |
103 content::RecordAction(action); | 116 content::RecordAction(action); |
104 } | 117 } |
105 | 118 |
106 bool ChromeBookmarkClient::IsPermanentNodeVisible(int node_type) { | 119 bookmarks::LoadExtraCallback ChromeBookmarkClient::GetLoadExtraNodesCallback() { |
107 DCHECK(node_type == BookmarkNode::BOOKMARK_BAR || | 120 return base::Bind(&ChromeBookmarkClient::LoadExtraNodes); |
108 node_type == BookmarkNode::OTHER_NODE || | 121 } |
109 node_type == BookmarkNode::MOBILE); | 122 |
110 #if !defined(OS_IOS) | 123 bool ChromeBookmarkClient::CanRemovePermanentNodeChildren( |
111 return node_type != BookmarkNode::MOBILE; | 124 const BookmarkNode* node) { |
112 #else | 125 return true; |
113 return node_type == BookmarkNode::MOBILE; | 126 } |
114 #endif | 127 |
| 128 bool ChromeBookmarkClient::CanSetPermanentNodeTitle( |
| 129 const BookmarkNode* permanent_node) { |
| 130 return false; |
| 131 } |
| 132 |
| 133 bool ChromeBookmarkClient::CanSyncNode(const BookmarkNode* node) { |
| 134 return true; |
| 135 } |
| 136 |
| 137 bool ChromeBookmarkClient::CanReorderChildren(const BookmarkNode* parent) { |
| 138 return true; |
115 } | 139 } |
116 | 140 |
117 void ChromeBookmarkClient::Observe( | 141 void ChromeBookmarkClient::Observe( |
118 int type, | 142 int type, |
119 const content::NotificationSource& source, | 143 const content::NotificationSource& source, |
120 const content::NotificationDetails& details) { | 144 const content::NotificationDetails& details) { |
121 switch (type) { | 145 switch (type) { |
122 case chrome::NOTIFICATION_FAVICON_CHANGED: { | 146 case chrome::NOTIFICATION_FAVICON_CHANGED: { |
123 content::Details<FaviconChangedDetails> favicon_details(details); | 147 content::Details<FaviconChangedDetails> favicon_details(details); |
124 model_->OnFaviconChanged(favicon_details->urls); | 148 model_->OnFaviconChanged(favicon_details->urls); |
(...skipping 20 matching lines...) Loading... |
145 const BookmarkNode* node, | 169 const BookmarkNode* node, |
146 const std::set<GURL>& removed_urls) { | 170 const std::set<GURL>& removed_urls) { |
147 NotifyHistoryOfRemovedURLs(profile_, removed_urls); | 171 NotifyHistoryOfRemovedURLs(profile_, removed_urls); |
148 } | 172 } |
149 | 173 |
150 void ChromeBookmarkClient::BookmarkAllNodesRemoved( | 174 void ChromeBookmarkClient::BookmarkAllNodesRemoved( |
151 BookmarkModel* model, | 175 BookmarkModel* model, |
152 const std::set<GURL>& removed_urls) { | 176 const std::set<GURL>& removed_urls) { |
153 NotifyHistoryOfRemovedURLs(profile_, removed_urls); | 177 NotifyHistoryOfRemovedURLs(profile_, removed_urls); |
154 } | 178 } |
| 179 |
| 180 // static |
| 181 bookmarks::BookmarkPermanentNodeList ChromeBookmarkClient::LoadExtraNodes( |
| 182 int64* next_id) { |
| 183 // TODO(joaodasilva): load the managed node. http://crbug.com/49598 |
| 184 return bookmarks::BookmarkPermanentNodeList(); |
| 185 } |
OLD | NEW |