| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 Browser* browser = chrome::FindTabbedBrowser(profile, true); | 44 Browser* browser = chrome::FindTabbedBrowser(profile, true); |
| 45 if (!browser) | 45 if (!browser) |
| 46 return; | 46 return; |
| 47 content::WebContents* web_contents = | 47 content::WebContents* web_contents = |
| 48 browser->tab_strip_model()->GetActiveWebContents(); | 48 browser->tab_strip_model()->GetActiveWebContents(); |
| 49 if (!web_contents) | 49 if (!web_contents) |
| 50 return; | 50 return; |
| 51 InfoBarService* infobar_service = | 51 InfoBarService* infobar_service = |
| 52 InfoBarService::FromWebContents(web_contents); | 52 InfoBarService::FromWebContents(web_contents); |
| 53 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); | 53 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); |
| 54 scoped_ptr<infobars::InfoBar> new_infobar( | 54 std::unique_ptr<infobars::InfoBar> new_infobar( |
| 55 infobar_service->CreateConfirmInfoBar( | 55 infobar_service->CreateConfirmInfoBar( |
| 56 scoped_ptr<ConfirmInfoBarDelegate>(new ThemeInstalledInfoBarDelegate( | 56 std::unique_ptr< |
| 57 ConfirmInfoBarDelegate>(new ThemeInstalledInfoBarDelegate( |
| 57 extensions::ExtensionSystem::Get(profile)->extension_service(), | 58 extensions::ExtensionSystem::Get(profile)->extension_service(), |
| 58 theme_service, new_theme, previous_theme_id, | 59 theme_service, new_theme, previous_theme_id, |
| 59 previous_using_system_theme)))); | 60 previous_using_system_theme)))); |
| 60 | 61 |
| 61 // If there's a previous theme infobar, just replace that instead of adding a | 62 // If there's a previous theme infobar, just replace that instead of adding a |
| 62 // new one. | 63 // new one. |
| 63 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { | 64 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
| 64 infobars::InfoBar* old_infobar = infobar_service->infobar_at(i); | 65 infobars::InfoBar* old_infobar = infobar_service->infobar_at(i); |
| 65 ThemeInstalledInfoBarDelegate* theme_infobar = | 66 ThemeInstalledInfoBarDelegate* theme_infobar = |
| 66 old_infobar->delegate()->AsThemePreviewInfobarDelegate(); | 67 old_infobar->delegate()->AsThemePreviewInfobarDelegate(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 void ThemeInstalledInfoBarDelegate::Observe( | 168 void ThemeInstalledInfoBarDelegate::Observe( |
| 168 int type, | 169 int type, |
| 169 const content::NotificationSource& source, | 170 const content::NotificationSource& source, |
| 170 const content::NotificationDetails& details) { | 171 const content::NotificationDetails& details) { |
| 171 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); | 172 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); |
| 172 // If the new theme is different from what this info bar is associated with, | 173 // If the new theme is different from what this info bar is associated with, |
| 173 // close this info bar since it is no longer relevant. | 174 // close this info bar since it is no longer relevant. |
| 174 if (theme_id_ != theme_service_->GetThemeID()) | 175 if (theme_id_ != theme_service_->GetThemeID()) |
| 175 infobar()->RemoveSelf(); | 176 infobar()->RemoveSelf(); |
| 176 } | 177 } |
| OLD | NEW |