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"
12 class WebsiteSettingsUIBridge
;
18 // This NSWindowController subclass manages the InfoBubbleWindow and view that
19 // are displayed when the user clicks the favicon or security lock icon.
20 @interface WebsiteSettingsBubbleController
: BaseBubbleController
{
22 content::WebContents
* webContents_
;
24 base::scoped_nsobject
<NSView
> contentView_
;
25 base::scoped_nsobject
<NSSegmentedControl
> segmentedControl_
;
26 base::scoped_nsobject
<NSTabView
> tabView_
;
28 // Displays the web site identity.
29 NSTextField
* identityField_
;
31 // Display the identity status (e.g. verified, not verified).
32 NSTextField
* identityStatusField_
;
34 // The main content view for the Permissions tab.
35 NSView
* permissionsTabContentView_
;
37 // The main content view for the Connection tab.
38 NSView
* connectionTabContentView_
;
40 // Container for cookies info on the Permissions tab.
43 // The link button for showing cookies and site data info.
44 NSButton
* cookiesButton_
;
46 // The link button for showing certificate information.
47 NSButton
* certificateInfoButton_
;
49 // The link button for revoking certificate decisions.
50 NSButton
* resetDecisionsButton_
;
52 // The ID of the server certificate from the identity info.
53 // This should always be non-zero on a secure connection, and 0 otherwise.
56 // Container for permission info on the Permissions tab.
57 NSView
* permissionsView_
;
59 NSImageView
* identityStatusIcon_
;
60 NSTextField
* identityStatusDescriptionField_
;
61 NSView
* separatorAfterIdentity_
;
63 NSImageView
* connectionStatusIcon_
;
64 NSTextField
* connectionStatusDescriptionField_
;
65 NSView
* separatorAfterConnection_
;
67 NSImageView
* firstVisitIcon_
;
68 NSTextField
* firstVisitHeaderField_
;
69 NSTextField
* firstVisitDescriptionField_
;
70 NSView
* separatorAfterFirstVisit_
;
72 // The link button for 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 WebsiteSettingsUI
{
103 WebsiteSettingsUIBridge();
104 virtual ~WebsiteSettingsUIBridge();
106 // Creates a |WebsiteSettingsBubbleController| and displays the UI. |parent|
107 // contains the currently active window, |profile| contains the currently
108 // active profile and |ssl| contains the |SSLStatus| of the connection to the
109 // website in the currently active tab that is wrapped by the
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 // WebsiteSettingsUI implementations.
121 virtual void SetCookieInfo(const CookieInfoList
& cookie_info_list
) OVERRIDE
;
122 virtual void SetPermissionInfo(
123 const PermissionInfoList
& permission_info_list
) OVERRIDE
;
124 virtual void SetIdentityInfo(const IdentityInfo
& identity_info
) OVERRIDE
;
125 virtual void SetFirstVisit(const base::string16
& first_visit
) OVERRIDE
;
126 virtual void SetSelectedTab(TabId tab_id
) OVERRIDE
;
129 // The Cocoa controller for the bubble UI.
130 WebsiteSettingsBubbleController
* bubble_controller_
;
132 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsUIBridge
);