Commit 1da5f717 authored by sky@chromium.org's avatar sky@chromium.org

Revert 113112 - Revert 113103 - Changes the visibility of the 'mobile' node...

Revert 113112 - Revert 113103 - Changes the visibility of the 'mobile' node based on whether there is a node on the sync side.

BUG=102714
TEST=none

Review URL: http://codereview.chromium.org/8786006

TBR=sky@chromium.org
Review URL: http://codereview.chromium.org/8819008

TBR=sky@chromium.org
Review URL: http://codereview.chromium.org/8818004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113117 0039d316-1c4b-4281-b951-d872f2087c98
parent 4f8c5e03
......@@ -108,6 +108,8 @@ class MobileNode : public BookmarkNode {
explicit MobileNode(int64 id);
virtual ~MobileNode();
void set_visible(bool value) { visible_ = value; }
// BookmarkNode overrides:
virtual bool IsVisible() const OVERRIDE;
......@@ -546,6 +548,11 @@ void BookmarkModel::ClearStore() {
store_ = NULL;
}
void BookmarkModel::SetMobileFolderVisible(bool value) {
DCHECK(loaded_);
static_cast<MobileNode*>(mobile_node_)->set_visible(value);
}
bool BookmarkModel::IsBookmarkedNoLock(const GURL& url) {
BookmarkNode tmp_node(url);
return (nodes_ordered_by_url_set_.find(&tmp_node) !=
......
......@@ -329,6 +329,9 @@ class BookmarkModel : public content::NotificationObserver,
return expanded_state_tracker_.get();
}
// Sets whether the mobile folder is visible. This is set by sync.
void SetMobileFolderVisible(bool value);
private:
friend class BookmarkCodecTest;
friend class BookmarkModelTest;
......
......@@ -6,11 +6,13 @@
#include <string>
#include "base/command_line.h"
#include "chrome/browser/sync/engine/syncer.h"
#include "chrome/browser/sync/engine/syncer_proto_util.h"
#include "chrome/browser/sync/engine/syncproto.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/model_type_payload_map.h"
#include "chrome/common/chrome_switches.h"
using syncable::ScopedDirLookup;
......@@ -35,8 +37,10 @@ void DownloadUpdatesCommand::ExecuteImpl(SyncSession* session) {
ClientToServerMessage::GET_UPDATES);
GetUpdatesMessage* get_updates =
client_to_server_message.mutable_get_updates();
// TODO: make this default to true.
get_updates->set_include_syncable_bookmarks(true);
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kCreateMobileBookmarksFolder)) {
get_updates->set_include_syncable_bookmarks(true);
}
ScopedDirLookup dir(session->context()->directory_manager(),
session->context()->account_name());
......
......@@ -451,6 +451,9 @@ void BookmarkChangeProcessor::ApplyChangesFromSyncModel(
foster_parent = NULL;
}
// The visibility of the mobile node may need to change.
model_associator_->UpdateMobileNodeVisibility();
// We are now ready to hear about bookmarks changes again.
model->AddObserver(this);
}
......
......@@ -186,6 +186,14 @@ BookmarkModelAssociator::~BookmarkModelAssociator() {
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 @@ void BookmarkModelAssociator::Associate(const BookmarkNode* node,
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 @@ bool BookmarkModelAssociator::BuildAssociations(SyncError* error) {
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 @@ bool BookmarkModelAssociator::BuildAssociations(SyncError* error) {
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 @@ bool BookmarkModelAssociator::LoadAssociations() {
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.
......
......@@ -40,6 +40,10 @@ class BookmarkModelAssociator
UnrecoverableErrorHandler* unrecoverable_error_handler);
virtual ~BookmarkModelAssociator();
// Invokes BookmarkModel::SetMobileFolderVisible() based on whether the mobile
// node exists.
void UpdateMobileNodeVisibility();
// AssociatorInterface implementation.
//
// AssociateModels iterates through both the sync and the browser
......
......@@ -296,6 +296,8 @@ class ProfileSyncServiceBookmarkTest : public testing::Test {
virtual void SetUp() {
test_user_share_.SetUp();
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kCreateMobileBookmarksFolder);
}
virtual void TearDown() {
......
......@@ -190,6 +190,9 @@ const char kCrashOnHangThreads[] = "crash-on-hang-threads";
// other threads are not responsive.
const char kCrashOnLive[] = "crash-on-live";
// If true the mobile bookmarks folder is created on the sync side.
const char kCreateMobileBookmarksFolder[] = "create-mobile-bookmarks-folder";
// Path to the inspector files on disk (allows reloading of devtool files
// without having to restart the browser).
const char kDebugDevToolsFrontend[] = "debug-devtools-frontend";
......@@ -567,9 +570,6 @@ const char kEnableSyncTabsForOtherClients[] =
// Enables context menu for selecting groups of tabs.
const char kEnableTabGroupsContextMenu[] = "enable-tab-groups-context-menu";
// Enables the "synced bookmarks" folder.
const char kEnableSyncedBookmarksFolder[] = "enable-synced-bookmarks-folder";
// Spawns threads to watch for excessive delays in specified message loops.
// User should set breakpoints on Alarm() to examine problematic thread.
//
......
......@@ -64,6 +64,7 @@ extern const char kCountry[];
extern const char kCrashOnHangSeconds[];
extern const char kCrashOnHangThreads[];
extern const char kCrashOnLive[];
extern const char kCreateMobileBookmarksFolder[];
extern const char kDebugDevToolsFrontend[];
extern const char kDebugEnableFrameToggle[];
extern const char kDebugPrint[];
......@@ -162,7 +163,6 @@ extern const char kEnableSyncExtensionSettings[];
extern const char kEnableSyncOAuth[];
extern const char kEnableSyncTabs[];
extern const char kEnableSyncTabsForOtherClients[];
extern const char kEnableSyncedBookmarksFolder[];
extern const char kEnableTabGroupsContextMenu[];
extern const char kEnableTopSites[];
extern const char kEnableWatchdog[];
......
......@@ -394,8 +394,6 @@ class SyncDataModel(object):
parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK),
PermanentItem('other_bookmarks', name='Other Bookmarks',
parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK),
PermanentItem('synced_bookmarks', name='Mobile Bookmarks',
parent_tag='google_chrome_bookmarks', sync_type=BOOKMARK),
PermanentItem('google_chrome_preferences', name='Preferences',
parent_tag='google_chrome', sync_type=PREFERENCE),
PermanentItem('google_chrome_autofill', name='Autofill',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment