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

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

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 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 226624)
+++ chrome/browser/extensions/api/debugger/debugger_api.cc (working copy)
@@ -68,11 +68,7 @@
namespace OnEvent = extensions::api::debugger::OnEvent;
namespace SendCommand = extensions::api::debugger::SendCommand;
-namespace {
-class ExtensionDevToolsInfoBarDelegate;
-} // namespace
-
// ExtensionDevToolsClientHost ------------------------------------------------
class ExtensionDevToolsClientHost : public DevToolsClientHost,
@@ -84,7 +80,7 @@
const std::string& extension_id,
const std::string& extension_name,
const Debuggee& debuggee,
- ExtensionDevToolsInfoBarDelegate* infobar);
+ InfoBar* infobar);
virtual ~ExtensionDevToolsClientHost();
@@ -119,7 +115,7 @@
typedef std::map<int, scoped_refptr<DebuggerSendCommandFunction> >
PendingRequests;
PendingRequests pending_requests_;
- ExtensionDevToolsInfoBarDelegate* infobar_;
+ InfoBar* infobar_;
OnDetach::Reason detach_reason_;
DISALLOW_COPY_AND_ASSIGN(ExtensionDevToolsClientHost);
@@ -147,12 +143,10 @@
class ExtensionDevToolsInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- // Creates an extension dev tools infobar delegate and adds it to the
- // InfoBarService associated with |rvh|. Returns the delegate if it was
+ // Creates an extension dev tools infobar and delegate and adds the infobar to
+ // the InfoBarService associated with |rvh|. Returns the infobar if it was
// successfully added.
- static ExtensionDevToolsInfoBarDelegate* Create(
- RenderViewHost* rvh,
- const std::string& client_name);
+ static InfoBar* Create(RenderViewHost* rvh, const std::string& client_name);
void set_client_host(ExtensionDevToolsClientHost* client_host) {
client_host_ = client_host;
@@ -159,8 +153,7 @@
}
private:
- ExtensionDevToolsInfoBarDelegate(InfoBarService* infobar_service,
- const std::string& client_name);
+ explicit ExtensionDevToolsInfoBarDelegate(const std::string& client_name);
virtual ~ExtensionDevToolsInfoBarDelegate();
// ConfirmInfoBarDelegate:
@@ -179,7 +172,7 @@
};
// static
-ExtensionDevToolsInfoBarDelegate* ExtensionDevToolsInfoBarDelegate::Create(
+InfoBar* ExtensionDevToolsInfoBarDelegate::Create(
RenderViewHost* rvh,
const std::string& client_name) {
if (!rvh)
@@ -194,15 +187,14 @@
if (!infobar_service)
return NULL;
- return static_cast<ExtensionDevToolsInfoBarDelegate*>(
- infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
- new ExtensionDevToolsInfoBarDelegate(infobar_service, client_name))));
+ return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
+ scoped_ptr<ConfirmInfoBarDelegate>(
+ new ExtensionDevToolsInfoBarDelegate(client_name))));
}
ExtensionDevToolsInfoBarDelegate::ExtensionDevToolsInfoBarDelegate(
- InfoBarService* infobar_service,
const std::string& client_name)
- : ConfirmInfoBarDelegate(infobar_service),
+ : ConfirmInfoBarDelegate(),
client_name_(client_name),
client_host_(NULL) {
}
@@ -305,7 +297,7 @@
const std::string& extension_id,
const std::string& extension_name,
const Debuggee& debuggee,
- ExtensionDevToolsInfoBarDelegate* infobar)
+ InfoBar* infobar)
: profile_(profile),
agent_host_(agent_host),
extension_id_(extension_id),
@@ -331,7 +323,8 @@
agent_host_.get(), this);
if (infobar_) {
- infobar_->set_client_host(this);
+ static_cast<ExtensionDevToolsInfoBarDelegate*>(
+ infobar_->delegate())->set_client_host(this);
registrar_.Add(
this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
content::Source<InfoBarService>(InfoBarService::FromWebContents(
@@ -346,7 +339,8 @@
registrar_.RemoveAll();
if (infobar_) {
- infobar_->set_client_host(NULL);
+ static_cast<ExtensionDevToolsInfoBarDelegate*>(
+ infobar_->delegate())->set_client_host(NULL);
InfoBarService::FromWebContents(WebContents::FromRenderViewHost(
agent_host_->GetRenderViewHost()))->RemoveInfoBar(infobar_);
}
@@ -416,7 +410,7 @@
Close();
} else {
DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type);
- if (content::Details<InfoBarRemovedDetails>(details)->first == infobar_) {
+ if (content::Details<InfoBar::RemovedDetails>(details)->first == infobar_) {
infobar_ = NULL;
SendDetachedEvent();
Close();
@@ -566,13 +560,13 @@
return false;
}
- ExtensionDevToolsInfoBarDelegate* infobar = NULL;
+ InfoBar* infobar = NULL;
if (!CommandLine::ForCurrentProcess()->
HasSwitch(switches::kSilentDebuggerExtensionAPI)) {
// Do not attach to the target if for any reason the infobar cannot be shown
// for this WebContents instance.
infobar = ExtensionDevToolsInfoBarDelegate::Create(
- agent_host_->GetRenderViewHost(), GetExtension()->name());
+ agent_host_->GetRenderViewHost(), GetExtension()->name());
if (!infobar) {
error_ = ErrorUtils::FormatErrorMessage(
keys::kSilentDebuggingRequired,

Powered by Google App Engine
This is Rietveld 408576698