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 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
10 #include "chrome/browser/ui/website_settings/website_settings_ui.h"
11 #include "content/public/browser/web_contents_observer.h"
13 class WebsiteSettingsUIBridge
;
19 // This NSWindowController subclass manages the InfoBubbleWindow and view that
20 // are displayed when the user clicks the favicon or security lock icon.
22 // TODO(palmer): Normalize all WebsiteSettings*, SiteSettings*, PageInfo*, et c.
24 @interface WebsiteSettingsBubbleController
: BaseBubbleController
{
26 content::WebContents
* webContents_
;
28 base::scoped_nsobject
<NSView
> contentView_
;
29 base::scoped_nsobject
<NSSegmentedControl
> segmentedControl_
;
30 base::scoped_nsobject
<NSTabView
> tabView_
;
32 // Displays the web site identity.
33 NSTextField
* identityField_
;
35 // Display the identity status (e.g. verified, not verified).
36 NSTextField
* identityStatusField_
;
38 // The main content view for the Permissions tab.
39 NSView
* permissionsTabContentView_
;
41 // The main content view for the Connection tab.
42 NSView
* connectionTabContentView_
;
44 // Container for cookies info on the Permissions tab.
47 // The link button for showing site settings.
48 NSButton
* siteSettingsButton_
;
50 // The link button for showing certificate information.
51 NSButton
* certificateInfoButton_
;
53 // The link button for revoking certificate decisions.
54 NSButton
* resetDecisionsButton_
;
56 // The ID of the server certificate from the identity info. This should
57 // always be non-zero on a secure connection, and 0 otherwise.
60 // Container for permission info on the Permissions tab.
61 NSView
* permissionsView_
;
63 NSImageView
* identityStatusIcon_
;
64 NSTextField
* identityStatusDescriptionField_
;
65 NSView
* separatorAfterIdentity_
;
67 NSImageView
* connectionStatusIcon_
;
68 NSTextField
* connectionStatusDescriptionField_
;
69 NSView
* separatorAfterConnection_
;
71 // The link button to launch the Help Center article explaining the
73 NSButton
* helpButton_
;
75 // The UI translates user actions to specific events and forwards them to the
76 // |presenter_|. The |presenter_| handles these events and updates the UI.
77 scoped_ptr
<WebsiteSettings
> presenter_
;
79 // Bridge which implements the WebsiteSettingsUI interface and forwards
80 // methods on to this class.
81 scoped_ptr
<WebsiteSettingsUIBridge
> bridge_
;
84 // Designated initializer. The controller will release itself when the bubble
85 // is closed. |parentWindow| cannot be nil. |webContents| may be nil for
87 - (id
)initWithParentWindow
:(NSWindow
*)parentWindow
88 websiteSettingsUIBridge
:(WebsiteSettingsUIBridge
*)bridge
89 webContents
:(content::WebContents
*)webContents
90 isInternalPage
:(BOOL
)isInternalPage
;
92 // Return the default width of the window. It may be wider to fit the content.
93 // This may be overriden by a subclass for testing purposes.
94 - (CGFloat
)defaultWindowWidth
;
98 // Provides a bridge between the WebSettingsUI C++ interface and the Cocoa
99 // implementation in WebsiteSettingsBubbleController.
100 class WebsiteSettingsUIBridge
: public content::WebContentsObserver
,
101 public WebsiteSettingsUI
{
103 explicit WebsiteSettingsUIBridge(content::WebContents
* web_contents
);
104 ~WebsiteSettingsUIBridge() override
;
106 // Creates a |WebsiteSettingsBubbleController| and displays the UI. |parent|
107 // is the currently active window. |profile| points to the currently active
108 // profile. |web_contents| points to the WebContents that wraps the currently
109 // active tab. |url| is the GURL of the currently active tab. |ssl| is the
110 // |SSLStatus| of the connection to the website in the currently active tab.
111 static void Show(gfx::NativeWindow parent
,
113 content::WebContents
* web_contents
,
115 const content::SSLStatus
& ssl
);
117 void set_bubble_controller(
118 WebsiteSettingsBubbleController
* bubble_controller
);
120 // WebContentsObserver implementation.
121 void RenderFrameDeleted(content::RenderFrameHost
* render_frame_host
) override
;
123 // WebsiteSettingsUI implementations.
124 void SetCookieInfo(const CookieInfoList
& cookie_info_list
) override
;
125 void SetPermissionInfo(
126 const PermissionInfoList
& permission_info_list
) override
;
127 void SetIdentityInfo(const IdentityInfo
& identity_info
) override
;
128 void SetSelectedTab(TabId tab_id
) override
;
131 // The WebContents the bubble UI is attached to.
132 content::WebContents
* web_contents_
;
134 // The Cocoa controller for the bubble UI.
135 WebsiteSettingsBubbleController
* bubble_controller_
;
137 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsUIBridge
);