| 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_->SetTheme(previous_theme); | 147 theme_service_->RevertToTheme(previous_theme); |
| 148 // TODO(estade): while we're waiting to close, it would be nice to |
| 149 // indicate that the theme is busy reverting. |
| 148 return false; // The theme change will close us. | 150 return false; // The theme change will close us. |
| 149 } | 151 } |
| 150 } | 152 } |
| 151 | 153 |
| 152 if (previous_using_system_theme_) | 154 if (previous_using_system_theme_) |
| 153 theme_service_->UseSystemTheme(); | 155 theme_service_->UseSystemTheme(); |
| 154 else | 156 else |
| 155 theme_service_->UseDefaultTheme(); | 157 theme_service_->UseDefaultTheme(); |
| 156 return false; // The theme change will close us. | 158 return false; // The theme change will close us. |
| 157 } | 159 } |
| 158 | 160 |
| 159 void ThemeInstalledInfoBarDelegate::Observe( | 161 void ThemeInstalledInfoBarDelegate::Observe( |
| 160 int type, | 162 int type, |
| 161 const content::NotificationSource& source, | 163 const content::NotificationSource& source, |
| 162 const content::NotificationDetails& details) { | 164 const content::NotificationDetails& details) { |
| 163 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); | 165 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); |
| 164 // If the new theme is different from what this info bar is associated with, | 166 // If the new theme is different from what this info bar is associated with, |
| 165 // close this info bar since it is no longer relevant. | 167 // close this info bar since it is no longer relevant. |
| 166 if (theme_id_ != theme_service_->GetThemeID()) | 168 if (theme_id_ != theme_service_->GetThemeID()) |
| 167 infobar()->RemoveSelf(); | 169 infobar()->RemoveSelf(); |
| 168 } | 170 } |
| OLD | NEW |