| OLD | NEW |
| (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_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_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/website_settings_ui.h" | |
| 14 #include "chrome/browser/ui/views/website_settings/chosen_object_row_observer.h" | |
| 15 #include "chrome/browser/ui/views/website_settings/permission_selector_row.h" | |
| 16 #include "chrome/browser/ui/views/website_settings/permission_selector_row_obser
ver.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 WebsiteSettingsPopupViewTestApi; | |
| 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 website settings UI. | |
| 57 class WebsiteSettingsPopupView : 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 WebsiteSettingsUI { | |
| 65 public: | |
| 66 ~WebsiteSettingsPopupView() override; | |
| 67 | |
| 68 // Type of the popup being displayed. | |
| 69 enum PopupType { | |
| 70 POPUP_NONE, | |
| 71 // Usual page info bubble for websites. | |
| 72 POPUP_WEBSITE_SETTINGS, | |
| 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::WebsiteSettingsPopupViewTestApi; | |
| 90 | |
| 91 WebsiteSettingsPopupView(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 WebsiteSettingsUI::PermissionInfo& permission) override; | |
| 105 | |
| 106 // ChosenObjectRowObserver implementation. | |
| 107 void OnChosenObjectDeleted( | |
| 108 const WebsiteSettingsUI::ChosenObjectInfo& info) override; | |
| 109 | |
| 110 // views::BubbleDialogDelegateView implementation. | |
| 111 base::string16 GetWindowTitle() const override; | |
| 112 bool ShouldShowCloseButton() const override; | |
| 113 void OnWidgetDestroying(views::Widget* widget) override; | |
| 114 int GetDialogButtons() const override; | |
| 115 const gfx::FontList& GetTitleFontList() const override; | |
| 116 | |
| 117 // views::ButtonListener implementation. | |
| 118 void ButtonPressed(views::Button* button, const ui::Event& event) override; | |
| 119 | |
| 120 // views::LinkListener implementation. | |
| 121 void LinkClicked(views::Link* source, int event_flags) override; | |
| 122 | |
| 123 // views::StyledLabelListener implementation. | |
| 124 void StyledLabelLinkClicked(views::StyledLabel* label, | |
| 125 const gfx::Range& range, | |
| 126 int event_flags) override; | |
| 127 | |
| 128 // views::View implementation. | |
| 129 gfx::Size GetPreferredSize() const override; | |
| 130 | |
| 131 // WebsiteSettingsUI implementations. | |
| 132 void SetCookieInfo(const CookieInfoList& cookie_info_list) override; | |
| 133 void SetPermissionInfo(const PermissionInfoList& permission_info_list, | |
| 134 ChosenObjectInfoList chosen_object_info_list) override; | |
| 135 void SetIdentityInfo(const IdentityInfo& identity_info) override; | |
| 136 | |
| 137 // Creates the contents of the |site_settings_view_|. The ownership of the | |
| 138 // returned view is transferred to the caller. | |
| 139 views::View* CreateSiteSettingsView(int side_margin) WARN_UNUSED_RESULT; | |
| 140 | |
| 141 // 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 | |
| 143 // be alive to finish handling the mouse or keyboard click. | |
| 144 void HandleLinkClickedAsync(views::Link* source); | |
| 145 | |
| 146 // Whether DevTools is disabled for the relevant profile. | |
| 147 bool is_devtools_disabled_; | |
| 148 | |
| 149 // The presenter that controls the Website Settings UI. | |
| 150 std::unique_ptr<WebsiteSettings> presenter_; | |
| 151 | |
| 152 Profile* profile_; | |
| 153 | |
| 154 // The header section (containing security-related information). | |
| 155 PopupHeaderView* header_; | |
| 156 | |
| 157 // The security summary for the current page. | |
| 158 base::string16 summary_text_; | |
| 159 | |
| 160 // The separator between the header and the site settings view. | |
| 161 views::Separator* separator_; | |
| 162 | |
| 163 // The view that contains the cookie and permissions sections. | |
| 164 views::View* site_settings_view_; | |
| 165 // The view that contains the contents of the "Cookies" part of the site | |
| 166 // settings view. | |
| 167 views::View* cookies_view_; | |
| 168 // The link that opens the "Cookies" dialog. | |
| 169 views::Link* cookie_dialog_link_; | |
| 170 // The view that contains the "Permissions" table of the site settings view. | |
| 171 views::View* permissions_view_; | |
| 172 | |
| 173 // The certificate provided by the site, if one exists. | |
| 174 scoped_refptr<net::X509Certificate> certificate_; | |
| 175 | |
| 176 // 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 | |
| 178 // |Permission| changes. | |
| 179 std::vector<std::unique_ptr<PermissionSelectorRow>> selector_rows_; | |
| 180 | |
| 181 base::WeakPtrFactory<WebsiteSettingsPopupView> weak_factory_; | |
| 182 | |
| 183 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView); | |
| 184 }; | |
| 185 | |
| 186 #endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_
H_ | |
| OLD | NEW |