OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/sync/engine/syncapi.h" | 9 #include "chrome/browser/sync/engine/syncapi.h" |
10 #include "chrome/browser/sync/glue/theme_util.h" | 10 #include "chrome/browser/sync/glue/theme_util.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 DCHECK(error_handler); | 32 DCHECK(error_handler); |
33 } | 33 } |
34 | 34 |
35 ThemeChangeProcessor::~ThemeChangeProcessor() {} | 35 ThemeChangeProcessor::~ThemeChangeProcessor() {} |
36 | 36 |
37 void ThemeChangeProcessor::Observe(NotificationType type, | 37 void ThemeChangeProcessor::Observe(NotificationType type, |
38 const NotificationSource& source, | 38 const NotificationSource& source, |
39 const NotificationDetails& details) { | 39 const NotificationDetails& details) { |
40 DCHECK(running()); | 40 DCHECK(running()); |
41 DCHECK(profile_); | 41 DCHECK(profile_); |
42 const Extension* extension = Details<const Extension>(details).ptr(); | 42 const Extension* extension = NULL; |
| 43 if (type == NotificationType::EXTENSION_UNLOADED) { |
| 44 extension = Details<UnloadedExtensionInfo>(details)->extension; |
| 45 } else { |
| 46 extension = Details<const Extension>(details).ptr(); |
| 47 } |
43 std::string current_or_future_theme_id = | 48 std::string current_or_future_theme_id = |
44 profile_->GetThemeProvider()->GetThemeID(); | 49 profile_->GetThemeProvider()->GetThemeID(); |
45 const Extension* current_theme = profile_->GetTheme(); | 50 const Extension* current_theme = profile_->GetTheme(); |
46 switch (type.value) { | 51 switch (type.value) { |
47 case NotificationType::BROWSER_THEME_CHANGED: | 52 case NotificationType::BROWSER_THEME_CHANGED: |
48 // We pay attention to this notification only when it signifies | 53 // We pay attention to this notification only when it signifies |
49 // that a user changed the theme to the default/system theme, or | 54 // that a user changed the theme to the default/system theme, or |
50 // when it signifies that a user changed the theme to a custom | 55 // when it signifies that a user changed the theme to a custom |
51 // one that was already installed. Otherwise, current_theme | 56 // one that was already installed. Otherwise, current_theme |
52 // still points to the previous theme until it gets installed | 57 // still points to the previous theme until it gets installed |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 Source<Profile>(profile_)); | 211 Source<Profile>(profile_)); |
207 } | 212 } |
208 | 213 |
209 void ThemeChangeProcessor::StopObserving() { | 214 void ThemeChangeProcessor::StopObserving() { |
210 DCHECK(profile_); | 215 DCHECK(profile_); |
211 VLOG(1) << "Unobserving all notifications"; | 216 VLOG(1) << "Unobserving all notifications"; |
212 notification_registrar_.RemoveAll(); | 217 notification_registrar_.RemoveAll(); |
213 } | 218 } |
214 | 219 |
215 } // namespace browser_sync | 220 } // namespace browser_sync |
OLD | NEW |