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

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

Issue 305973004: BookmarkClient can add extra nodes to BookmarkModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanups Created 6 years, 6 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 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...) Expand 10 before | Expand all | Expand 10 after
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::CanRemoveNode(const BookmarkNode* node) {
111 return node_type != BookmarkNode::MOBILE; 124 return true;
112 #else 125 }
113 return node_type == BookmarkNode::MOBILE; 126
114 #endif 127 bool ChromeBookmarkClient::CanSetTitle(const BookmarkNode* permanent_node) {
128 return false;
129 }
130
131 bool ChromeBookmarkClient::CanSyncNode(const BookmarkNode* node) {
132 return true;
133 }
134
135 bool ChromeBookmarkClient::CanReorderChildren(const BookmarkNode* parent) {
136 return true;
115 } 137 }
116 138
117 void ChromeBookmarkClient::Observe( 139 void ChromeBookmarkClient::Observe(
118 int type, 140 int type,
119 const content::NotificationSource& source, 141 const content::NotificationSource& source,
120 const content::NotificationDetails& details) { 142 const content::NotificationDetails& details) {
121 switch (type) { 143 switch (type) {
122 case chrome::NOTIFICATION_FAVICON_CHANGED: { 144 case chrome::NOTIFICATION_FAVICON_CHANGED: {
123 content::Details<FaviconChangedDetails> favicon_details(details); 145 content::Details<FaviconChangedDetails> favicon_details(details);
124 model_->OnFaviconChanged(favicon_details->urls); 146 model_->OnFaviconChanged(favicon_details->urls);
(...skipping 20 matching lines...) Expand all
145 const BookmarkNode* node, 167 const BookmarkNode* node,
146 const std::set<GURL>& removed_urls) { 168 const std::set<GURL>& removed_urls) {
147 NotifyHistoryOfRemovedURLs(profile_, removed_urls); 169 NotifyHistoryOfRemovedURLs(profile_, removed_urls);
148 } 170 }
149 171
150 void ChromeBookmarkClient::BookmarkAllNodesRemoved( 172 void ChromeBookmarkClient::BookmarkAllNodesRemoved(
151 BookmarkModel* model, 173 BookmarkModel* model,
152 const std::set<GURL>& removed_urls) { 174 const std::set<GURL>& removed_urls) {
153 NotifyHistoryOfRemovedURLs(profile_, removed_urls); 175 NotifyHistoryOfRemovedURLs(profile_, removed_urls);
154 } 176 }
177
178 // static
179 bookmarks::BookmarkPermanentNodeList ChromeBookmarkClient::LoadExtraNodes(
180 int64* next_id) {
181 // TODO(joaodasilva): load the managed node. http://crbug.com/49598
182 return bookmarks::BookmarkPermanentNodeList();
183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698