Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: chrome/browser/extensions/theme_installed_infobar_delegate.cc

Issue 2799003002: Unpack theme data from extensions off of UI thread. (Closed)
Patch Set: fix BrowserThemePackUnittest: data race and shutdown sequence Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 InfoBarButton button) const { 138 InfoBarButton button) const {
139 DCHECK_EQ(BUTTON_CANCEL, button); 139 DCHECK_EQ(BUTTON_CANCEL, button);
140 return l10n_util::GetStringUTF16(IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON); 140 return l10n_util::GetStringUTF16(IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON);
141 } 141 }
142 142
143 bool ThemeInstalledInfoBarDelegate::Cancel() { 143 bool ThemeInstalledInfoBarDelegate::Cancel() {
144 if (!previous_theme_id_.empty()) { 144 if (!previous_theme_id_.empty()) {
145 const extensions::Extension* previous_theme = 145 const extensions::Extension* previous_theme =
146 extension_service_->GetExtensionById(previous_theme_id_, true); 146 extension_service_->GetExtensionById(previous_theme_id_, true);
147 if (previous_theme) { 147 if (previous_theme) {
148 theme_service_->SetTheme(previous_theme); 148 theme_service_->RevertToTheme(previous_theme);
149 // TODO(estade): while we're waiting to close, it would be nice to
150 // indicate that the theme is busy reverting.
149 return false; // The theme change will close us. 151 return false; // The theme change will close us.
150 } 152 }
151 } 153 }
152 154
153 if (previous_using_system_theme_) 155 if (previous_using_system_theme_)
154 theme_service_->UseSystemTheme(); 156 theme_service_->UseSystemTheme();
155 else 157 else
156 theme_service_->UseDefaultTheme(); 158 theme_service_->UseDefaultTheme();
157 return false; // The theme change will close us. 159 return false; // The theme change will close us.
158 } 160 }
159 161
160 void ThemeInstalledInfoBarDelegate::Observe( 162 void ThemeInstalledInfoBarDelegate::Observe(
161 int type, 163 int type,
162 const content::NotificationSource& source, 164 const content::NotificationSource& source,
163 const content::NotificationDetails& details) { 165 const content::NotificationDetails& details) {
164 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); 166 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type);
165 // If the new theme is different from what this info bar is associated with, 167 // If the new theme is different from what this info bar is associated with,
166 // close this info bar since it is no longer relevant. 168 // close this info bar since it is no longer relevant.
167 if (theme_id_ != theme_service_->GetThemeID()) 169 if (theme_id_ != theme_service_->GetThemeID())
168 infobar()->RemoveSelf(); 170 infobar()->RemoveSelf();
169 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698