summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-12 17:23:43 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-12 17:23:43 +0000
commiteec3bcfa9e92a62fef68293ccbef32b6ef98eea7 (patch)
tree0935285f90235f0303659055197f179fb5d7c23b
parentfc701137f192ee798ee6d9a41cf11fcb34d218bb (diff)
downloadchromium_src-eec3bcfa9e92a62fef68293ccbef32b6ef98eea7.zip
chromium_src-eec3bcfa9e92a62fef68293ccbef32b6ef98eea7.tar.gz
chromium_src-eec3bcfa9e92a62fef68293ccbef32b6ef98eea7.tar.bz2
Turn on sync for OS X (behind an --enable-sync switch).
Added ProfileSyncService::IsSyncEnabled(). BUG=23073 TEST=manually (OS X),trybot Review URL: http://codereview.chromium.org/389019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31789 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc6
-rw-r--r--chrome/browser/profile.cc12
-rw-r--r--chrome/browser/sync/profile_sync_service.cc8
-rw-r--r--chrome/browser/sync/profile_sync_service.h5
-rw-r--r--chrome/browser/views/toolbar_view.cc3
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
7 files changed, 26 insertions, 12 deletions
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index 87181f0..2b4174b 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -31,6 +31,7 @@
#include "chrome/browser/sessions/session_types.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/sessions/tab_restore_service.h"
+#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/user_data_manager.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/jstemplate_builder.h"
@@ -565,12 +566,9 @@ NewTabUI::NewTabUI(TabContents* contents)
AddMessageHandler((new MetricsHandler())->Attach(this));
if (WebResourcesEnabled())
AddMessageHandler((new TipsHandler())->Attach(this));
-
-#if !defined(OS_POSIX)
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync)) {
+ if (ProfileSyncService::IsSyncEnabled()) {
AddMessageHandler((new NewTabPageSyncHandler())->Attach(this));
}
-#endif
AddMessageHandler((new NewTabPageSetHomepageHandler())->Attach(this));
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 59010e6..dd2835e 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -1439,14 +1439,12 @@ void ProfileImpl::StopCreateSessionServiceTimer() {
}
ProfileSyncService* ProfileImpl::GetProfileSyncService() {
-#if !defined(OS_POSIX)
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync)) {
- if (!sync_service_.get())
- InitSyncService();
- return sync_service_.get();
+ if (!ProfileSyncService::IsSyncEnabled()) {
+ return NULL;
}
-#endif
- return NULL;
+ if (!sync_service_.get())
+ InitSyncService();
+ return sync_service_.get();
}
void ProfileImpl::InitSyncService() {
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index d8a6b00..953ebd3 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -423,6 +423,14 @@ void ProfileSyncService::SyncEvent(SyncEventCodes code) {
histogram.Add(code);
}
+bool ProfileSyncService::IsSyncEnabled() {
+#if defined(OS_POSIX)
+ return CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableSync);
+#else
+ return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync);
+#endif
+}
+
bool ProfileSyncService::ShouldPushChanges() {
// True only after all bootstrapping has succeeded: the bookmark model is
// loaded, the sync backend is initialized, the two domains are
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 6730226..a738311 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -195,6 +195,11 @@ class ProfileSyncService : public NotificationObserver,
// Record stats on various events.
static void SyncEvent(SyncEventCodes code);
+ // Returns whether sync is enabled. Sync can be enabled/disabled both
+ // at compile time (e.g., on a per-OS basis) or at run time (e.g.,
+ // command-line switches).
+ static bool IsSyncEnabled();
+
// UnrecoverableErrorHandler implementation.
virtual void OnUnrecoverableError();
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index 63b32ae..0747331 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/encoding_menu_controller.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/sync_status_ui_helper.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
@@ -1176,7 +1177,7 @@ void ToolbarView::CreateAppMenu() {
IDS_SHOW_EXTENSIONS);
app_menu_contents_->AddSeparator();
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync)) {
+ if (ProfileSyncService::IsSyncEnabled()) {
string16 label;
string16 link;
// TODO(timsteele): Need a ui helper method to just get the type without
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index e91f5d1..072f02e 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -226,6 +226,9 @@ const char kEnableSharedWorkers[] = "enable-shared-workers";
// Enables StatsTable, logging statistics to a global named shared memory table.
const char kEnableStatsTable[] = "enable-stats-table";
+// Enable syncing bookmarks to a Google Account.
+const char kEnableSync[] = "enable-sync";
+
// Enables the new Tabstrip on Windows.
const char kEnableTabtastic2[] = "enable-tabtastic2";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index fea5e43..ff8ac12 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -80,6 +80,7 @@ extern const char kEnableSeccompSandbox[];
extern const char kEnableSessionStorage[];
extern const char kEnableSharedWorkers[];
extern const char kEnableStatsTable[];
+extern const char kEnableSync[];
extern const char kEnableTabtastic2[];
extern const char kEnableUserDataDirProfiles[];
extern const char kEnableUserScripts[];