register_protocol_handler_infobar_delegate.h revision 868fa2fe829687343ffae624259930155e16dbd8
1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_CUSTOM_HANDLERS_REGISTER_PROTOCOL_HANDLER_INFOBAR_DELEGATE_H_
6#define CHROME_BROWSER_CUSTOM_HANDLERS_REGISTER_PROTOCOL_HANDLER_INFOBAR_DELEGATE_H_
7
8#include "base/strings/string16.h"
9#include "chrome/browser/infobars/confirm_infobar_delegate.h"
10#include "chrome/common/custom_handlers/protocol_handler.h"
11
12class InfoBarService;
13class ProtocolHandlerRegistry;
14
15// An InfoBar delegate that enables the user to allow or deny storing credit
16// card information gathered from a form submission.
17class RegisterProtocolHandlerInfoBarDelegate : public ConfirmInfoBarDelegate {
18 public:
19  // Creates a new RPH delegate.  Searches |infobar_service| for an existing
20  // delegate for the same |handler|; replaces it with the new delegate if
21  // found, otherwise adds the new infobar to |infobar_service|.
22  static void Create(InfoBarService* infobar_service,
23                     ProtocolHandlerRegistry* registry,
24                     const ProtocolHandler& handler);
25
26 private:
27  RegisterProtocolHandlerInfoBarDelegate(InfoBarService* infobar_service,
28                                         ProtocolHandlerRegistry* registry,
29                                         const ProtocolHandler& handler);
30
31  // ConfirmInfoBarDelegate:
32  virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE;
33  virtual Type GetInfoBarType() const OVERRIDE;
34  virtual RegisterProtocolHandlerInfoBarDelegate*
35      AsRegisterProtocolHandlerInfoBarDelegate() OVERRIDE;
36  virtual string16 GetMessageText() const OVERRIDE;
37  virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
38  virtual bool NeedElevation(InfoBarButton button) const OVERRIDE;
39  virtual bool Accept() OVERRIDE;
40  virtual bool Cancel() OVERRIDE;
41  virtual string16 GetLinkText() const OVERRIDE;
42  virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
43
44  // Returns a user-friendly name for the protocol of this protocol handler.
45  string16 GetProtocolName(const ProtocolHandler& handler) const;
46
47  ProtocolHandlerRegistry* registry_;
48  ProtocolHandler handler_;
49
50  DISALLOW_COPY_AND_ASSIGN(RegisterProtocolHandlerInfoBarDelegate);
51};
52
53#endif  // CHROME_BROWSER_CUSTOM_HANDLERS_REGISTER_PROTOCOL_HANDLER_INFOBAR_DELEGATE_H_
54