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

Unified Diff: chrome/browser/extensions/api/debugger/debugger_api.cc

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/debugger/debugger_api.cc
===================================================================
--- chrome/browser/extensions/api/debugger/debugger_api.cc (revision 175396)
+++ chrome/browser/extensions/api/debugger/debugger_api.cc (working copy)
@@ -59,17 +59,24 @@
class ExtensionDevToolsInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- ExtensionDevToolsInfoBarDelegate(
+ // Creates an extension dev tools delegate and adds it to |infobar_service|.
+ // Returns a pointer to the delegate if it was successfully added.
+ static ExtensionDevToolsInfoBarDelegate* Create(
InfoBarService* infobar_service,
const std::string& client_name,
ExtensionDevToolsClientHost* client_host);
- virtual ~ExtensionDevToolsInfoBarDelegate();
// Notifies infobar delegate that associated DevToolsClientHost will be
// destroyed.
void DiscardClientHost();
private:
+ ExtensionDevToolsInfoBarDelegate(
+ InfoBarService* infobar_service,
+ const std::string& client_name,
+ ExtensionDevToolsClientHost* client_host);
+ virtual ~ExtensionDevToolsInfoBarDelegate();
+
// ConfirmInfoBarDelegate:
virtual int GetButtons() const OVERRIDE;
virtual Type GetInfoBarType() const OVERRIDE;
@@ -196,14 +203,12 @@
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents_);
- infobar_delegate_ = new ExtensionDevToolsInfoBarDelegate(infobar_service,
- extension_name,
- this);
- if (infobar_service->AddInfoBar(infobar_delegate_)) {
+ infobar_delegate_ = ExtensionDevToolsInfoBarDelegate::Create(infobar_service,
+ extension_name,
+ this);
+ if (infobar_delegate_) {
registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
content::Source<InfoBarService>(infobar_service));
- } else {
- infobar_delegate_ = NULL;
}
}
@@ -347,6 +352,21 @@
}
}
+// static
+ExtensionDevToolsInfoBarDelegate* ExtensionDevToolsInfoBarDelegate::Create(
+ InfoBarService* infobar_service,
+ const std::string& client_name,
+ ExtensionDevToolsClientHost* client_host) {
+ return static_cast<ExtensionDevToolsInfoBarDelegate*>(
+ infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
+ new ExtensionDevToolsInfoBarDelegate(infobar_service, client_name,
+ client_host))));
+}
+
+void ExtensionDevToolsInfoBarDelegate::DiscardClientHost() {
+ client_host_ = NULL;
+}
+
ExtensionDevToolsInfoBarDelegate::ExtensionDevToolsInfoBarDelegate(
InfoBarService* infobar_service,
const std::string& client_name,
@@ -359,10 +379,6 @@
ExtensionDevToolsInfoBarDelegate::~ExtensionDevToolsInfoBarDelegate() {
}
-void ExtensionDevToolsInfoBarDelegate::DiscardClientHost() {
- client_host_ = NULL;
-}
-
int ExtensionDevToolsInfoBarDelegate::GetButtons() const {
return BUTTON_CANCEL;
}
« no previous file with comments | « chrome/browser/download/download_request_limiter.cc ('k') | chrome/browser/extensions/app_notify_channel_ui_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698