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.
5 #import <Cocoa/Cocoa.h>
7 #include "base/mac/scoped_nsobject.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/ssl/security_state_model.h"
10 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
11 #include "chrome/browser/ui/website_settings/website_settings_ui.h"
12 #include "content/public/browser/web_contents_observer.h"
14 class WebsiteSettingsUIBridge
;
20 // This NSWindowController subclass manages the InfoBubbleWindow and view that
21 // are displayed when the user clicks the favicon or security lock icon.
23 // TODO(palmer): Normalize all WebsiteSettings*, SiteSettings*, PageInfo*, et c.
25 @interface WebsiteSettingsBubbleController
: BaseBubbleController
{
27 content::WebContents
* webContents_
;
29 base::scoped_nsobject
<NSView
> contentView_
;
30 base::scoped_nsobject
<NSSegmentedControl
> segmentedControl_
;
31 base::scoped_nsobject
<NSTabView
> tabView_
;
33 // Displays the web site identity.
34 NSTextField
* identityField_
;
36 // Display the identity status (e.g. verified, not verified).
37 NSTextField
* identityStatusField_
;
39 // The main content view for the Permissions tab.
40 NSView
* permissionsTabContentView_
;
42 // The main content view for the Connection tab.
43 NSView
* connectionTabContentView_
;
45 // Container for cookies info on the Permissions tab.
48 // The link button for showing site settings.
49 NSButton
* siteSettingsButton_
;
51 // The link button for showing certificate information.
52 NSButton
* certificateInfoButton_
;
54 // The link button for revoking certificate decisions.
55 NSButton
* resetDecisionsButton_
;
57 // The ID of the server certificate from the identity info. This should
58 // always be non-zero on a secure connection, and 0 otherwise.
61 // Container for permission info on the Permissions tab.
62 NSView
* permissionsView_
;
64 NSImageView
* identityStatusIcon_
;
65 NSTextField
* identityStatusDescriptionField_
;
66 NSView
* separatorAfterIdentity_
;
68 NSImageView
* connectionStatusIcon_
;
69 NSTextField
* connectionStatusDescriptionField_
;
70 NSView
* separatorAfterConnection_
;
72 // The link button to launch the Help Center article explaining the
74 NSButton
* helpButton_
;
76 // The UI translates user actions to specific events and forwards them to the
77 // |presenter_|. The |presenter_| handles these events and updates the UI.
78 scoped_ptr
<WebsiteSettings
> presenter_
;
80 // Bridge which implements the WebsiteSettingsUI interface and forwards
81 // methods on to this class.
82 scoped_ptr
<WebsiteSettingsUIBridge
> bridge_
;
85 // Designated initializer. The controller will release itself when the bubble
86 // is closed. |parentWindow| cannot be nil. |webContents| may be nil for
88 - (id
)initWithParentWindow
:(NSWindow
*)parentWindow
89 websiteSettingsUIBridge
:(WebsiteSettingsUIBridge
*)bridge
90 webContents
:(content::WebContents
*)webContents
91 isInternalPage
:(BOOL
)isInternalPage
;
93 // Return the default width of the window. It may be wider to fit the content.
94 // This may be overriden by a subclass for testing purposes.
95 - (CGFloat
)defaultWindowWidth
;
99 // Provides a bridge between the WebSettingsUI C++ interface and the Cocoa
100 // implementation in WebsiteSettingsBubbleController.
101 class WebsiteSettingsUIBridge
: public content::WebContentsObserver
,
102 public WebsiteSettingsUI
{
104 explicit WebsiteSettingsUIBridge(content::WebContents
* web_contents
);
105 ~WebsiteSettingsUIBridge() override
;
107 // Creates a |WebsiteSettingsBubbleController| and displays the UI. |parent|
108 // is the currently active window. |profile| points to the currently active
109 // profile. |web_contents| points to the WebContents that wraps the currently
110 // active tab. |url| is the GURL of the currently active
111 // tab. |security_info| is the |SecurityStateModel::SecurityInfo| of
112 // the connection to the website in the currently active tab.
113 static void Show(gfx::NativeWindow parent
,
115 content::WebContents
* web_contents
,
117 const SecurityStateModel::SecurityInfo
& security_info
);
119 void set_bubble_controller(
120 WebsiteSettingsBubbleController
* bubble_controller
);
122 // WebContentsObserver implementation.
123 void RenderFrameDeleted(content::RenderFrameHost
* render_frame_host
) override
;
125 // WebsiteSettingsUI implementations.
126 void SetCookieInfo(const CookieInfoList
& cookie_info_list
) override
;
127 void SetPermissionInfo(
128 const PermissionInfoList
& permission_info_list
) override
;
129 void SetIdentityInfo(const IdentityInfo
& identity_info
) override
;
130 void SetSelectedTab(TabId tab_id
) override
;
133 // The WebContents the bubble UI is attached to.
134 content::WebContents
* web_contents_
;
136 // The Cocoa controller for the bubble UI.
137 WebsiteSettingsBubbleController
* bubble_controller_
;
139 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsUIBridge
);