Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1000)

Side by Side Diff: chrome/browser/extensions/extension_disabled_infobar_delegate.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 12 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
13 #include "chrome/browser/ui/browser_list.h" 13 #include "chrome/browser/ui/browser_list.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/extensions/extension_file_util.h" 16 #include "chrome/common/extensions/extension_file_util.h"
16 #include "chrome/common/extensions/extension_resource.h" 17 #include "chrome/common/extensions/extension_resource.h"
17 #include "content/browser/tab_contents/tab_contents.h" 18 #include "content/browser/tab_contents/tab_contents.h"
18 #include "content/common/notification_details.h" 19 #include "content/common/notification_details.h"
19 #include "content/common/notification_registrar.h" 20 #include "content/common/notification_registrar.h"
20 #include "content/common/notification_source.h" 21 #include "content/common/notification_source.h"
21 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
22 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
23 24
24 // ExtensionDisabledDialogDelegate -------------------------------------------- 25 // ExtensionDisabledDialogDelegate --------------------------------------------
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 private: 91 private:
91 virtual ~ExtensionDisabledInfobarDelegate(); 92 virtual ~ExtensionDisabledInfobarDelegate();
92 93
93 // ConfirmInfoBarDelegate: 94 // ConfirmInfoBarDelegate:
94 virtual string16 GetMessageText() const OVERRIDE; 95 virtual string16 GetMessageText() const OVERRIDE;
95 virtual int GetButtons() const OVERRIDE; 96 virtual int GetButtons() const OVERRIDE;
96 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 97 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
97 virtual bool Accept() OVERRIDE; 98 virtual bool Accept() OVERRIDE;
98 99
99 // NotificationObserver: 100 // NotificationObserver:
100 virtual void Observe(NotificationType type, 101 virtual void Observe(int type,
101 const NotificationSource& source, 102 const NotificationSource& source,
102 const NotificationDetails& details) OVERRIDE; 103 const NotificationDetails& details) OVERRIDE;
103 104
104 NotificationRegistrar registrar_; 105 NotificationRegistrar registrar_;
105 TabContentsWrapper* tab_contents_; 106 TabContentsWrapper* tab_contents_;
106 ExtensionService* service_; 107 ExtensionService* service_;
107 const Extension* extension_; 108 const Extension* extension_;
108 }; 109 };
109 110
110 ExtensionDisabledInfobarDelegate::ExtensionDisabledInfobarDelegate( 111 ExtensionDisabledInfobarDelegate::ExtensionDisabledInfobarDelegate(
111 TabContentsWrapper* tab_contents, 112 TabContentsWrapper* tab_contents,
112 ExtensionService* service, 113 ExtensionService* service,
113 const Extension* extension) 114 const Extension* extension)
114 : ConfirmInfoBarDelegate(tab_contents->tab_contents()), 115 : ConfirmInfoBarDelegate(tab_contents->tab_contents()),
115 tab_contents_(tab_contents), 116 tab_contents_(tab_contents),
116 service_(service), 117 service_(service),
117 extension_(extension) { 118 extension_(extension) {
118 // The user might re-enable the extension in other ways, so watch for that. 119 // The user might re-enable the extension in other ways, so watch for that.
119 registrar_.Add(this, NotificationType::EXTENSION_LOADED, 120 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
120 Source<Profile>(service->profile())); 121 Source<Profile>(service->profile()));
121 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, 122 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
122 Source<Profile>(service->profile())); 123 Source<Profile>(service->profile()));
123 } 124 }
124 125
125 ExtensionDisabledInfobarDelegate::~ExtensionDisabledInfobarDelegate() { 126 ExtensionDisabledInfobarDelegate::~ExtensionDisabledInfobarDelegate() {
126 } 127 }
127 128
128 string16 ExtensionDisabledInfobarDelegate::GetMessageText() const { 129 string16 ExtensionDisabledInfobarDelegate::GetMessageText() const {
129 return l10n_util::GetStringFUTF16(extension_->is_app() ? 130 return l10n_util::GetStringFUTF16(extension_->is_app() ?
130 IDS_APP_DISABLED_INFOBAR_LABEL : IDS_EXTENSION_DISABLED_INFOBAR_LABEL, 131 IDS_APP_DISABLED_INFOBAR_LABEL : IDS_EXTENSION_DISABLED_INFOBAR_LABEL,
131 UTF8ToUTF16(extension_->name())); 132 UTF8ToUTF16(extension_->name()));
(...skipping 11 matching lines...) Expand all
143 } 144 }
144 145
145 bool ExtensionDisabledInfobarDelegate::Accept() { 146 bool ExtensionDisabledInfobarDelegate::Accept() {
146 // This object manages its own lifetime. 147 // This object manages its own lifetime.
147 new ExtensionDisabledDialogDelegate(tab_contents_->profile(), service_, 148 new ExtensionDisabledDialogDelegate(tab_contents_->profile(), service_,
148 extension_); 149 extension_);
149 return true; 150 return true;
150 } 151 }
151 152
152 void ExtensionDisabledInfobarDelegate::Observe( 153 void ExtensionDisabledInfobarDelegate::Observe(
153 NotificationType type, 154 int type,
154 const NotificationSource& source, 155 const NotificationSource& source,
155 const NotificationDetails& details) { 156 const NotificationDetails& details) {
156 // TODO(mpcomplete): RemoveInfoBar doesn't seem to always result in us getting 157 // TODO(mpcomplete): RemoveInfoBar doesn't seem to always result in us getting
157 // deleted. 158 // deleted.
158 const Extension* extension = NULL; 159 const Extension* extension = NULL;
159 if (type.value == NotificationType::EXTENSION_LOADED) { 160 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
160 extension = Details<const Extension>(details).ptr(); 161 extension = Details<const Extension>(details).ptr();
161 } else { 162 } else {
162 DCHECK_EQ(NotificationType::EXTENSION_UNLOADED, type.value); 163 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNLOADED, type);
163 UnloadedExtensionInfo* info = Details<UnloadedExtensionInfo>(details).ptr(); 164 UnloadedExtensionInfo* info = Details<UnloadedExtensionInfo>(details).ptr();
164 if (info->reason == UnloadedExtensionInfo::DISABLE || 165 if (info->reason == UnloadedExtensionInfo::DISABLE ||
165 info->reason == UnloadedExtensionInfo::UNINSTALL) 166 info->reason == UnloadedExtensionInfo::UNINSTALL)
166 extension = info->extension; 167 extension = info->extension;
167 } 168 }
168 if (extension == extension_) 169 if (extension == extension_)
169 tab_contents_->RemoveInfoBar(this); 170 tab_contents_->RemoveInfoBar(this);
170 } 171 }
171 172
172 173
(...skipping 11 matching lines...) Expand all
184 185
185 tab_contents->AddInfoBar(new ExtensionDisabledInfobarDelegate( 186 tab_contents->AddInfoBar(new ExtensionDisabledInfobarDelegate(
186 tab_contents, service, extension)); 187 tab_contents, service, extension));
187 } 188 }
188 189
189 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, 190 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile,
190 const Extension* extension) { 191 const Extension* extension) {
191 // This object manages its own lifetime. 192 // This object manages its own lifetime.
192 new ExtensionDisabledDialogDelegate(profile, service, extension); 193 new ExtensionDisabledDialogDelegate(profile, service, extension);
193 } 194 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_debugger_api.cc ('k') | chrome/browser/extensions/extension_event_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698