OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TAB_CONTENTS_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ |
6 #define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // Returns true if the supplied |delegate| is equal to this one. Equality is | 46 // Returns true if the supplied |delegate| is equal to this one. Equality is |
47 // left to the implementation to define. This function is called by the | 47 // left to the implementation to define. This function is called by the |
48 // TabContents when determining whether or not a delegate should be added | 48 // TabContents when determining whether or not a delegate should be added |
49 // because a matching one already exists. If this function returns true, the | 49 // because a matching one already exists. If this function returns true, the |
50 // TabContents will not add the new delegate because it considers one to | 50 // TabContents will not add the new delegate because it considers one to |
51 // already be present. | 51 // already be present. |
52 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; | 52 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; |
53 | 53 |
54 // Returns true if the InfoBar should be closed automatically after the page | 54 // Returns true if the InfoBar should be closed automatically after the page |
55 // is navigated. The default behavior is to return true if the page is | 55 // is navigated. The default behavior is to return true if the user initiated |
56 // navigated somewhere else or reloaded. | 56 // navigation somewhere else or reloaded. |
57 virtual bool ShouldExpire( | 57 virtual bool ShouldExpire( |
58 const NavigationController::LoadCommittedDetails& details) const; | 58 const NavigationController::LoadCommittedDetails& details) const; |
59 | 59 |
60 // Called when the user clicks on the close button to dismiss the infobar. | 60 // Called when the user clicks on the close button to dismiss the infobar. |
61 virtual void InfoBarDismissed(); | 61 virtual void InfoBarDismissed(); |
62 | 62 |
63 // Called after the InfoBar is closed. Deletes |this|. | 63 // Called after the InfoBar is closed. Deletes |this|. |
64 // TODO(pkasting): Get rid of this and delete delegates directly. | 64 // TODO(pkasting): Get rid of this and delete delegates directly. |
65 void InfoBarClosed(); | 65 void InfoBarClosed(); |
66 | 66 |
(...skipping 17 matching lines...) Expand all Loading... |
84 // Provided to subclasses as a convenience to initialize the state of this | 84 // Provided to subclasses as a convenience to initialize the state of this |
85 // object. If |contents| is non-NULL, its active entry's unique ID will be | 85 // object. If |contents| is non-NULL, its active entry's unique ID will be |
86 // stored using StoreActiveEntryUniqueID automatically. | 86 // stored using StoreActiveEntryUniqueID automatically. |
87 explicit InfoBarDelegate(TabContents* contents); | 87 explicit InfoBarDelegate(TabContents* contents); |
88 | 88 |
89 // Store the unique id for the active entry in the specified TabContents, to | 89 // Store the unique id for the active entry in the specified TabContents, to |
90 // be used later upon navigation to determine if this InfoBarDelegate should | 90 // be used later upon navigation to determine if this InfoBarDelegate should |
91 // be expired from |contents_|. | 91 // be expired from |contents_|. |
92 void StoreActiveEntryUniqueID(TabContents* contents); | 92 void StoreActiveEntryUniqueID(TabContents* contents); |
93 | 93 |
| 94 // Returns true if the navigation is to a new URL or a reload occured. |
| 95 bool ShouldExpireInternal( |
| 96 const NavigationController::LoadCommittedDetails& details) const; |
| 97 |
94 private: | 98 private: |
95 // The unique id of the active NavigationEntry of the TabContents that we were | 99 // The unique id of the active NavigationEntry of the TabContents that we were |
96 // opened for. Used to help expire on navigations. | 100 // opened for. Used to help expire on navigations. |
97 int contents_unique_id_; | 101 int contents_unique_id_; |
98 | 102 |
99 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); | 103 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); |
100 }; | 104 }; |
101 | 105 |
102 #endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ | 106 #endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ |
OLD | NEW |