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

Unified Diff: chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.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/custom_handlers/register_protocol_handler_infobar_delegate.cc
===================================================================
--- chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc (revision 175396)
+++ chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.cc (working copy)
@@ -17,13 +17,30 @@
using content::Referrer;
using content::UserMetricsAction;
-RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate(
+// static
+void RegisterProtocolHandlerInfoBarDelegate::Create(
InfoBarService* infobar_service,
ProtocolHandlerRegistry* registry,
- const ProtocolHandler& handler)
- : ConfirmInfoBarDelegate(infobar_service),
- registry_(registry),
- handler_(handler) {
+ const ProtocolHandler& handler) {
+ content::RecordAction(
+ content::UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown"));
+
+ scoped_ptr<InfoBarDelegate> infobar(
+ new RegisterProtocolHandlerInfoBarDelegate(infobar_service, registry,
+ handler));
+
+ for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) {
+ RegisterProtocolHandlerInfoBarDelegate* existing_delegate =
+ infobar_service->GetInfoBarDelegateAt(i)->
+ AsRegisterProtocolHandlerInfoBarDelegate();
+ if ((existing_delegate != NULL) &&
+ existing_delegate->handler_.IsEquivalent(handler)) {
+ infobar_service->ReplaceInfoBar(existing_delegate, infobar.Pass());
+ return;
+ }
+ }
+
+ infobar_service->AddInfoBar(infobar.Pass());
}
InfoBarDelegate::InfoBarAutomationType
@@ -47,6 +64,15 @@
GetProtocolName(handler_));
}
+RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate(
+ InfoBarService* infobar_service,
+ ProtocolHandlerRegistry* registry,
+ const ProtocolHandler& handler)
+ : ConfirmInfoBarDelegate(infobar_service),
+ registry_(registry),
+ handler_(handler) {
+}
+
string16 RegisterProtocolHandlerInfoBarDelegate::GetProtocolName(
const ProtocolHandler& handler) const {
if (handler.protocol() == "mailto")
@@ -101,11 +127,6 @@
return false;
}
-bool RegisterProtocolHandlerInfoBarDelegate::IsReplacedBy(
- RegisterProtocolHandlerInfoBarDelegate* delegate) {
- return handler_.IsEquivalent(delegate->handler_);
-}
-
RegisterProtocolHandlerInfoBarDelegate*
RegisterProtocolHandlerInfoBarDelegate::
AsRegisterProtocolHandlerInfoBarDelegate() {

Powered by Google App Engine
This is Rietveld 408576698