OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/extensions/extensions_service.h" | 10 #include "chrome/browser/extensions/extensions_service.h" |
11 #include "chrome/browser/profile.h" | 11 #include "chrome/browser/profile.h" |
12 #include "chrome/browser/tab_contents/tab_contents.h" | 12 #include "chrome/browser/tab_contents/tab_contents.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
15 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
16 | 16 |
17 ThemeInstalledInfoBarDelegate::ThemeInstalledInfoBarDelegate( | 17 ThemeInstalledInfoBarDelegate::ThemeInstalledInfoBarDelegate( |
18 TabContents* tab_contents, const Extension* new_theme, | 18 TabContents* tab_contents, const Extension* new_theme, |
19 const std::string& previous_theme_id) | 19 const std::string& previous_theme_id) |
20 : ConfirmInfoBarDelegate(tab_contents), | 20 : ConfirmInfoBarDelegate(tab_contents), |
21 was_canceled_(false), | 21 was_canceled_(false), |
22 profile_(tab_contents->profile()), | 22 profile_(tab_contents->profile()), |
23 name_(new_theme->name()), | 23 name_(new_theme->name()), |
24 new_theme_id_(new_theme->id()), | 24 new_theme_id_(new_theme->id()), |
25 previous_theme_id_(previous_theme_id) { | 25 previous_theme_id_(previous_theme_id) { |
26 } | 26 } |
27 | 27 |
28 void ThemeInstalledInfoBarDelegate::InfoBarClosed() { | 28 void ThemeInstalledInfoBarDelegate::InfoBarClosed() { |
29 ExtensionsService* service = profile_->GetExtensionsService(); | 29 ExtensionsService* service = profile_->GetExtensionsService(); |
30 if (service) { | 30 // Only delete the theme if we've installed a new theme and not the same |
| 31 // theme on top of the current one. |
| 32 if (service && previous_theme_id_ != new_theme_id_) { |
31 std::string uninstall_id; | 33 std::string uninstall_id; |
32 if (was_canceled_) | 34 if (was_canceled_) |
33 uninstall_id = new_theme_id_; | 35 uninstall_id = new_theme_id_; |
34 else if (!previous_theme_id_.empty()) | 36 else if (!previous_theme_id_.empty()) |
35 uninstall_id = previous_theme_id_; | 37 uninstall_id = previous_theme_id_; |
36 // It's possible that the theme was already uninstalled by someone so make | 38 // It's possible that the theme was already uninstalled by someone so make |
37 // sure it exists. | 39 // sure it exists. |
38 if (!uninstall_id.empty() && service->GetExtensionById(uninstall_id, true)) | 40 if (!uninstall_id.empty() && service->GetExtensionById(uninstall_id, true)) |
39 service->UninstallExtension(uninstall_id, false); | 41 service->UninstallExtension(uninstall_id, false); |
40 } | 42 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 if (previous_theme) { | 87 if (previous_theme) { |
86 profile_->SetTheme(previous_theme); | 88 profile_->SetTheme(previous_theme); |
87 return true; | 89 return true; |
88 } | 90 } |
89 } | 91 } |
90 } | 92 } |
91 | 93 |
92 profile_->ClearTheme(); | 94 profile_->ClearTheme(); |
93 return true; | 95 return true; |
94 } | 96 } |
OLD | NEW |