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

Side by Side Diff: chrome/browser/sync/glue/bookmark_model_associator.cc

Issue 8786006: Changes the visibility of the 'mobile' node based on whether (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/browser/sync/glue/bookmark_model_associator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/sync/glue/bookmark_model_associator.h" 5 #include "chrome/browser/sync/glue/bookmark_model_associator.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
180 DCHECK(bookmark_model_); 180 DCHECK(bookmark_model_);
181 DCHECK(user_share_); 181 DCHECK(user_share_);
182 DCHECK(unrecoverable_error_handler_); 182 DCHECK(unrecoverable_error_handler_);
183 } 183 }
184 184
185 BookmarkModelAssociator::~BookmarkModelAssociator() { 185 BookmarkModelAssociator::~BookmarkModelAssociator() {
186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
187 } 187 }
188 188
189 void BookmarkModelAssociator::UpdateMobileNodeVisibility() {
190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
191 if (!bookmark_model_->IsLoaded())
akalin 2011/12/03 00:17:05 hmm does the visibility get updated eventually whe
sky 2011/12/03 00:23:07 I would assume Associate is run at that point. But
Yaron 2011/12/05 18:40:12 Hmm. It looks like BookmarkChangeProcessor::Loaded
192 return;
193
194 int64 mobile_bookmarks_sync_id;
195 bookmark_model_->SetMobileFolderVisible(
196 GetSyncIdForTaggedNode(kMobileBookmarksTag, &mobile_bookmarks_sync_id));
197 }
198
189 bool BookmarkModelAssociator::DisassociateModels(SyncError* error) { 199 bool BookmarkModelAssociator::DisassociateModels(SyncError* error) {
190 id_map_.clear(); 200 id_map_.clear();
191 id_map_inverse_.clear(); 201 id_map_inverse_.clear();
192 dirty_associations_sync_ids_.clear(); 202 dirty_associations_sync_ids_.clear();
193 return true; 203 return true;
194 } 204 }
195 205
196 int64 BookmarkModelAssociator::GetSyncIdFromChromeId(const int64& node_id) { 206 int64 BookmarkModelAssociator::GetSyncIdFromChromeId(const int64& node_id) {
197 BookmarkIdToSyncIdMap::const_iterator iter = id_map_.find(node_id); 207 BookmarkIdToSyncIdMap::const_iterator iter = id_map_.find(node_id);
198 return iter == id_map_.end() ? sync_api::kInvalidId : iter->second; 208 return iter == id_map_.end() ? sync_api::kInvalidId : iter->second;
(...skipping 22 matching lines...) Expand all
221 int64 sync_id) { 231 int64 sync_id) {
222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
223 int64 node_id = node->id(); 233 int64 node_id = node->id();
224 DCHECK_NE(sync_id, sync_api::kInvalidId); 234 DCHECK_NE(sync_id, sync_api::kInvalidId);
225 DCHECK(id_map_.find(node_id) == id_map_.end()); 235 DCHECK(id_map_.find(node_id) == id_map_.end());
226 DCHECK(id_map_inverse_.find(sync_id) == id_map_inverse_.end()); 236 DCHECK(id_map_inverse_.find(sync_id) == id_map_inverse_.end());
227 id_map_[node_id] = sync_id; 237 id_map_[node_id] = sync_id;
228 id_map_inverse_[sync_id] = node; 238 id_map_inverse_[sync_id] = node;
229 dirty_associations_sync_ids_.insert(sync_id); 239 dirty_associations_sync_ids_.insert(sync_id);
230 PostPersistAssociationsTask(); 240 PostPersistAssociationsTask();
241 UpdateMobileNodeVisibility();
231 } 242 }
232 243
233 void BookmarkModelAssociator::Disassociate(int64 sync_id) { 244 void BookmarkModelAssociator::Disassociate(int64 sync_id) {
234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
235 SyncIdToBookmarkNodeMap::iterator iter = id_map_inverse_.find(sync_id); 246 SyncIdToBookmarkNodeMap::iterator iter = id_map_inverse_.find(sync_id);
236 if (iter == id_map_inverse_.end()) 247 if (iter == id_map_inverse_.end())
237 return; 248 return;
238 id_map_.erase(iter->second->id()); 249 id_map_.erase(iter->second->id());
239 id_map_inverse_.erase(iter); 250 id_map_inverse_.erase(iter);
240 dirty_associations_sync_ids_.erase(sync_id); 251 dirty_associations_sync_ids_.erase(sync_id);
akalin 2011/12/03 00:17:05 should we make the mobile folder invisible here?
sky 2011/12/03 00:23:07 I'm not sure either.
Yaron 2011/12/05 18:40:12 Nope. We should leave it the way it was.
241 } 252 }
242 253
243 bool BookmarkModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { 254 bool BookmarkModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) {
244 DCHECK(has_nodes); 255 DCHECK(has_nodes);
245 *has_nodes = false; 256 *has_nodes = false;
246 bool has_mobile_folder = true; 257 bool has_mobile_folder = true;
247 int64 bookmark_bar_sync_id; 258 int64 bookmark_bar_sync_id;
248 if (!GetSyncIdForTaggedNode(kBookmarkBarTag, &bookmark_bar_sync_id)) { 259 if (!GetSyncIdForTaggedNode(kBookmarkBarTag, &bookmark_bar_sync_id)) {
249 return false; 260 return false;
250 } 261 }
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 bool BookmarkModelAssociator::CryptoReadyIfNecessary() { 609 bool BookmarkModelAssociator::CryptoReadyIfNecessary() {
599 // We only access the cryptographer while holding a transaction. 610 // We only access the cryptographer while holding a transaction.
600 sync_api::ReadTransaction trans(FROM_HERE, user_share_); 611 sync_api::ReadTransaction trans(FROM_HERE, user_share_);
601 const syncable::ModelTypeSet& encrypted_types = 612 const syncable::ModelTypeSet& encrypted_types =
602 sync_api::GetEncryptedTypes(&trans); 613 sync_api::GetEncryptedTypes(&trans);
603 return encrypted_types.count(syncable::BOOKMARKS) == 0 || 614 return encrypted_types.count(syncable::BOOKMARKS) == 0 ||
604 trans.GetCryptographer()->is_ready(); 615 trans.GetCryptographer()->is_ready();
605 } 616 }
606 617
607 } // namespace browser_sync 618 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/bookmark_model_associator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698