OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/sync/glue/theme_change_processor.h" | 5 #include "chrome/browser/sync/glue/theme_change_processor.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/tracked.h" | 8 #include "base/tracked.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sync/engine/syncapi.h" | 10 #include "chrome/browser/sync/engine/syncapi.h" |
11 #include "chrome/browser/sync/glue/theme_util.h" | 11 #include "chrome/browser/sync/glue/theme_util.h" |
12 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" | 12 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" |
13 #include "chrome/browser/themes/theme_service.h" | 13 #include "chrome/browser/themes/theme_service.h" |
14 #include "chrome/browser/themes/theme_service_factory.h" | 14 #include "chrome/browser/themes/theme_service_factory.h" |
| 15 #include "chrome/common/chrome_notification_types.h" |
15 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
16 #include "content/common/notification_details.h" | 17 #include "content/common/notification_details.h" |
17 #include "content/common/notification_source.h" | 18 #include "content/common/notification_source.h" |
18 | 19 |
19 namespace browser_sync { | 20 namespace browser_sync { |
20 | 21 |
21 ThemeChangeProcessor::ThemeChangeProcessor( | 22 ThemeChangeProcessor::ThemeChangeProcessor( |
22 UnrecoverableErrorHandler* error_handler) | 23 UnrecoverableErrorHandler* error_handler) |
23 : ChangeProcessor(error_handler), | 24 : ChangeProcessor(error_handler), |
24 profile_(NULL) { | 25 profile_(NULL) { |
25 DCHECK(error_handler); | 26 DCHECK(error_handler); |
26 } | 27 } |
27 | 28 |
28 ThemeChangeProcessor::~ThemeChangeProcessor() {} | 29 ThemeChangeProcessor::~ThemeChangeProcessor() {} |
29 | 30 |
30 void ThemeChangeProcessor::Observe(NotificationType type, | 31 void ThemeChangeProcessor::Observe(int type, |
31 const NotificationSource& source, | 32 const NotificationSource& source, |
32 const NotificationDetails& details) { | 33 const NotificationDetails& details) { |
33 DCHECK(running()); | 34 DCHECK(running()); |
34 DCHECK(profile_); | 35 DCHECK(profile_); |
35 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); | 36 DCHECK(type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED); |
36 | 37 |
37 sync_api::WriteTransaction trans(FROM_HERE, share_handle()); | 38 sync_api::WriteTransaction trans(FROM_HERE, share_handle()); |
38 sync_api::WriteNode node(&trans); | 39 sync_api::WriteNode node(&trans); |
39 if (!node.InitByClientTagLookup(syncable::THEMES, | 40 if (!node.InitByClientTagLookup(syncable::THEMES, |
40 kCurrentThemeClientTag)) { | 41 kCurrentThemeClientTag)) { |
41 std::string err = "Could not create node with client tag: "; | 42 std::string err = "Could not create node with client tag: "; |
42 error_handler()->OnUnrecoverableError(FROM_HERE, | 43 error_handler()->OnUnrecoverableError(FROM_HERE, |
43 err + kCurrentThemeClientTag); | 44 err + kCurrentThemeClientTag); |
44 return; | 45 return; |
45 } | 46 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 115 |
115 void ThemeChangeProcessor::StopImpl() { | 116 void ThemeChangeProcessor::StopImpl() { |
116 StopObserving(); | 117 StopObserving(); |
117 profile_ = NULL; | 118 profile_ = NULL; |
118 } | 119 } |
119 | 120 |
120 void ThemeChangeProcessor::StartObserving() { | 121 void ThemeChangeProcessor::StartObserving() { |
121 DCHECK(profile_); | 122 DCHECK(profile_); |
122 VLOG(1) << "Observing BROWSER_THEME_CHANGED"; | 123 VLOG(1) << "Observing BROWSER_THEME_CHANGED"; |
123 notification_registrar_.Add( | 124 notification_registrar_.Add( |
124 this, NotificationType::BROWSER_THEME_CHANGED, | 125 this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
125 Source<ThemeService>( | 126 Source<ThemeService>( |
126 ThemeServiceFactory::GetForProfile(profile_))); | 127 ThemeServiceFactory::GetForProfile(profile_))); |
127 } | 128 } |
128 | 129 |
129 void ThemeChangeProcessor::StopObserving() { | 130 void ThemeChangeProcessor::StopObserving() { |
130 DCHECK(profile_); | 131 DCHECK(profile_); |
131 VLOG(1) << "Unobserving all notifications"; | 132 VLOG(1) << "Unobserving all notifications"; |
132 notification_registrar_.RemoveAll(); | 133 notification_registrar_.RemoveAll(); |
133 } | 134 } |
134 | 135 |
135 } // namespace browser_sync | 136 } // namespace browser_sync |
OLD | NEW |