| 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 |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/app/vector_icons/vector_icons.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/infobars/infobar_service.h" | 16 #include "chrome/browser/infobars/infobar_service.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/themes/theme_service.h" | 18 #include "chrome/browser/themes/theme_service.h" |
| 18 #include "chrome/browser/themes/theme_service_factory.h" | 19 #include "chrome/browser/themes/theme_service_factory.h" |
| 19 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 22 #include "chrome/grit/theme_resources.h" | 23 #include "chrome/grit/theme_resources.h" |
| 23 #include "components/infobars/core/infobar.h" | 24 #include "components/infobars/core/infobar.h" |
| 24 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| 25 #include "extensions/browser/extension_system.h" | 26 #include "extensions/browser/extension_system.h" |
| 26 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/gfx/vector_icons_public.h" | |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 void ThemeInstalledInfoBarDelegate::Create( | 31 void ThemeInstalledInfoBarDelegate::Create( |
| 32 const extensions::Extension* new_theme, | 32 const extensions::Extension* new_theme, |
| 33 Profile* profile, | 33 Profile* profile, |
| 34 const std::string& previous_theme_id, | 34 const std::string& previous_theme_id, |
| 35 bool previous_using_system_theme) { | 35 bool previous_using_system_theme) { |
| 36 DCHECK(new_theme); | 36 DCHECK(new_theme); |
| 37 if (!new_theme->is_theme()) | 37 if (!new_theme->is_theme()) |
| 38 return; | 38 return; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 infobars::InfoBarDelegate::Type | 109 infobars::InfoBarDelegate::Type |
| 110 ThemeInstalledInfoBarDelegate::GetInfoBarType() const { | 110 ThemeInstalledInfoBarDelegate::GetInfoBarType() const { |
| 111 return PAGE_ACTION_TYPE; | 111 return PAGE_ACTION_TYPE; |
| 112 } | 112 } |
| 113 | 113 |
| 114 infobars::InfoBarDelegate::InfoBarIdentifier | 114 infobars::InfoBarDelegate::InfoBarIdentifier |
| 115 ThemeInstalledInfoBarDelegate::GetIdentifier() const { | 115 ThemeInstalledInfoBarDelegate::GetIdentifier() const { |
| 116 return THEME_INSTALLED_INFOBAR_DELEGATE; | 116 return THEME_INSTALLED_INFOBAR_DELEGATE; |
| 117 } | 117 } |
| 118 | 118 |
| 119 gfx::VectorIconId ThemeInstalledInfoBarDelegate::GetVectorIconId() const { | 119 const gfx::VectorIcon& ThemeInstalledInfoBarDelegate::GetVectorIcon() const { |
| 120 return gfx::VectorIconId::PAINTBRUSH; | 120 return kPaintbrushIcon; |
| 121 } | 121 } |
| 122 | 122 |
| 123 ThemeInstalledInfoBarDelegate* | 123 ThemeInstalledInfoBarDelegate* |
| 124 ThemeInstalledInfoBarDelegate::AsThemePreviewInfobarDelegate() { | 124 ThemeInstalledInfoBarDelegate::AsThemePreviewInfobarDelegate() { |
| 125 return this; | 125 return this; |
| 126 } | 126 } |
| 127 | 127 |
| 128 base::string16 ThemeInstalledInfoBarDelegate::GetMessageText() const { | 128 base::string16 ThemeInstalledInfoBarDelegate::GetMessageText() const { |
| 129 return l10n_util::GetStringFUTF16(IDS_THEME_INSTALL_INFOBAR_LABEL, | 129 return l10n_util::GetStringFUTF16(IDS_THEME_INSTALL_INFOBAR_LABEL, |
| 130 base::UTF8ToUTF16(name_)); | 130 base::UTF8ToUTF16(name_)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 160 void ThemeInstalledInfoBarDelegate::Observe( | 160 void ThemeInstalledInfoBarDelegate::Observe( |
| 161 int type, | 161 int type, |
| 162 const content::NotificationSource& source, | 162 const content::NotificationSource& source, |
| 163 const content::NotificationDetails& details) { | 163 const content::NotificationDetails& details) { |
| 164 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); | 164 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); |
| 165 // If the new theme is different from what this info bar is associated with, | 165 // 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. | 166 // close this info bar since it is no longer relevant. |
| 167 if (theme_id_ != theme_service_->GetThemeID()) | 167 if (theme_id_ != theme_service_->GetThemeID()) |
| 168 infobar()->RemoveSelf(); | 168 infobar()->RemoveSelf(); |
| 169 } | 169 } |
| OLD | NEW |