1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__
6 #define CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
12 #include "chrome/browser/sync/glue/frontend_data_type_controller.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
16 namespace browser_sync {
18 // A class that manages the startup and shutdown of bookmark sync.
19 class BookmarkDataTypeController : public FrontendDataTypeController,
20 public content::NotificationObserver,
21 public BaseBookmarkModelObserver {
23 BookmarkDataTypeController(ProfileSyncComponentsFactory* profile_sync_factory,
25 ProfileSyncService* sync_service);
27 // FrontendDataTypeController interface.
28 virtual syncer::ModelType type() const OVERRIDE;
30 // content::NotificationObserver interface.
31 virtual void Observe(int type,
32 const content::NotificationSource& source,
33 const content::NotificationDetails& details) OVERRIDE;
36 virtual ~BookmarkDataTypeController();
38 // FrontendDataTypeController interface.
39 virtual bool StartModels() OVERRIDE;
40 virtual void CleanUpState() OVERRIDE;
41 virtual void CreateSyncComponents() OVERRIDE;
43 // BaseBookmarkModelObserver interface.
44 virtual void BookmarkModelChanged() OVERRIDE;
45 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE;
46 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE;
48 // Helper that returns true iff both the bookmark model and the history
49 // service have finished loading.
50 bool DependentsLoaded();
52 content::NotificationRegistrar registrar_;
54 BookmarkModel* bookmark_model_;
56 // Have we installed ourselves as a BookmarkModel observer?
57 bool installed_bookmark_observer_;
59 DISALLOW_COPY_AND_ASSIGN(BookmarkDataTypeController);
62 } // namespace browser_sync
64 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_DATA_TYPE_CONTROLLER_H__