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_API_INFOBARS_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_API_INFOBARS_INFOBAR_DELEGATE_H_ |
6 #define CHROME_BROWSER_API_INFOBARS_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_API_INFOBARS_INFOBAR_DELEGATE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "webkit/glue/window_open_disposition.h" | 10 #include "webkit/glue/window_open_disposition.h" |
11 | 11 |
12 class AutoLoginInfoBarDelegate; | 12 class AutoLoginInfoBarDelegate; |
13 class ConfirmInfoBarDelegate; | 13 class ConfirmInfoBarDelegate; |
14 class ExtensionInfoBarDelegate; | 14 class ExtensionInfoBarDelegate; |
15 class InfoBar; | 15 class InfoBar; |
16 class InfoBarTabService; | 16 class InfoBarService; |
17 class InsecureContentInfoBarDelegate; | 17 class InsecureContentInfoBarDelegate; |
18 class LinkInfoBarDelegate; | 18 class LinkInfoBarDelegate; |
19 class MediaStreamInfoBarDelegate; | 19 class MediaStreamInfoBarDelegate; |
20 class PluginInstallerInfoBarDelegate; | 20 class PluginInstallerInfoBarDelegate; |
21 class RegisterProtocolHandlerInfoBarDelegate; | 21 class RegisterProtocolHandlerInfoBarDelegate; |
22 class SavePasswordInfoBarDelegate; | 22 class SavePasswordInfoBarDelegate; |
23 class ThemeInstalledInfoBarDelegate; | 23 class ThemeInstalledInfoBarDelegate; |
24 class TranslateInfoBarDelegate; | 24 class TranslateInfoBarDelegate; |
25 | 25 |
26 namespace gfx { | 26 namespace gfx { |
(...skipping 24 matching lines...) Expand all Loading... |
51 RPH_INFOBAR, | 51 RPH_INFOBAR, |
52 UNKNOWN_INFOBAR, | 52 UNKNOWN_INFOBAR, |
53 }; | 53 }; |
54 | 54 |
55 virtual ~InfoBarDelegate(); | 55 virtual ~InfoBarDelegate(); |
56 | 56 |
57 virtual InfoBarAutomationType GetInfoBarAutomationType() const; | 57 virtual InfoBarAutomationType GetInfoBarAutomationType() const; |
58 | 58 |
59 // Called to create the InfoBar. Implementation of this method is | 59 // Called to create the InfoBar. Implementation of this method is |
60 // platform-specific. | 60 // platform-specific. |
61 virtual InfoBar* CreateInfoBar(InfoBarTabService* owner) = 0; | 61 virtual InfoBar* CreateInfoBar(InfoBarService* owner) = 0; |
62 | 62 |
63 // TODO(pkasting): Move to InfoBar once InfoBars own their delegates. | 63 // TODO(pkasting): Move to InfoBar once InfoBars own their delegates. |
64 InfoBarTabService* owner() { return owner_; } | 64 InfoBarService* owner() { return owner_; } |
65 | 65 |
66 void clear_owner() { owner_ = NULL; } | 66 void clear_owner() { owner_ = NULL; } |
67 | 67 |
68 // Returns true if the supplied |delegate| is equal to this one. Equality is | 68 // Returns true if the supplied |delegate| is equal to this one. Equality is |
69 // left to the implementation to define. This function is called by the | 69 // left to the implementation to define. This function is called by the |
70 // InfoBarTabService when determining whether or not a delegate should be | 70 // InfoBarService when determining whether or not a delegate should be |
71 // added because a matching one already exists. If this function returns true, | 71 // added because a matching one already exists. If this function returns true, |
72 // the InfoBarTabService will not add the new delegate because it considers | 72 // the InfoBarService will not add the new delegate because it considers |
73 // one to already be present. | 73 // one to already be present. |
74 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; | 74 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; |
75 | 75 |
76 // Returns true if the InfoBar should be closed automatically after the page | 76 // Returns true if the InfoBar should be closed automatically after the page |
77 // is navigated. By default this returns true if the navigation is to a new | 77 // is navigated. By default this returns true if the navigation is to a new |
78 // page (not including reloads). Subclasses wishing to change this behavior | 78 // page (not including reloads). Subclasses wishing to change this behavior |
79 // can override either this function or ShouldExpireInternal(), depending on | 79 // can override either this function or ShouldExpireInternal(), depending on |
80 // what level of control they need. | 80 // what level of control they need. |
81 virtual bool ShouldExpire(const content::LoadCommittedDetails& details) const; | 81 virtual bool ShouldExpire(const content::LoadCommittedDetails& details) const; |
82 | 82 |
(...skipping 20 matching lines...) Expand all Loading... |
103 virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); | 103 virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); |
104 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); | 104 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); |
105 virtual RegisterProtocolHandlerInfoBarDelegate* | 105 virtual RegisterProtocolHandlerInfoBarDelegate* |
106 AsRegisterProtocolHandlerInfoBarDelegate(); | 106 AsRegisterProtocolHandlerInfoBarDelegate(); |
107 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); | 107 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); |
108 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); | 108 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); |
109 | 109 |
110 protected: | 110 protected: |
111 // If |contents| is non-NULL, its active entry's unique ID will be stored | 111 // If |contents| is non-NULL, its active entry's unique ID will be stored |
112 // using StoreActiveEntryUniqueID automatically. | 112 // using StoreActiveEntryUniqueID automatically. |
113 explicit InfoBarDelegate(InfoBarTabService* infobar_service); | 113 explicit InfoBarDelegate(InfoBarService* infobar_service); |
114 | 114 |
115 // Store the unique id for the active entry in the specified WebContents, to | 115 // Store the unique id for the active entry in the specified WebContents, to |
116 // be used later upon navigation to determine if this InfoBarDelegate should | 116 // be used later upon navigation to determine if this InfoBarDelegate should |
117 // be expired from |contents_|. | 117 // be expired from |contents_|. |
118 void StoreActiveEntryUniqueID(InfoBarTabService* infobar_service); | 118 void StoreActiveEntryUniqueID(InfoBarService* infobar_service); |
119 | 119 |
120 // Direct accessors for subclasses that need to do something special. | 120 // Direct accessors for subclasses that need to do something special. |
121 int contents_unique_id() const { return contents_unique_id_; } | 121 int contents_unique_id() const { return contents_unique_id_; } |
122 void set_contents_unique_id(int contents_unique_id) { | 122 void set_contents_unique_id(int contents_unique_id) { |
123 contents_unique_id_ = contents_unique_id; | 123 contents_unique_id_ = contents_unique_id; |
124 } | 124 } |
125 | 125 |
126 // Returns true if the navigation is to a new URL or a reload occured. | 126 // Returns true if the navigation is to a new URL or a reload occured. |
127 virtual bool ShouldExpireInternal( | 127 virtual bool ShouldExpireInternal( |
128 const content::LoadCommittedDetails& details) const; | 128 const content::LoadCommittedDetails& details) const; |
129 | 129 |
130 // Removes ourself from |owner_| if we haven't already been removed. | 130 // Removes ourself from |owner_| if we haven't already been removed. |
131 // TODO(pkasting): Move to InfoBar. | 131 // TODO(pkasting): Move to InfoBar. |
132 void RemoveSelf(); | 132 void RemoveSelf(); |
133 | 133 |
134 private: | 134 private: |
135 // The unique id of the active NavigationEntry of the WebContents that we were | 135 // The unique id of the active NavigationEntry of the WebContents that we were |
136 // opened for. Used to help expire on navigations. | 136 // opened for. Used to help expire on navigations. |
137 int contents_unique_id_; | 137 int contents_unique_id_; |
138 | 138 |
139 // TODO(pkasting): Remove. | 139 // TODO(pkasting): Remove. |
140 InfoBarTabService* owner_; | 140 InfoBarService* owner_; |
141 | 141 |
142 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); | 142 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); |
143 }; | 143 }; |
144 | 144 |
145 #endif // CHROME_BROWSER_API_INFOBARS_INFOBAR_DELEGATE_H_ | 145 #endif // CHROME_BROWSER_API_INFOBARS_INFOBAR_DELEGATE_H_ |
OLD | NEW |