OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/extensions/theme_installed_infobar_delegate.h" | 5 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 InfoBarButton button) const { | 137 InfoBarButton button) const { |
138 DCHECK_EQ(BUTTON_CANCEL, button); | 138 DCHECK_EQ(BUTTON_CANCEL, button); |
139 return l10n_util::GetStringUTF16(IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON); | 139 return l10n_util::GetStringUTF16(IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON); |
140 } | 140 } |
141 | 141 |
142 bool ThemeInstalledInfoBarDelegate::Cancel() { | 142 bool ThemeInstalledInfoBarDelegate::Cancel() { |
143 if (!previous_theme_id_.empty()) { | 143 if (!previous_theme_id_.empty()) { |
144 const extensions::Extension* previous_theme = | 144 const extensions::Extension* previous_theme = |
145 extension_service_->GetExtensionById(previous_theme_id_, true); | 145 extension_service_->GetExtensionById(previous_theme_id_, true); |
146 if (previous_theme) { | 146 if (previous_theme) { |
147 theme_service_->RevertToTheme(previous_theme); | 147 theme_service_->SetTheme(previous_theme); |
148 // TODO(estade): while we're waiting to close, it would be nice to | |
149 // indicate that the theme is busy reverting. | |
150 return false; // The theme change will close us. | 148 return false; // The theme change will close us. |
151 } | 149 } |
152 } | 150 } |
153 | 151 |
154 if (previous_using_system_theme_) | 152 if (previous_using_system_theme_) |
155 theme_service_->UseSystemTheme(); | 153 theme_service_->UseSystemTheme(); |
156 else | 154 else |
157 theme_service_->UseDefaultTheme(); | 155 theme_service_->UseDefaultTheme(); |
158 return false; // The theme change will close us. | 156 return false; // The theme change will close us. |
159 } | 157 } |
160 | 158 |
161 void ThemeInstalledInfoBarDelegate::Observe( | 159 void ThemeInstalledInfoBarDelegate::Observe( |
162 int type, | 160 int type, |
163 const content::NotificationSource& source, | 161 const content::NotificationSource& source, |
164 const content::NotificationDetails& details) { | 162 const content::NotificationDetails& details) { |
165 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); | 163 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); |
166 // If the new theme is different from what this info bar is associated with, | 164 // If the new theme is different from what this info bar is associated with, |
167 // close this info bar since it is no longer relevant. | 165 // close this info bar since it is no longer relevant. |
168 if (theme_id_ != theme_service_->GetThemeID()) | 166 if (theme_id_ != theme_service_->GetThemeID()) |
169 infobar()->RemoveSelf(); | 167 infobar()->RemoveSelf(); |
170 } | 168 } |
OLD | NEW |