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_UI_VIEWS_PAGE_INFO_PAGE_INFO_POPUP_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_BUBBLE_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_POPUP_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_BUBBLE_VIEW_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/ui/page_info/page_info_ui.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" | 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" | 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" | 16 #include "chrome/browser/ui/views/page_info/permission_selector_row_observer.h" |
17 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
18 #include "ui/views/bubble/bubble_dialog_delegate.h" | 18 #include "ui/views/bubble/bubble_dialog_delegate.h" |
19 #include "ui/views/controls/button/button.h" | 19 #include "ui/views/controls/button/button.h" |
20 #include "ui/views/controls/link_listener.h" | 20 #include "ui/views/controls/link_listener.h" |
21 #include "ui/views/controls/separator.h" | 21 #include "ui/views/controls/separator.h" |
22 #include "ui/views/controls/styled_label_listener.h" | 22 #include "ui/views/controls/styled_label_listener.h" |
23 | 23 |
24 class GURL; | 24 class GURL; |
25 class PopupHeaderView; | 25 class BubbleHeaderView; |
26 class Profile; | 26 class Profile; |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 class WebContents; | 29 class WebContents; |
30 } | 30 } |
31 | 31 |
32 namespace net { | 32 namespace net { |
33 class X509Certificate; | 33 class X509Certificate; |
34 } | 34 } |
35 | 35 |
36 namespace security_state { | 36 namespace security_state { |
37 struct SecurityInfo; | 37 struct SecurityInfo; |
38 } // namespace security_state | 38 } // namespace security_state |
39 | 39 |
40 namespace test { | 40 namespace test { |
41 class PageInfoPopupViewTestApi; | 41 class PageInfoBubbleViewTestApi; |
42 } | 42 } |
43 | 43 |
44 namespace views { | 44 namespace views { |
45 class Link; | 45 class Link; |
46 class Widget; | 46 class Widget; |
47 } | 47 } |
48 | 48 |
49 enum : int { | 49 enum : int { |
50 // Left icon margin. | 50 // Left icon margin. |
51 kPermissionIconMarginLeft = 6, | 51 kPermissionIconMarginLeft = 6, |
52 // The width of the column that contains the permissions icons. | 52 // The width of the column that contains the permissions icons. |
53 kPermissionIconColumnWidth = 16, | 53 kPermissionIconColumnWidth = 16, |
54 }; | 54 }; |
55 | 55 |
56 // The views implementation of the page info UI. | 56 // The views implementation of the page info UI. |
57 class PageInfoPopupView : public content::WebContentsObserver, | 57 class PageInfoBubbleView : public content::WebContentsObserver, |
58 public PermissionSelectorRowObserver, | 58 public PermissionSelectorRowObserver, |
59 public ChosenObjectRowObserver, | 59 public ChosenObjectRowObserver, |
60 public views::BubbleDialogDelegateView, | 60 public views::BubbleDialogDelegateView, |
61 public views::ButtonListener, | 61 public views::ButtonListener, |
62 public views::LinkListener, | 62 public views::LinkListener, |
63 public views::StyledLabelListener, | 63 public views::StyledLabelListener, |
64 public PageInfoUI { | 64 public PageInfoUI { |
65 public: | 65 public: |
66 ~PageInfoPopupView() override; | 66 ~PageInfoBubbleView() override; |
67 | 67 |
68 // Type of the popup being displayed. | 68 // Type of the bubble being displayed. |
69 enum PopupType { | 69 enum BubbleType { |
70 POPUP_NONE, | 70 BUBBLE_NONE, |
71 // Usual page info bubble for websites. | 71 // Usual page info bubble for websites. |
72 POPUP_PAGE_INFO, | 72 BUBBLE_PAGE_INFO, |
73 // Custom bubble for internal pages like chrome:// and chrome-extensions://. | 73 // Custom bubble for internal pages like chrome:// and chrome-extensions://. |
74 POPUP_INTERNAL_PAGE | 74 BUBBLE_INTERNAL_PAGE |
75 }; | 75 }; |
76 | 76 |
77 // If |anchor_view| is null, |anchor_rect| is used to anchor the bubble. | 77 // If |anchor_view| is null, |anchor_rect| is used to anchor the bubble. |
78 static void ShowPopup(views::View* anchor_view, | 78 static void ShowBubble(views::View* anchor_view, |
79 const gfx::Rect& anchor_rect, | 79 const gfx::Rect& anchor_rect, |
80 Profile* profile, | 80 Profile* profile, |
81 content::WebContents* web_contents, | 81 content::WebContents* web_contents, |
82 const GURL& url, | 82 const GURL& url, |
83 const security_state::SecurityInfo& security_info); | 83 const security_state::SecurityInfo& security_info); |
84 | 84 |
85 // Returns the type of the popup bubble being shown. | 85 // Returns the type of the bubble being shown. |
86 static PopupType GetShownPopupType(); | 86 static BubbleType GetShownBubbleType(); |
87 | 87 |
88 private: | 88 private: |
89 friend class test::PageInfoPopupViewTestApi; | 89 friend class test::PageInfoBubbleViewTestApi; |
90 | 90 |
91 PageInfoPopupView(views::View* anchor_view, | 91 PageInfoBubbleView(views::View* anchor_view, |
92 gfx::NativeView parent_window, | 92 gfx::NativeView parent_window, |
93 Profile* profile, | 93 Profile* profile, |
94 content::WebContents* web_contents, | 94 content::WebContents* web_contents, |
95 const GURL& url, | 95 const GURL& url, |
96 const security_state::SecurityInfo& security_info); | 96 const security_state::SecurityInfo& security_info); |
97 | 97 |
98 // WebContentsObserver implementation. | 98 // WebContentsObserver implementation. |
99 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; | 99 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
100 void WebContentsDestroyed() override; | 100 void WebContentsDestroyed() override; |
101 | 101 |
102 // PermissionSelectorRowObserver implementation. | 102 // PermissionSelectorRowObserver implementation. |
103 void OnPermissionChanged( | 103 void OnPermissionChanged( |
104 const PageInfoUI::PermissionInfo& permission) override; | 104 const PageInfoUI::PermissionInfo& permission) override; |
105 | 105 |
106 // ChosenObjectRowObserver implementation. | 106 // ChosenObjectRowObserver implementation. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 // Whether DevTools is disabled for the relevant profile. | 145 // Whether DevTools is disabled for the relevant profile. |
146 bool is_devtools_disabled_; | 146 bool is_devtools_disabled_; |
147 | 147 |
148 // The presenter that controls the Page Info UI. | 148 // The presenter that controls the Page Info UI. |
149 std::unique_ptr<PageInfo> presenter_; | 149 std::unique_ptr<PageInfo> presenter_; |
150 | 150 |
151 Profile* profile_; | 151 Profile* profile_; |
152 | 152 |
153 // The header section (containing security-related information). | 153 // The header section (containing security-related information). |
154 PopupHeaderView* header_; | 154 BubbleHeaderView* header_; |
155 | 155 |
156 // The security summary for the current page. | 156 // The security summary for the current page. |
157 base::string16 summary_text_; | 157 base::string16 summary_text_; |
158 | 158 |
159 // The separator between the header and the site settings view. | 159 // The separator between the header and the site settings view. |
160 views::Separator* separator_; | 160 views::Separator* separator_; |
161 | 161 |
162 // The view that contains the cookie and permissions sections. | 162 // The view that contains the cookie and permissions sections. |
163 views::View* site_settings_view_; | 163 views::View* site_settings_view_; |
164 // The view that contains the contents of the "Cookies" part of the site | 164 // The view that contains the contents of the "Cookies" part of the site |
165 // settings view. | 165 // settings view. |
166 views::View* cookies_view_; | 166 views::View* cookies_view_; |
167 // The link that opens the "Cookies" dialog. | 167 // The link that opens the "Cookies" dialog. |
168 views::Link* cookie_dialog_link_; | 168 views::Link* cookie_dialog_link_; |
169 // The view that contains the "Permissions" table of the site settings view. | 169 // The view that contains the "Permissions" table of the site settings view. |
170 views::View* permissions_view_; | 170 views::View* permissions_view_; |
171 | 171 |
172 // The certificate provided by the site, if one exists. | 172 // The certificate provided by the site, if one exists. |
173 scoped_refptr<net::X509Certificate> certificate_; | 173 scoped_refptr<net::X509Certificate> certificate_; |
174 | 174 |
175 // These rows bundle together all the |View|s involved in a single row of the | 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 | 176 // permissions section, and keep those views updated when the underlying |
177 // |Permission| changes. | 177 // |Permission| changes. |
178 std::vector<std::unique_ptr<PermissionSelectorRow>> selector_rows_; | 178 std::vector<std::unique_ptr<PermissionSelectorRow>> selector_rows_; |
179 | 179 |
180 base::WeakPtrFactory<PageInfoPopupView> weak_factory_; | 180 base::WeakPtrFactory<PageInfoBubbleView> weak_factory_; |
181 | 181 |
182 DISALLOW_COPY_AND_ASSIGN(PageInfoPopupView); | 182 DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleView); |
183 }; | 183 }; |
184 | 184 |
185 #endif // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_POPUP_VIEW_H_ | 185 #endif // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_BUBBLE_VIEW_H_ |
OLD | NEW |