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 InfoBarTabHelper; | 16 class InfoBarTabService; |
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(InfoBarTabHelper* owner) = 0; | 61 virtual InfoBar* CreateInfoBar(InfoBarTabService* owner) = 0; |
62 | |
63 // Called by the InfoBarTabHelper when it removes us. | |
64 void clear_owner() { owner_ = NULL; } | |
65 | 62 |
66 // TODO(pkasting): Move to InfoBar once InfoBars own their delegates. | 63 // TODO(pkasting): Move to InfoBar once InfoBars own their delegates. |
67 InfoBarTabHelper* owner() { return owner_; } | 64 InfoBarTabService* owner() { return owner_; } |
68 | 65 |
69 // Returns true if the supplied |delegate| is equal to this one. Equality is | 66 // Returns true if the supplied |delegate| is equal to this one. Equality is |
70 // left to the implementation to define. This function is called by the | 67 // left to the implementation to define. This function is called by the |
71 // InfoBarTabHelper when determining whether or not a delegate should be | 68 // InfoBarTabService when determining whether or not a delegate should be |
72 // added because a matching one already exists. If this function returns true, | 69 // added because a matching one already exists. If this function returns true, |
73 // the InfoBarTabHelper will not add the new delegate because it considers | 70 // the InfoBarTabHelper will not add the new delegate because it considers |
erikwright (departed)
2012/08/16 17:25:38
Helper->Service
Jói
2012/08/17 15:51:24
Done.
| |
74 // one to already be present. | 71 // one to already be present. |
75 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; | 72 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; |
76 | 73 |
77 // Returns true if the InfoBar should be closed automatically after the page | 74 // Returns true if the InfoBar should be closed automatically after the page |
78 // is navigated. By default this returns true if the navigation is to a new | 75 // is navigated. By default this returns true if the navigation is to a new |
79 // page (not including reloads). Subclasses wishing to change this behavior | 76 // page (not including reloads). Subclasses wishing to change this behavior |
80 // can override either this function or ShouldExpireInternal(), depending on | 77 // can override either this function or ShouldExpireInternal(), depending on |
81 // what level of control they need. | 78 // what level of control they need. |
82 virtual bool ShouldExpire(const content::LoadCommittedDetails& details) const; | 79 virtual bool ShouldExpire(const content::LoadCommittedDetails& details) const; |
83 | 80 |
(...skipping 20 matching lines...) Expand all Loading... | |
104 virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); | 101 virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); |
105 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); | 102 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); |
106 virtual RegisterProtocolHandlerInfoBarDelegate* | 103 virtual RegisterProtocolHandlerInfoBarDelegate* |
107 AsRegisterProtocolHandlerInfoBarDelegate(); | 104 AsRegisterProtocolHandlerInfoBarDelegate(); |
108 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); | 105 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); |
109 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); | 106 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); |
110 | 107 |
111 protected: | 108 protected: |
112 // If |contents| is non-NULL, its active entry's unique ID will be stored | 109 // If |contents| is non-NULL, its active entry's unique ID will be stored |
113 // using StoreActiveEntryUniqueID automatically. | 110 // using StoreActiveEntryUniqueID automatically. |
114 explicit InfoBarDelegate(InfoBarTabHelper* infobar_helper); | 111 explicit InfoBarDelegate(InfoBarTabService* infobar_helper); |
erikwright (departed)
2012/08/16 17:25:38
rename
Jói
2012/08/17 15:51:24
Done.
| |
115 | 112 |
116 // Store the unique id for the active entry in the specified WebContents, to | 113 // Store the unique id for the active entry in the specified WebContents, to |
117 // be used later upon navigation to determine if this InfoBarDelegate should | 114 // be used later upon navigation to determine if this InfoBarDelegate should |
118 // be expired from |contents_|. | 115 // be expired from |contents_|. |
119 void StoreActiveEntryUniqueID(InfoBarTabHelper* infobar_helper); | 116 void StoreActiveEntryUniqueID(InfoBarTabService* infobar_helper); |
erikwright (departed)
2012/08/16 17:25:38
rename
Jói
2012/08/17 15:51:24
Done.
| |
120 | 117 |
121 // Direct accessors for subclasses that need to do something special. | 118 // Direct accessors for subclasses that need to do something special. |
122 int contents_unique_id() const { return contents_unique_id_; } | 119 int contents_unique_id() const { return contents_unique_id_; } |
123 void set_contents_unique_id(int contents_unique_id) { | 120 void set_contents_unique_id(int contents_unique_id) { |
124 contents_unique_id_ = contents_unique_id; | 121 contents_unique_id_ = contents_unique_id; |
125 } | 122 } |
126 | 123 |
127 // Returns true if the navigation is to a new URL or a reload occured. | 124 // Returns true if the navigation is to a new URL or a reload occured. |
128 virtual bool ShouldExpireInternal( | 125 virtual bool ShouldExpireInternal( |
129 const content::LoadCommittedDetails& details) const; | 126 const content::LoadCommittedDetails& details) const; |
130 | 127 |
131 // Removes ourself from |owner_| if we haven't already been removed. | 128 // Removes ourself from |owner_| if we haven't already been removed. |
132 // TODO(pkasting): Move to InfoBar. | 129 // TODO(pkasting): Move to InfoBar. |
133 void RemoveSelf(); | 130 void RemoveSelf(); |
134 | 131 |
135 private: | 132 private: |
133 friend class InfoBarTabHelper; | |
134 | |
135 // Called by the InfoBarTabHelper when it removes us. | |
136 void clear_owner() { owner_ = NULL; } | |
erikwright (departed)
2012/08/16 17:25:38
This implies that one could not simply write an al
Jói
2012/08/17 15:51:24
Moved it back to public. Removed the comment.
| |
137 | |
136 // The unique id of the active NavigationEntry of the WebContents that we were | 138 // The unique id of the active NavigationEntry of the WebContents that we were |
137 // opened for. Used to help expire on navigations. | 139 // opened for. Used to help expire on navigations. |
138 int contents_unique_id_; | 140 int contents_unique_id_; |
139 | 141 |
140 // TODO(pkasting): Remove. | 142 // TODO(pkasting): Remove. |
141 InfoBarTabHelper* owner_; | 143 InfoBarTabService* owner_; |
142 | 144 |
143 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); | 145 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); |
144 }; | 146 }; |
145 | 147 |
146 #endif // CHROME_BROWSER_API_INFOBARS_INFOBAR_DELEGATE_H_ | 148 #endif // CHROME_BROWSER_API_INFOBARS_INFOBAR_DELEGATE_H_ |
OLD | NEW |