Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / themes / theme_syncable_service.h
blobc5bd8938979c99bf51a1be3ca4b16e0886ccd9df
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_THEMES_THEME_SYNCABLE_SERVICE_H_
6 #define CHROME_BROWSER_THEMES_THEME_SYNCABLE_SERVICE_H_
8 #include "base/gtest_prod_util.h"
9 #include "base/threading/thread_checker.h"
10 #include "sync/api/sync_change.h"
11 #include "sync/api/sync_data.h"
12 #include "sync/api/sync_error_factory.h"
13 #include "sync/api/sync_error.h"
14 #include "sync/api/syncable_service.h"
16 class Profile;
17 class ThemeService;
18 class ThemeSyncableServiceTest;
20 namespace sync_pb {
21 class ThemeSpecifics;
24 class ThemeSyncableService : public syncer::SyncableService {
25 public:
26 ThemeSyncableService(Profile* profile, // Same profile used by theme_service.
27 ThemeService* theme_service);
28 ~ThemeSyncableService() override;
30 static syncer::ModelType model_type() { return syncer::THEMES; }
32 // Called by ThemeService when user changes theme.
33 void OnThemeChange();
35 // syncer::SyncableService implementation.
36 syncer::SyncMergeResult MergeDataAndStartSyncing(
37 syncer::ModelType type,
38 const syncer::SyncDataList& initial_sync_data,
39 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
40 scoped_ptr<syncer::SyncErrorFactory> error_handler) override;
41 void StopSyncing(syncer::ModelType type) override;
42 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override;
43 syncer::SyncError ProcessSyncChanges(
44 const tracked_objects::Location& from_here,
45 const syncer::SyncChangeList& change_list) override;
47 // Client tag and tile of theme node in sync.
48 static const char kCurrentThemeClientTag[];
49 static const char kCurrentThemeNodeTitle[];
51 private:
52 static bool AreThemeSpecificsEqual(
53 const sync_pb::ThemeSpecifics& a,
54 const sync_pb::ThemeSpecifics& b,
55 bool is_system_theme_distinct_from_default_theme);
57 // Set theme from theme specifics in |sync_data| using
58 // SetCurrentThemeFromThemeSpecifics() if it's different from |current_specs|.
59 void MaybeSetTheme(const sync_pb::ThemeSpecifics& current_specs,
60 const syncer::SyncData& sync_data);
62 void SetCurrentThemeFromThemeSpecifics(
63 const sync_pb::ThemeSpecifics& theme_specifics);
65 // If the current theme is syncable, fills in the passed |theme_specifics|
66 // structure based on the currently applied theme and returns |true|.
67 // Otherwise returns |false|.
68 bool GetThemeSpecificsFromCurrentTheme(
69 sync_pb::ThemeSpecifics* theme_specifics) const;
71 // Updates theme specifics in sync to |theme_specifics|.
72 syncer::SyncError ProcessNewTheme(
73 syncer::SyncChange::SyncChangeType change_type,
74 const sync_pb::ThemeSpecifics& theme_specifics);
76 Profile* const profile_;
77 ThemeService* const theme_service_;
79 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
80 scoped_ptr<syncer::SyncErrorFactory> sync_error_handler_;
82 // Persist use_system_theme_by_default for platforms that use it, even if
83 // we're not on one.
84 bool use_system_theme_by_default_;
86 base::ThreadChecker thread_checker_;
88 FRIEND_TEST_ALL_PREFIXES(ThemeSyncableServiceTest, AreThemeSpecificsEqual);
90 DISALLOW_COPY_AND_ASSIGN(ThemeSyncableService);
93 #endif // CHROME_BROWSER_THEMES_THEME_SYNCABLE_SERVICE_H_