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_WEBSITE_SETTINGS_POPUP_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_POPUP_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PAGE_INFO_WEBSITE_SETTINGS_POPUP_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_POPUP_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/website_settings_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 PopupHeaderView; |
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 WebsiteSettingsPopupViewTestApi; | 41 class PageInfoPopupViewTestApi; |
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 website settings UI. | 56 // The views implementation of the page info UI. |
57 class WebsiteSettingsPopupView : public content::WebContentsObserver, | 57 class PageInfoPopupView : 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 WebsiteSettingsUI { | 64 public PageInfoUI { |
65 public: | 65 public: |
66 ~WebsiteSettingsPopupView() override; | 66 ~PageInfoPopupView() override; |
67 | 67 |
68 // Type of the popup being displayed. | 68 // Type of the popup being displayed. |
69 enum PopupType { | 69 enum PopupType { |
70 POPUP_NONE, | 70 POPUP_NONE, |
71 // Usual page info bubble for websites. | 71 // Usual page info bubble for websites. |
72 POPUP_WEBSITE_SETTINGS, | 72 POPUP_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 POPUP_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 ShowPopup(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 popup bubble being shown. |
86 static PopupType GetShownPopupType(); | 86 static PopupType GetShownPopupType(); |
87 | 87 |
88 private: | 88 private: |
89 friend class test::WebsiteSettingsPopupViewTestApi; | 89 friend class test::PageInfoPopupViewTestApi; |
90 | 90 |
91 WebsiteSettingsPopupView(views::View* anchor_view, | 91 PageInfoPopupView(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 WebsiteSettingsUI::PermissionInfo& permission) override; | 104 const PageInfoUI::PermissionInfo& permission) override; |
105 | 105 |
106 // ChosenObjectRowObserver implementation. | 106 // ChosenObjectRowObserver implementation. |
107 void OnChosenObjectDeleted( | 107 void OnChosenObjectDeleted(const PageInfoUI::ChosenObjectInfo& info) override; |
108 const WebsiteSettingsUI::ChosenObjectInfo& info) override; | |
109 | 108 |
110 // views::BubbleDialogDelegateView implementation. | 109 // views::BubbleDialogDelegateView implementation. |
111 base::string16 GetWindowTitle() const override; | 110 base::string16 GetWindowTitle() const override; |
112 bool ShouldShowCloseButton() const override; | 111 bool ShouldShowCloseButton() const override; |
113 void OnWidgetDestroying(views::Widget* widget) override; | 112 void OnWidgetDestroying(views::Widget* widget) override; |
114 int GetDialogButtons() const override; | 113 int GetDialogButtons() const override; |
115 const gfx::FontList& GetTitleFontList() const override; | 114 const gfx::FontList& GetTitleFontList() const override; |
116 | 115 |
117 // views::ButtonListener implementation. | 116 // views::ButtonListener implementation. |
118 void ButtonPressed(views::Button* button, const ui::Event& event) override; | 117 void ButtonPressed(views::Button* button, const ui::Event& event) override; |
119 | 118 |
120 // views::LinkListener implementation. | 119 // views::LinkListener implementation. |
121 void LinkClicked(views::Link* source, int event_flags) override; | 120 void LinkClicked(views::Link* source, int event_flags) override; |
122 | 121 |
123 // views::StyledLabelListener implementation. | 122 // views::StyledLabelListener implementation. |
124 void StyledLabelLinkClicked(views::StyledLabel* label, | 123 void StyledLabelLinkClicked(views::StyledLabel* label, |
125 const gfx::Range& range, | 124 const gfx::Range& range, |
126 int event_flags) override; | 125 int event_flags) override; |
127 | 126 |
128 // views::View implementation. | 127 // views::View implementation. |
129 gfx::Size GetPreferredSize() const override; | 128 gfx::Size GetPreferredSize() const override; |
130 | 129 |
131 // WebsiteSettingsUI implementations. | 130 // PageInfoUI implementations. |
132 void SetCookieInfo(const CookieInfoList& cookie_info_list) override; | 131 void SetCookieInfo(const CookieInfoList& cookie_info_list) override; |
133 void SetPermissionInfo(const PermissionInfoList& permission_info_list, | 132 void SetPermissionInfo(const PermissionInfoList& permission_info_list, |
134 ChosenObjectInfoList chosen_object_info_list) override; | 133 ChosenObjectInfoList chosen_object_info_list) override; |
135 void SetIdentityInfo(const IdentityInfo& identity_info) override; | 134 void SetIdentityInfo(const IdentityInfo& identity_info) override; |
136 | 135 |
137 // Creates the contents of the |site_settings_view_|. The ownership of the | 136 // Creates the contents of the |site_settings_view_|. The ownership of the |
138 // returned view is transferred to the caller. | 137 // returned view is transferred to the caller. |
139 views::View* CreateSiteSettingsView(int side_margin) WARN_UNUSED_RESULT; | 138 views::View* CreateSiteSettingsView(int side_margin) WARN_UNUSED_RESULT; |
140 | 139 |
141 // Used to asynchronously handle clicks since these calls may cause the | 140 // Used to asynchronously handle clicks since these calls may cause the |
142 // destruction of the settings view and the base class window still needs to | 141 // destruction of the settings view and the base class window still needs to |
143 // be alive to finish handling the mouse or keyboard click. | 142 // be alive to finish handling the mouse or keyboard click. |
144 void HandleLinkClickedAsync(views::Link* source); | 143 void HandleLinkClickedAsync(views::Link* source); |
145 | 144 |
146 // Whether DevTools is disabled for the relevant profile. | 145 // Whether DevTools is disabled for the relevant profile. |
147 bool is_devtools_disabled_; | 146 bool is_devtools_disabled_; |
148 | 147 |
149 // The presenter that controls the Website Settings UI. | 148 // The presenter that controls the Page Info UI. |
150 std::unique_ptr<WebsiteSettings> presenter_; | 149 std::unique_ptr<PageInfo> presenter_; |
151 | 150 |
152 Profile* profile_; | 151 Profile* profile_; |
153 | 152 |
154 // The header section (containing security-related information). | 153 // The header section (containing security-related information). |
155 PopupHeaderView* header_; | 154 PopupHeaderView* header_; |
156 | 155 |
157 // The security summary for the current page. | 156 // The security summary for the current page. |
158 base::string16 summary_text_; | 157 base::string16 summary_text_; |
159 | 158 |
160 // The separator between the header and the site settings view. | 159 // The separator between the header and the site settings view. |
(...skipping 10 matching lines...) Expand all Loading... |
171 views::View* permissions_view_; | 170 views::View* permissions_view_; |
172 | 171 |
173 // The certificate provided by the site, if one exists. | 172 // The certificate provided by the site, if one exists. |
174 scoped_refptr<net::X509Certificate> certificate_; | 173 scoped_refptr<net::X509Certificate> certificate_; |
175 | 174 |
176 // 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 |
177 // permissions section, and keep those views updated when the underlying | 176 // permissions section, and keep those views updated when the underlying |
178 // |Permission| changes. | 177 // |Permission| changes. |
179 std::vector<std::unique_ptr<PermissionSelectorRow>> selector_rows_; | 178 std::vector<std::unique_ptr<PermissionSelectorRow>> selector_rows_; |
180 | 179 |
181 base::WeakPtrFactory<WebsiteSettingsPopupView> weak_factory_; | 180 base::WeakPtrFactory<PageInfoPopupView> weak_factory_; |
182 | 181 |
183 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView); | 182 DISALLOW_COPY_AND_ASSIGN(PageInfoPopupView); |
184 }; | 183 }; |
185 | 184 |
186 #endif // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_WEBSITE_SETTINGS_POPUP_VIEW_H_ | 185 #endif // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_PAGE_INFO_POPUP_VIEW_H_ |
OLD | NEW |