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.
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 ID of the server certificate from the identity info.
50 // This should always be non-zero on a secure connection, and 0 otherwise.
53 // Container for permission info on the Permissions tab.
54 NSView
* permissionsView_
;
56 NSImageView
* identityStatusIcon_
;
57 NSTextField
* identityStatusDescriptionField_
;
58 NSView
* separatorAfterIdentity_
;
60 NSImageView
* connectionStatusIcon_
;
61 NSTextField
* connectionStatusDescriptionField_
;
62 NSView
* separatorAfterConnection_
;
64 NSImageView
* firstVisitIcon_
;
65 NSTextField
* firstVisitHeaderField_
;
66 NSTextField
* firstVisitDescriptionField_
;
67 NSView
* separatorAfterFirstVisit_
;
69 // The link button for launch the help center article explaining the
71 NSButton
* helpButton_
;
73 // The UI translates user actions to specific events and forwards them to the
74 // |presenter_|. The |presenter_| handles these events and updates the UI.
75 scoped_ptr
<WebsiteSettings
> presenter_
;
77 // Bridge which implements the WebsiteSettingsUI interface and forwards
78 // methods on to this class.
79 scoped_ptr
<WebsiteSettingsUIBridge
> bridge_
;
82 // Designated initializer. The controller will release itself when the bubble
83 // is closed. |parentWindow| cannot be nil. |webContents| may be nil for
85 - (id
)initWithParentWindow
:(NSWindow
*)parentWindow
86 websiteSettingsUIBridge
:(WebsiteSettingsUIBridge
*)bridge
87 webContents
:(content::WebContents
*)webContents
88 isInternalPage
:(BOOL
)isInternalPage
;
90 // Return the default width of the window. It may be wider to fit the content.
91 // This may be overriden by a subclass for testing purposes.
92 - (CGFloat
)defaultWindowWidth
;
96 // Provides a bridge between the WebSettingsUI C++ interface and the Cocoa
97 // implementation in WebsiteSettingsBubbleController.
98 class WebsiteSettingsUIBridge
: public WebsiteSettingsUI
{
100 WebsiteSettingsUIBridge();
101 virtual ~WebsiteSettingsUIBridge();
103 // Creates a |WebsiteSettingsBubbleController| and displays the UI. |parent|
104 // contains the currently active window, |profile| contains the currently
105 // active profile and |ssl| contains the |SSLStatus| of the connection to the
106 // website in the currently active tab that is wrapped by the
108 static void Show(gfx::NativeWindow parent
,
110 content::WebContents
* web_contents
,
112 const content::SSLStatus
& ssl
);
114 void set_bubble_controller(
115 WebsiteSettingsBubbleController
* bubble_controller
);
117 // WebsiteSettingsUI implementations.
118 virtual void SetCookieInfo(const CookieInfoList
& cookie_info_list
) OVERRIDE
;
119 virtual void SetPermissionInfo(
120 const PermissionInfoList
& permission_info_list
) OVERRIDE
;
121 virtual void SetIdentityInfo(const IdentityInfo
& identity_info
) OVERRIDE
;
122 virtual void SetFirstVisit(const base::string16
& first_visit
) OVERRIDE
;
123 virtual void SetSelectedTab(TabId tab_id
) OVERRIDE
;
126 // The Cocoa controller for the bubble UI.
127 WebsiteSettingsBubbleController
* bubble_controller_
;
129 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsUIBridge
);