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

Side by Side Diff: chrome/browser/ui/views/page_info/page_info_popup_view.h

Issue 2797923003: Rename PageInfoPopupView to PageInfoBubbleView. (Closed)
Patch Set: Two more words. Created 3 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
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_UI_VIEWS_PAGE_INFO_PAGE_INFO_POPUP_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_POPUP_VIEW_H_
7
8 #include <memory>
9
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/ui/page_info/page_info_ui.h"
14 #include "chrome/browser/ui/views/page_info/chosen_object_row_observer.h"
15 #include "chrome/browser/ui/views/page_info/permission_selector_row.h"
16 #include "chrome/browser/ui/views/page_info/permission_selector_row_observer.h"
17 #include "content/public/browser/web_contents_observer.h"
18 #include "ui/views/bubble/bubble_dialog_delegate.h"
19 #include "ui/views/controls/button/button.h"
20 #include "ui/views/controls/link_listener.h"
21 #include "ui/views/controls/separator.h"
22 #include "ui/views/controls/styled_label_listener.h"
23
24 class GURL;
25 class PopupHeaderView;
26 class Profile;
27
28 namespace content {
29 class WebContents;
30 }
31
32 namespace net {
33 class X509Certificate;
34 }
35
36 namespace security_state {
37 struct SecurityInfo;
38 } // namespace security_state
39
40 namespace test {
41 class PageInfoPopupViewTestApi;
42 }
43
44 namespace views {
45 class Link;
46 class Widget;
47 }
48
49 enum : int {
50 // Left icon margin.
51 kPermissionIconMarginLeft = 6,
52 // The width of the column that contains the permissions icons.
53 kPermissionIconColumnWidth = 16,
54 };
55
56 // The views implementation of the page info UI.
57 class PageInfoPopupView : public content::WebContentsObserver,
58 public PermissionSelectorRowObserver,
59 public ChosenObjectRowObserver,
60 public views::BubbleDialogDelegateView,
61 public views::ButtonListener,
62 public views::LinkListener,
63 public views::StyledLabelListener,
64 public PageInfoUI {
65 public:
66 ~PageInfoPopupView() override;
67
68 // Type of the popup being displayed.
69 enum PopupType {
70 POPUP_NONE,
71 // Usual page info bubble for websites.
72 POPUP_PAGE_INFO,
73 // Custom bubble for internal pages like chrome:// and chrome-extensions://.
74 POPUP_INTERNAL_PAGE
75 };
76
77 // If |anchor_view| is null, |anchor_rect| is used to anchor the bubble.
78 static void ShowPopup(views::View* anchor_view,
79 const gfx::Rect& anchor_rect,
80 Profile* profile,
81 content::WebContents* web_contents,
82 const GURL& url,
83 const security_state::SecurityInfo& security_info);
84
85 // Returns the type of the popup bubble being shown.
86 static PopupType GetShownPopupType();
87
88 private:
89 friend class test::PageInfoPopupViewTestApi;
90
91 PageInfoPopupView(views::View* anchor_view,
92 gfx::NativeView parent_window,
93 Profile* profile,
94 content::WebContents* web_contents,
95 const GURL& url,
96 const security_state::SecurityInfo& security_info);
97
98 // WebContentsObserver implementation.
99 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
100 void WebContentsDestroyed() override;
101
102 // PermissionSelectorRowObserver implementation.
103 void OnPermissionChanged(
104 const PageInfoUI::PermissionInfo& permission) override;
105
106 // ChosenObjectRowObserver implementation.
107 void OnChosenObjectDeleted(const PageInfoUI::ChosenObjectInfo& info) override;
108
109 // views::BubbleDialogDelegateView implementation.
110 base::string16 GetWindowTitle() const override;
111 bool ShouldShowCloseButton() const override;
112 void OnWidgetDestroying(views::Widget* widget) override;
113 int GetDialogButtons() const override;
114 const gfx::FontList& GetTitleFontList() const override;
115
116 // views::ButtonListener implementation.
117 void ButtonPressed(views::Button* button, const ui::Event& event) override;
118
119 // views::LinkListener implementation.
120 void LinkClicked(views::Link* source, int event_flags) override;
121
122 // views::StyledLabelListener implementation.
123 void StyledLabelLinkClicked(views::StyledLabel* label,
124 const gfx::Range& range,
125 int event_flags) override;
126
127 // views::View implementation.
128 gfx::Size GetPreferredSize() const override;
129
130 // PageInfoUI implementations.
131 void SetCookieInfo(const CookieInfoList& cookie_info_list) override;
132 void SetPermissionInfo(const PermissionInfoList& permission_info_list,
133 ChosenObjectInfoList chosen_object_info_list) override;
134 void SetIdentityInfo(const IdentityInfo& identity_info) override;
135
136 // Creates the contents of the |site_settings_view_|. The ownership of the
137 // returned view is transferred to the caller.
138 views::View* CreateSiteSettingsView(int side_margin) WARN_UNUSED_RESULT;
139
140 // Used to asynchronously handle clicks since these calls may cause the
141 // destruction of the settings view and the base class window still needs to
142 // be alive to finish handling the mouse or keyboard click.
143 void HandleLinkClickedAsync(views::Link* source);
144
145 // Whether DevTools is disabled for the relevant profile.
146 bool is_devtools_disabled_;
147
148 // The presenter that controls the Page Info UI.
149 std::unique_ptr<PageInfo> presenter_;
150
151 Profile* profile_;
152
153 // The header section (containing security-related information).
154 PopupHeaderView* header_;
155
156 // The security summary for the current page.
157 base::string16 summary_text_;
158
159 // The separator between the header and the site settings view.
160 views::Separator* separator_;
161
162 // The view that contains the cookie and permissions sections.
163 views::View* site_settings_view_;
164 // The view that contains the contents of the "Cookies" part of the site
165 // settings view.
166 views::View* cookies_view_;
167 // The link that opens the "Cookies" dialog.
168 views::Link* cookie_dialog_link_;
169 // The view that contains the "Permissions" table of the site settings view.
170 views::View* permissions_view_;
171
172 // The certificate provided by the site, if one exists.
173 scoped_refptr<net::X509Certificate> certificate_;
174
175 // These rows bundle together all the |View|s involved in a single row of the
176 // permissions section, and keep those views updated when the underlying
177 // |Permission| changes.
178 std::vector<std::unique_ptr<PermissionSelectorRow>> selector_rows_;
179
180 base::WeakPtrFactory<PageInfoPopupView> weak_factory_;
181
182 DISALLOW_COPY_AND_ASSIGN(PageInfoPopupView);
183 };
184
185 #endif // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_POPUP_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698