OLD | NEW |
| (Empty) |
1 // Copyright 2014 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_COCOA_WEBSITE_SETTINGS_WEBSITE_SETTINGS_BUBBLE_CONTROL
LER_H_ | |
6 #define CHROME_BROWSER_UI_COCOA_WEBSITE_SETTINGS_WEBSITE_SETTINGS_BUBBLE_CONTROL
LER_H_ | |
7 | |
8 #import <Cocoa/Cocoa.h> | |
9 | |
10 #include <memory> | |
11 | |
12 #include "base/mac/scoped_nsobject.h" | |
13 #include "base/macros.h" | |
14 #import "chrome/browser/ui/cocoa/omnibox_decoration_bubble_controller.h" | |
15 #include "chrome/browser/ui/page_info/website_settings_ui.h" | |
16 #include "content/public/browser/web_contents_observer.h" | |
17 | |
18 class WebsiteSettingsUIBridge; | |
19 | |
20 namespace content { | |
21 class WebContents; | |
22 } | |
23 | |
24 namespace net { | |
25 class X509Certificate; | |
26 } | |
27 | |
28 namespace security_state { | |
29 struct SecurityInfo; | |
30 } // namespace security_state | |
31 | |
32 // This NSWindowController subclass manages the InfoBubbleWindow and view that | |
33 // are displayed when the user clicks the favicon or security lock icon. | |
34 // | |
35 // TODO(palmer): Normalize all WebsiteSettings*, SiteSettings*, PageInfo*, et c. | |
36 // to OriginInfo*. | |
37 @interface WebsiteSettingsBubbleController : OmniboxDecorationBubbleController { | |
38 @private | |
39 content::WebContents* webContents_; | |
40 | |
41 base::scoped_nsobject<NSView> contentView_; | |
42 | |
43 // The main content view for the Permissions tab. | |
44 NSView* securitySectionView_; | |
45 | |
46 // Displays the short security summary for the page | |
47 // (private/not private/etc.). | |
48 NSTextField* securitySummaryField_; | |
49 | |
50 // Displays a longer explanation of the page's security state, and how the | |
51 // user should treat it. | |
52 NSTextField* securityDetailsField_; | |
53 | |
54 // The link button for opening a Chrome Help Center page explaining connection | |
55 // security. | |
56 NSButton* connectionHelpButton_; | |
57 | |
58 // URL of the page for which the bubble is shown. | |
59 GURL url_; | |
60 | |
61 // Displays a paragraph to accompany the reset decisions button, explaining | |
62 // that the user has made a decision to trust an invalid security certificate | |
63 // for the current site. | |
64 // This field only shows when there is an acrive certificate exception. | |
65 NSTextField* resetDecisionsField_; | |
66 | |
67 // The link button for revoking certificate decisions. | |
68 // This link only shows when there is an acrive certificate exception. | |
69 NSButton* resetDecisionsButton_; | |
70 | |
71 // The server certificate from the identity info. This should always be | |
72 // non-null on a cryptographic connection, and null otherwise. | |
73 scoped_refptr<net::X509Certificate> certificate_; | |
74 | |
75 // Separator line. | |
76 NSView* separatorAfterSecuritySection_; | |
77 | |
78 // Container for the site settings section. | |
79 NSView* siteSettingsSectionView_; | |
80 | |
81 // Container for cookies info in the site settings section. | |
82 NSView* cookiesView_; | |
83 | |
84 // Container for permission info in the site settings section. | |
85 NSView* permissionsView_; | |
86 | |
87 // Whether the permissionView_ shows anything. | |
88 BOOL permissionsPresent_; | |
89 | |
90 // The link button for showing site settings. | |
91 NSButton* siteSettingsButton_; | |
92 | |
93 // The UI translates user actions to specific events and forwards them to the | |
94 // |presenter_|. The |presenter_| handles these events and updates the UI. | |
95 std::unique_ptr<WebsiteSettings> presenter_; | |
96 | |
97 // Bridge which implements the WebsiteSettingsUI interface and forwards | |
98 // methods on to this class. | |
99 std::unique_ptr<WebsiteSettingsUIBridge> bridge_; | |
100 } | |
101 | |
102 // Designated initializer. The controller will release itself when the bubble | |
103 // is closed. |parentWindow| cannot be nil. |webContents| may be nil for | |
104 // testing purposes. | |
105 - (id)initWithParentWindow:(NSWindow*)parentWindow | |
106 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge | |
107 webContents:(content::WebContents*)webContents | |
108 url:(const GURL&)url; | |
109 | |
110 // Return the default width of the window. It may be wider to fit the content. | |
111 // This may be overriden by a subclass for testing purposes. | |
112 - (CGFloat)defaultWindowWidth; | |
113 | |
114 @end | |
115 | |
116 // Provides a bridge between the WebSettingsUI C++ interface and the Cocoa | |
117 // implementation in WebsiteSettingsBubbleController. | |
118 class WebsiteSettingsUIBridge : public content::WebContentsObserver, | |
119 public WebsiteSettingsUI { | |
120 public: | |
121 explicit WebsiteSettingsUIBridge(content::WebContents* web_contents); | |
122 ~WebsiteSettingsUIBridge() override; | |
123 | |
124 // Creates a |WebsiteSettingsBubbleController| and displays the UI. |parent| | |
125 // is the currently active window. |profile| points to the currently active | |
126 // profile. |web_contents| points to the WebContents that wraps the currently | |
127 // active tab. |virtual_url| is the virtual GURL of the currently active | |
128 // tab. |security_info| is the |security_state::SecurityInfo| of the | |
129 // connection to the website in the currently active tab. | |
130 static void Show(gfx::NativeWindow parent, | |
131 Profile* profile, | |
132 content::WebContents* web_contents, | |
133 const GURL& virtual_url, | |
134 const security_state::SecurityInfo& security_info); | |
135 | |
136 void set_bubble_controller( | |
137 WebsiteSettingsBubbleController* bubble_controller); | |
138 | |
139 // WebContentsObserver implementation. | |
140 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; | |
141 | |
142 // WebsiteSettingsUI implementations. | |
143 void SetCookieInfo(const CookieInfoList& cookie_info_list) override; | |
144 void SetPermissionInfo(const PermissionInfoList& permission_info_list, | |
145 ChosenObjectInfoList chosen_object_info_list) override; | |
146 void SetIdentityInfo(const IdentityInfo& identity_info) override; | |
147 | |
148 private: | |
149 // The WebContents the bubble UI is attached to. | |
150 content::WebContents* web_contents_; | |
151 | |
152 // The Cocoa controller for the bubble UI. | |
153 WebsiteSettingsBubbleController* bubble_controller_; | |
154 | |
155 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsUIBridge); | |
156 }; | |
157 | |
158 #endif // CHROME_BROWSER_UI_COCOA_WEBSITE_SETTINGS_WEBSITE_SETTINGS_BUBBLE_CONT
ROLLER_H_ | |
OLD | NEW |