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

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

Issue 240193003: Move Infobars core files to the Infobars component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nib name on mac Created 6 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_
7
8 #include "base/basictypes.h"
9 #include "base/strings/string16.h"
10 #include "ui/base/window_open_disposition.h"
11
12 class AutoLoginInfoBarDelegate;
13 class ConfirmInfoBarDelegate;
14 class ExtensionInfoBarDelegate;
15 class InfoBar;
16 class InsecureContentInfoBarDelegate;
17 class MediaStreamInfoBarDelegate;
18 class PopupBlockedInfoBarDelegate;
19 class RegisterProtocolHandlerInfoBarDelegate;
20 class ScreenCaptureInfoBarDelegate;
21 class ThemeInstalledInfoBarDelegate;
22 class ThreeDAPIInfoBarDelegate;
23 class TranslateInfoBarDelegate;
24
25 namespace gfx {
26 class Image;
27 }
28
29 // An interface implemented by objects wishing to control an InfoBar.
30 // Implementing this interface is not sufficient to use an InfoBar, since it
31 // does not map to a specific InfoBar type. Instead, you must implement
32 // ConfirmInfoBarDelegate, or override with your own delegate for your own
33 // InfoBar variety.
34 class InfoBarDelegate {
35 public:
36 // The type of the infobar. It controls its appearance, such as its background
37 // color.
38 enum Type {
39 WARNING_TYPE,
40 PAGE_ACTION_TYPE,
41 };
42
43 enum InfoBarAutomationType {
44 CONFIRM_INFOBAR,
45 PASSWORD_INFOBAR,
46 RPH_INFOBAR,
47 UNKNOWN_INFOBAR,
48 };
49
50 // Describes navigation events, used to decide whether infobars should be
51 // dismissed.
52 struct NavigationDetails {
53 // Unique identifier for the entry.
54 int entry_id;
55 // True if it is a navigation to a different page (as opposed to in-page).
56 bool is_navigation_to_different_page;
57 // True if the entry replaced the existing one.
58 bool did_replace_entry;
59 // True for the main frame, false for a sub-frame.
60 bool is_main_frame;
61 bool is_reload;
62 bool is_redirect;
63 };
64
65 // Value to use when the InfoBar has no icon to show.
66 static const int kNoIconID;
67
68 // Called when the InfoBar that owns this delegate is being destroyed. At
69 // this point nothing is visible onscreen.
70 virtual ~InfoBarDelegate();
71
72 virtual InfoBarAutomationType GetInfoBarAutomationType() const;
73
74 // Returns true if the supplied |delegate| is equal to this one. Equality is
75 // left to the implementation to define. This function is called by the
76 // InfoBarManager when determining whether or not a delegate should be
77 // added because a matching one already exists. If this function returns true,
78 // the InfoBarManager will not add the new delegate because it considers
79 // one to already be present.
80 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
81
82 // Returns true if the InfoBar should be closed automatically after the page
83 // is navigated. By default this returns true if the navigation is to a new
84 // page (not including reloads). Subclasses wishing to change this behavior
85 // can override either this function or ShouldExpireInternal(), depending on
86 // what level of control they need.
87 virtual bool ShouldExpire(const NavigationDetails& details) const;
88
89 // Called when the user clicks on the close button to dismiss the infobar.
90 virtual void InfoBarDismissed();
91
92 // Return the resource ID of the icon to be shown for this InfoBar. If the
93 // value is equal to |kNoIconID|, no icon is shown.
94 virtual int GetIconID() const;
95
96 // Returns the type of the infobar. The type determines the appearance (such
97 // as background color) of the infobar.
98 virtual Type GetInfoBarType() const;
99
100 // Type-checking downcast routines:
101 virtual AutoLoginInfoBarDelegate* AsAutoLoginInfoBarDelegate();
102 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate();
103 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate();
104 virtual InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate();
105 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate();
106 virtual PopupBlockedInfoBarDelegate* AsPopupBlockedInfoBarDelegate();
107 virtual RegisterProtocolHandlerInfoBarDelegate*
108 AsRegisterProtocolHandlerInfoBarDelegate();
109 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate();
110 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate();
111 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate();
112
113 void set_infobar(InfoBar* infobar) { infobar_ = infobar; }
114
115 // Store the unique id for the active entry, to be used later upon navigation
116 // to determine if this InfoBarDelegate should be expired.
117 void StoreActiveEntryUniqueID();
118
119 // Return the icon to be shown for this InfoBar. If the returned Image is
120 // empty, no icon is shown.
121 virtual gfx::Image GetIcon() const;
122
123 protected:
124 InfoBarDelegate();
125
126 // Returns true if the navigation is to a new URL or a reload occured.
127 virtual bool ShouldExpireInternal(const NavigationDetails& details) const;
128
129 int contents_unique_id() const { return contents_unique_id_; }
130 InfoBar* infobar() { return infobar_; }
131
132 private:
133 // The unique id of the active NavigationEntry of the WebContents that we were
134 // opened for. Used to help expire on navigations.
135 int contents_unique_id_;
136
137 // The InfoBar associated with us.
138 InfoBar* infobar_;
139
140 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate);
141 };
142
143 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/infobars/infobar_container.cc ('k') | chrome/browser/infobars/infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698