Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: chrome/browser/api/infobars/infobar_delegate.h

Issue 10830353: Introduce InfoBarTabService API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments, merge to LKGR Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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_; }
65
66 void clear_owner() { owner_ = NULL; }
68 67
69 // 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
70 // 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
71 // InfoBarTabHelper when determining whether or not a delegate should be 70 // InfoBarTabService when determining whether or not a delegate should be
72 // 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,
73 // the InfoBarTabHelper will not add the new delegate because it considers 72 // the InfoBarTabService will not add the new delegate because it considers
74 // one to already be present. 73 // one to already be present.
75 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; 74 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
76 75
77 // 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
78 // 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
79 // page (not including reloads). Subclasses wishing to change this behavior 78 // page (not including reloads). Subclasses wishing to change this behavior
80 // can override either this function or ShouldExpireInternal(), depending on 79 // can override either this function or ShouldExpireInternal(), depending on
81 // what level of control they need. 80 // what level of control they need.
82 virtual bool ShouldExpire(const content::LoadCommittedDetails& details) const; 81 virtual bool ShouldExpire(const content::LoadCommittedDetails& details) const;
83 82
(...skipping 20 matching lines...) Expand all
104 virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); 103 virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate();
105 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); 104 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate();
106 virtual RegisterProtocolHandlerInfoBarDelegate* 105 virtual RegisterProtocolHandlerInfoBarDelegate*
107 AsRegisterProtocolHandlerInfoBarDelegate(); 106 AsRegisterProtocolHandlerInfoBarDelegate();
108 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); 107 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate();
109 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); 108 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate();
110 109
111 protected: 110 protected:
112 // 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
113 // using StoreActiveEntryUniqueID automatically. 112 // using StoreActiveEntryUniqueID automatically.
114 explicit InfoBarDelegate(InfoBarTabHelper* infobar_helper); 113 explicit InfoBarDelegate(InfoBarTabService* infobar_service);
115 114
116 // 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
117 // be used later upon navigation to determine if this InfoBarDelegate should 116 // be used later upon navigation to determine if this InfoBarDelegate should
118 // be expired from |contents_|. 117 // be expired from |contents_|.
119 void StoreActiveEntryUniqueID(InfoBarTabHelper* infobar_helper); 118 void StoreActiveEntryUniqueID(InfoBarTabService* infobar_service);
120 119
121 // Direct accessors for subclasses that need to do something special. 120 // Direct accessors for subclasses that need to do something special.
122 int contents_unique_id() const { return contents_unique_id_; } 121 int contents_unique_id() const { return contents_unique_id_; }
123 void set_contents_unique_id(int contents_unique_id) { 122 void set_contents_unique_id(int contents_unique_id) {
124 contents_unique_id_ = contents_unique_id; 123 contents_unique_id_ = contents_unique_id;
125 } 124 }
126 125
127 // 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.
128 virtual bool ShouldExpireInternal( 127 virtual bool ShouldExpireInternal(
129 const content::LoadCommittedDetails& details) const; 128 const content::LoadCommittedDetails& details) const;
130 129
131 // Removes ourself from |owner_| if we haven't already been removed. 130 // Removes ourself from |owner_| if we haven't already been removed.
132 // TODO(pkasting): Move to InfoBar. 131 // TODO(pkasting): Move to InfoBar.
133 void RemoveSelf(); 132 void RemoveSelf();
134 133
135 private: 134 private:
136 // 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
137 // opened for. Used to help expire on navigations. 136 // opened for. Used to help expire on navigations.
138 int contents_unique_id_; 137 int contents_unique_id_;
139 138
140 // TODO(pkasting): Remove. 139 // TODO(pkasting): Remove.
141 InfoBarTabHelper* owner_; 140 InfoBarTabService* owner_;
142 141
143 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); 142 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate);
144 }; 143 };
145 144
146 #endif // CHROME_BROWSER_API_INFOBARS_INFOBAR_DELEGATE_H_ 145 #endif // CHROME_BROWSER_API_INFOBARS_INFOBAR_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/api/infobars/confirm_infobar_delegate.cc ('k') | chrome/browser/api/infobars/infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698