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

Unified Diff: chrome/browser/sync/glue/bookmark_model_associator.cc

Issue 8818004: Revert 113112 - Revert 113103 - Changes the visibility of the 'mobile' node based on whether ther... (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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/glue/bookmark_model_associator.cc
===================================================================
--- chrome/browser/sync/glue/bookmark_model_associator.cc (revision 113116)
+++ chrome/browser/sync/glue/bookmark_model_associator.cc (working copy)
@@ -186,6 +186,14 @@
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
+void BookmarkModelAssociator::UpdateMobileNodeVisibility() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(bookmark_model_->IsLoaded());
+
+ bookmark_model_->SetMobileFolderVisible(
+ id_map_.find(bookmark_model_->mobile_node()->id()) != id_map_.end());
+}
+
bool BookmarkModelAssociator::DisassociateModels(SyncError* error) {
id_map_.clear();
id_map_inverse_.clear();
@@ -228,6 +236,7 @@
id_map_inverse_[sync_id] = node;
dirty_associations_sync_ids_.insert(sync_id);
PostPersistAssociationsTask();
+ UpdateMobileNodeVisibility();
}
void BookmarkModelAssociator::Disassociate(int64 sync_id) {
@@ -368,10 +377,15 @@
error->Reset(FROM_HERE, kServerError, model_type());
return false;
}
- // The mobile folder isn't always present on the backend, so we don't fail if
- // it doesn't exist.
- ignore_result(AssociateTaggedPermanentNode(bookmark_model_->mobile_node(),
- kMobileBookmarksTag));
+ if (!AssociateTaggedPermanentNode(bookmark_model_->mobile_node(),
+ kMobileBookmarksTag) &&
+ // The mobile folder only need exist if kCreateMobileBookmarksFolder is
+ // set.
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kCreateMobileBookmarksFolder)) {
+ error->Reset(FROM_HERE, kServerError, model_type());
+ return false;
+ }
int64 bookmark_bar_sync_id = GetSyncIdFromChromeId(
bookmark_model_->bookmark_bar_node()->id());
DCHECK_NE(bookmark_bar_sync_id, sync_api::kInvalidId);
@@ -380,6 +394,10 @@
DCHECK_NE(other_bookmarks_sync_id, sync_api::kInvalidId);
int64 mobile_bookmarks_sync_id = GetSyncIdFromChromeId(
bookmark_model_->mobile_node()->id());
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kCreateMobileBookmarksFolder)) {
+ DCHECK_NE(sync_api::kInvalidId, mobile_bookmarks_sync_id);
+ }
std::stack<int64> dfs_stack;
if (mobile_bookmarks_sync_id != sync_api::kInvalidId)
@@ -523,9 +541,11 @@
return false;
}
int64 mobile_bookmarks_id = -1;
- // Can't fail here as the mobile folder may not exist.
- ignore_result(
- GetSyncIdForTaggedNode(kMobileBookmarksTag, &mobile_bookmarks_id));
+ if (!GetSyncIdForTaggedNode(kMobileBookmarksTag, &mobile_bookmarks_id) &&
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kCreateMobileBookmarksFolder)) {
+ return false;
+ }
// Build a bookmark node ID index since we are going to repeatedly search for
// bookmark nodes by their IDs.
« no previous file with comments | « chrome/browser/sync/glue/bookmark_model_associator.h ('k') | chrome/browser/sync/profile_sync_service_bookmark_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698