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