| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/themes/theme_service.h" | 13 #include "chrome/browser/themes/theme_service.h" |
| 14 #include "chrome/browser/themes/theme_service_factory.h" | 14 #include "chrome/browser/themes/theme_service_factory.h" |
| 15 #include "chrome/browser/ui/browser_finder.h" | 15 #include "chrome/browser/ui/browser_finder.h" |
| 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
| 19 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 21 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | |
| 24 | 23 |
| 25 | 24 |
| 26 // static | 25 // static |
| 27 void ThemeInstalledInfoBarDelegate::Create( | 26 void ThemeInstalledInfoBarDelegate::Create( |
| 28 const extensions::Extension* new_theme, | 27 const extensions::Extension* new_theme, |
| 29 Profile* profile, | 28 Profile* profile, |
| 30 const std::string& previous_theme_id, | 29 const std::string& previous_theme_id, |
| 31 bool previous_using_native_theme) { | 30 bool previous_using_native_theme) { |
| 32 if (!new_theme->is_theme()) | 31 if (!new_theme->is_theme()) |
| 33 return; | 32 return; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 content::Source<ThemeService>(theme_service_)); | 97 content::Source<ThemeService>(theme_service_)); |
| 99 } | 98 } |
| 100 | 99 |
| 101 ThemeInstalledInfoBarDelegate::~ThemeInstalledInfoBarDelegate() { | 100 ThemeInstalledInfoBarDelegate::~ThemeInstalledInfoBarDelegate() { |
| 102 // We don't want any notifications while we're running our destructor. | 101 // We don't want any notifications while we're running our destructor. |
| 103 registrar_.RemoveAll(); | 102 registrar_.RemoveAll(); |
| 104 | 103 |
| 105 theme_service_->OnInfobarDestroyed(); | 104 theme_service_->OnInfobarDestroyed(); |
| 106 } | 105 } |
| 107 | 106 |
| 108 gfx::Image* ThemeInstalledInfoBarDelegate::GetIcon() const { | 107 int ThemeInstalledInfoBarDelegate::GetIconID() const { |
| 109 // TODO(aa): Reply with the theme's icon, but this requires reading it | 108 // TODO(aa): Reply with the theme's icon, but this requires reading it |
| 110 // asynchronously from disk. | 109 // asynchronously from disk. |
| 111 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 110 return IDR_INFOBAR_THEME; |
| 112 IDR_INFOBAR_THEME); | |
| 113 } | 111 } |
| 114 | 112 |
| 115 InfoBarDelegate::Type ThemeInstalledInfoBarDelegate::GetInfoBarType() const { | 113 InfoBarDelegate::Type ThemeInstalledInfoBarDelegate::GetInfoBarType() const { |
| 116 return PAGE_ACTION_TYPE; | 114 return PAGE_ACTION_TYPE; |
| 117 } | 115 } |
| 118 | 116 |
| 119 ThemeInstalledInfoBarDelegate* | 117 ThemeInstalledInfoBarDelegate* |
| 120 ThemeInstalledInfoBarDelegate::AsThemePreviewInfobarDelegate() { | 118 ThemeInstalledInfoBarDelegate::AsThemePreviewInfobarDelegate() { |
| 121 return this; | 119 return this; |
| 122 } | 120 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 void ThemeInstalledInfoBarDelegate::Observe( | 154 void ThemeInstalledInfoBarDelegate::Observe( |
| 157 int type, | 155 int type, |
| 158 const content::NotificationSource& source, | 156 const content::NotificationSource& source, |
| 159 const content::NotificationDetails& details) { | 157 const content::NotificationDetails& details) { |
| 160 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); | 158 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); |
| 161 // If the new theme is different from what this info bar is associated with, | 159 // If the new theme is different from what this info bar is associated with, |
| 162 // close this info bar since it is no longer relevant. | 160 // close this info bar since it is no longer relevant. |
| 163 if (theme_id_ != theme_service_->GetThemeID()) | 161 if (theme_id_ != theme_service_->GetThemeID()) |
| 164 RemoveSelf(); | 162 RemoveSelf(); |
| 165 } | 163 } |
| OLD | NEW |