| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_disabled_infobar_delegate.h" | 5 #include "chrome/browser/extensions/extension_disabled_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_install_ui.h" | 10 #include "chrome/browser/extensions/extension_install_ui.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 public NotificationObserver { | 80 public NotificationObserver { |
| 81 public: | 81 public: |
| 82 ExtensionDisabledInfobarDelegate(TabContents* tab_contents, | 82 ExtensionDisabledInfobarDelegate(TabContents* tab_contents, |
| 83 ExtensionService* service, | 83 ExtensionService* service, |
| 84 const Extension* extension); | 84 const Extension* extension); |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 virtual ~ExtensionDisabledInfobarDelegate(); | 87 virtual ~ExtensionDisabledInfobarDelegate(); |
| 88 | 88 |
| 89 // ConfirmInfoBarDelegate: | 89 // ConfirmInfoBarDelegate: |
| 90 virtual void InfoBarClosed(); | 90 virtual string16 GetMessageText() const OVERRIDE; |
| 91 virtual string16 GetMessageText() const; | 91 virtual int GetButtons() const OVERRIDE; |
| 92 virtual int GetButtons() const; | 92 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 93 virtual string16 GetButtonLabel(InfoBarButton button) const; | 93 virtual bool Accept() OVERRIDE; |
| 94 virtual bool Accept(); | |
| 95 | 94 |
| 96 // NotificationObserver: | 95 // NotificationObserver: |
| 97 virtual void Observe(NotificationType type, | 96 virtual void Observe(NotificationType type, |
| 98 const NotificationSource& source, | 97 const NotificationSource& source, |
| 99 const NotificationDetails& details); | 98 const NotificationDetails& details) OVERRIDE; |
| 100 | 99 |
| 101 NotificationRegistrar registrar_; | 100 NotificationRegistrar registrar_; |
| 102 TabContents* tab_contents_; | 101 TabContents* tab_contents_; |
| 103 ExtensionService* service_; | 102 ExtensionService* service_; |
| 104 const Extension* extension_; | 103 const Extension* extension_; |
| 105 }; | 104 }; |
| 106 | 105 |
| 107 ExtensionDisabledInfobarDelegate::ExtensionDisabledInfobarDelegate( | 106 ExtensionDisabledInfobarDelegate::ExtensionDisabledInfobarDelegate( |
| 108 TabContents* tab_contents, | 107 TabContents* tab_contents, |
| 109 ExtensionService* service, | 108 ExtensionService* service, |
| 110 const Extension* extension) | 109 const Extension* extension) |
| 111 : ConfirmInfoBarDelegate(tab_contents), | 110 : ConfirmInfoBarDelegate(tab_contents), |
| 112 tab_contents_(tab_contents), | 111 tab_contents_(tab_contents), |
| 113 service_(service), | 112 service_(service), |
| 114 extension_(extension) { | 113 extension_(extension) { |
| 115 // The user might re-enable the extension in other ways, so watch for that. | 114 // The user might re-enable the extension in other ways, so watch for that. |
| 116 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 115 registrar_.Add(this, NotificationType::EXTENSION_LOADED, |
| 117 Source<Profile>(service->profile())); | 116 Source<Profile>(service->profile())); |
| 118 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 117 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
| 119 Source<Profile>(service->profile())); | 118 Source<Profile>(service->profile())); |
| 120 } | 119 } |
| 121 | 120 |
| 122 ExtensionDisabledInfobarDelegate::~ExtensionDisabledInfobarDelegate() { | 121 ExtensionDisabledInfobarDelegate::~ExtensionDisabledInfobarDelegate() { |
| 123 } | 122 } |
| 124 | 123 |
| 125 void ExtensionDisabledInfobarDelegate::InfoBarClosed() { | |
| 126 delete this; | |
| 127 } | |
| 128 | |
| 129 string16 ExtensionDisabledInfobarDelegate::GetMessageText() const { | 124 string16 ExtensionDisabledInfobarDelegate::GetMessageText() const { |
| 130 return l10n_util::GetStringFUTF16(extension_->is_app() ? | 125 return l10n_util::GetStringFUTF16(extension_->is_app() ? |
| 131 IDS_APP_DISABLED_INFOBAR_LABEL : IDS_EXTENSION_DISABLED_INFOBAR_LABEL, | 126 IDS_APP_DISABLED_INFOBAR_LABEL : IDS_EXTENSION_DISABLED_INFOBAR_LABEL, |
| 132 UTF8ToUTF16(extension_->name())); | 127 UTF8ToUTF16(extension_->name())); |
| 133 } | 128 } |
| 134 | 129 |
| 135 int ExtensionDisabledInfobarDelegate::GetButtons() const { | 130 int ExtensionDisabledInfobarDelegate::GetButtons() const { |
| 136 return BUTTON_OK; | 131 return BUTTON_OK; |
| 137 } | 132 } |
| 138 | 133 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 179 |
| 185 tab_contents->AddInfoBar(new ExtensionDisabledInfobarDelegate( | 180 tab_contents->AddInfoBar(new ExtensionDisabledInfobarDelegate( |
| 186 tab_contents, service, extension)); | 181 tab_contents, service, extension)); |
| 187 } | 182 } |
| 188 | 183 |
| 189 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, | 184 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, |
| 190 const Extension* extension) { | 185 const Extension* extension) { |
| 191 // This object manages its own lifetime. | 186 // This object manages its own lifetime. |
| 192 new ExtensionDisabledDialogDelegate(profile, service, extension); | 187 new ExtensionDisabledDialogDelegate(profile, service, extension); |
| 193 } | 188 } |
| OLD | NEW |