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 #import <Cocoa/Cocoa.h> 6 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 12 class WebsiteSettingsUIBridge; 13 14 namespace content { 15 class WebContents; 16 } 17 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 { 21 @private 22 content::WebContents* webContents_; 23 24 base::scoped_nsobject<NSView> contentView_; 25 base::scoped_nsobject<NSSegmentedControl> segmentedControl_; 26 base::scoped_nsobject<NSTabView> tabView_; 27 28 // Displays the web site identity. 29 NSTextField* identityField_; 30 31 // Display the identity status (e.g. verified, not verified). 32 NSTextField* identityStatusField_; 33 34 // The main content view for the Permissions tab. 35 NSView* permissionsTabContentView_; 36 37 // The main content view for the Connection tab. 38 NSView* connectionTabContentView_; 39 40 // Container for cookies info on the Permissions tab. 41 NSView* cookiesView_; 42 43 // The link button for showing cookies and site data info. 44 NSButton* cookiesButton_; 45 46 // The link button for showing certificate information. 47 NSButton* certificateInfoButton_; 48 49 // The link button for revoking certificate decisions. 50 NSButton* resetDecisionsButton_; 51 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. 54 int certificateId_; 55 56 // Container for permission info on the Permissions tab. 57 NSView* permissionsView_; 58 59 NSImageView* identityStatusIcon_; 60 NSTextField* identityStatusDescriptionField_; 61 NSView* separatorAfterIdentity_; 62 63 NSImageView* connectionStatusIcon_; 64 NSTextField* connectionStatusDescriptionField_; 65 NSView* separatorAfterConnection_; 66 67 NSImageView* firstVisitIcon_; 68 NSTextField* firstVisitHeaderField_; 69 NSTextField* firstVisitDescriptionField_; 70 NSView* separatorAfterFirstVisit_; 71 72 // The link button for launch the help center article explaining the 73 // connection info. 74 NSButton* helpButton_; 75 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_; 79 80 // Bridge which implements the WebsiteSettingsUI interface and forwards 81 // methods on to this class. 82 scoped_ptr<WebsiteSettingsUIBridge> bridge_; 83 } 84 85 // Designated initializer. The controller will release itself when the bubble 86 // is closed. |parentWindow| cannot be nil. |webContents| may be nil for 87 // testing purposes. 88 - (id)initWithParentWindow:(NSWindow*)parentWindow 89 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge 90 webContents:(content::WebContents*)webContents 91 isInternalPage:(BOOL)isInternalPage; 92 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; 96 97 @end 98 99 // Provides a bridge between the WebSettingsUI C++ interface and the Cocoa 100 // implementation in WebsiteSettingsBubbleController. 101 class WebsiteSettingsUIBridge : public WebsiteSettingsUI { 102 public: 103 WebsiteSettingsUIBridge(); 104 virtual ~WebsiteSettingsUIBridge(); 105 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 110 // |web_contents|. 111 static void Show(gfx::NativeWindow parent, 112 Profile* profile, 113 content::WebContents* web_contents, 114 const GURL& url, 115 const content::SSLStatus& ssl); 116 117 void set_bubble_controller( 118 WebsiteSettingsBubbleController* bubble_controller); 119 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; 127 128 private: 129 // The Cocoa controller for the bubble UI. 130 WebsiteSettingsBubbleController* bubble_controller_; 131 132 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsUIBridge); 133 }; 134