- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / website_settings_bubble_controller.h
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.
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 ID of the server certificate from the identity info.
50   // This should always be non-zero on a secure connection, and 0 otherwise.
51   int certificateId_;
52
53   // Container for permission info on the Permissions tab.
54   NSView* permissionsView_;
55
56   NSImageView* identityStatusIcon_;
57   NSTextField* identityStatusDescriptionField_;
58   NSView* separatorAfterIdentity_;
59
60   NSImageView* connectionStatusIcon_;
61   NSTextField* connectionStatusDescriptionField_;
62   NSView* separatorAfterConnection_;
63
64   NSImageView* firstVisitIcon_;
65   NSTextField* firstVisitHeaderField_;
66   NSTextField* firstVisitDescriptionField_;
67   NSView* separatorAfterFirstVisit_;
68
69   // The link button for launch the help center article explaining the
70   // connection info.
71   NSButton* helpButton_;
72
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_;
76
77   // Bridge which implements the WebsiteSettingsUI interface and forwards
78   // methods on to this class.
79   scoped_ptr<WebsiteSettingsUIBridge> bridge_;
80 }
81
82 // Designated initializer. The controller will release itself when the bubble
83 // is closed. |parentWindow| cannot be nil. |webContents| may be nil for
84 // testing purposes.
85 - (id)initWithParentWindow:(NSWindow*)parentWindow
86    websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge
87                webContents:(content::WebContents*)webContents
88             isInternalPage:(BOOL)isInternalPage;
89
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;
93
94 @end
95
96 // Provides a bridge between the WebSettingsUI C++ interface and the Cocoa
97 // implementation in WebsiteSettingsBubbleController.
98 class WebsiteSettingsUIBridge : public WebsiteSettingsUI {
99  public:
100   WebsiteSettingsUIBridge();
101   virtual ~WebsiteSettingsUIBridge();
102
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
107   // |web_contents|.
108   static void Show(gfx::NativeWindow parent,
109                    Profile* profile,
110                    content::WebContents* web_contents,
111                    const GURL& url,
112                    const content::SSLStatus& ssl);
113
114   void set_bubble_controller(
115       WebsiteSettingsBubbleController* bubble_controller);
116
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 string16& first_visit) OVERRIDE;
123   virtual void SetSelectedTab(TabId tab_id) OVERRIDE;
124
125  private:
126   // The Cocoa controller for the bubble UI.
127   WebsiteSettingsBubbleController* bubble_controller_;
128
129   DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsUIBridge);
130 };