| 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() {
|
|
|