summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/profile_sync_service.cc
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-01 07:42:12 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-01 07:42:12 +0000
commitf92351d68c2089e7e36c00a4789ad3a199921ebc (patch)
tree49f4e1438481c33f37338178ca0515b597173b2d /chrome/browser/sync/profile_sync_service.cc
parent14c5c9c368d6f38c09b7cf3d170b2b55caf93ffd (diff)
downloadchromium_src-f92351d68c2089e7e36c00a4789ad3a199921ebc.zip
chromium_src-f92351d68c2089e7e36c00a4789ad3a199921ebc.tar.gz
chromium_src-f92351d68c2089e7e36c00a4789ad3a199921ebc.tar.bz2
[Sync] Add JS scriptability to syncapi
Add plumbing for ProfileSyncService, SyncBackendHost, and SyncManager to be able to listen for messages and emit events to chrome://sync-internals. Add initial version of notification-related messages and events and hook it up to chrome://sync-internals. Added rudimentary display for notifications to chrome://sync-internals. Changed DOMUI class slightly to be more testable. BUG=69500 TEST= Review URL: http://codereview.chromium.org/6379010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73263 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/profile_sync_service.cc')
-rw-r--r--chrome/browser/sync/profile_sync_service.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 4ea3c79..bb25585 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -30,9 +30,9 @@
#include "chrome/browser/sync/glue/data_type_controller.h"
#include "chrome/browser/sync/glue/data_type_manager.h"
#include "chrome/browser/sync/glue/session_data_type_controller.h"
+#include "chrome/browser/sync/js_arg_list.h"
#include "chrome/browser/sync/profile_sync_factory.h"
#include "chrome/browser/sync/signin_manager.h"
-#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/sync/token_migrator.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/net/gaia/gaia_constants.h"
@@ -78,9 +78,9 @@ ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory,
sync_service_url_(kDevServerUrl),
backend_initialized_(false),
is_auth_in_progress_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(wizard_(this)),
+ wizard_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
unrecoverable_error_detected_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(scoped_runnable_method_factory_(this)),
+ scoped_runnable_method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
token_migrator_(NULL),
clear_server_data_state_(CLEAR_NOT_STARTED) {
DCHECK(factory);
@@ -475,6 +475,8 @@ void ProfileSyncService::Shutdown(bool sync_disabled) {
data_type_manager_.reset();
}
+ js_event_handlers_.RemoveBackend();
+
// Move aside the backend so nobody else tries to use it while we are
// shutting it down.
scoped_ptr<SyncBackendHost> doomed_backend(backend_.release());
@@ -538,6 +540,8 @@ void ProfileSyncService::UpdateLastSyncedTime() {
void ProfileSyncService::NotifyObservers() {
FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged());
+ js_event_handlers_.RouteJsEvent(
+ "onSyncServiceStateChanged", browser_sync::JsArgList(), NULL);
}
// static
@@ -602,6 +606,8 @@ void ProfileSyncService::OnUnrecoverableError(
void ProfileSyncService::OnBackendInitialized() {
backend_initialized_ = true;
+ js_event_handlers_.SetBackend(backend_->GetJsBackend());
+
// The very first time the backend initializes is effectively the first time
// we can say we successfully "synced". last_synced_time_ will only be null
// in this case, because the pref wasn't restored on StartUp.
@@ -1282,6 +1288,10 @@ bool ProfileSyncService::HasObserver(Observer* observer) const {
return observers_.HasObserver(observer);
}
+browser_sync::JsFrontend* ProfileSyncService::GetJsFrontend() {
+ return &js_event_handlers_;
+}
+
void ProfileSyncService::SyncEvent(SyncEventCodes code) {
UMA_HISTOGRAM_ENUMERATION("Sync.EventCodes", code, MAX_SYNC_EVENT_CODE);
}