OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_COCOA_WEBSITE_SETTINGS_WEBSITE_SETTINGS_BUBBLE_CONTROL
LER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_PAGE_INFO_PAGE_INFO_BUBBLE_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_WEBSITE_SETTINGS_WEBSITE_SETTINGS_BUBBLE_CONTROL
LER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_PAGE_INFO_PAGE_INFO_BUBBLE_CONTROLLER_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #import "chrome/browser/ui/cocoa/omnibox_decoration_bubble_controller.h" | 14 #import "chrome/browser/ui/cocoa/omnibox_decoration_bubble_controller.h" |
15 #include "chrome/browser/ui/page_info/website_settings_ui.h" | 15 #include "chrome/browser/ui/page_info/page_info_ui.h" |
16 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
17 | 17 |
18 class WebsiteSettingsUIBridge; | 18 class PageInfoUIBridge; |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 class WebContents; | 21 class WebContents; |
22 } | 22 } |
23 | 23 |
24 namespace net { | 24 namespace net { |
25 class X509Certificate; | 25 class X509Certificate; |
26 } | 26 } |
27 | 27 |
28 namespace security_state { | 28 namespace security_state { |
29 struct SecurityInfo; | 29 struct SecurityInfo; |
30 } // namespace security_state | 30 } // namespace security_state |
31 | 31 |
32 // This NSWindowController subclass manages the InfoBubbleWindow and view that | 32 // This NSWindowController subclass manages the InfoBubbleWindow and view that |
33 // are displayed when the user clicks the favicon or security lock icon. | 33 // are displayed when the user clicks the favicon or security lock icon. |
34 // | 34 @interface PageInfoBubbleController : OmniboxDecorationBubbleController { |
35 // TODO(palmer): Normalize all WebsiteSettings*, SiteSettings*, PageInfo*, et c. | |
36 // to OriginInfo*. | |
37 @interface WebsiteSettingsBubbleController : OmniboxDecorationBubbleController { | |
38 @private | 35 @private |
39 content::WebContents* webContents_; | 36 content::WebContents* webContents_; |
40 | 37 |
41 base::scoped_nsobject<NSView> contentView_; | 38 base::scoped_nsobject<NSView> contentView_; |
42 | 39 |
43 // The main content view for the Permissions tab. | 40 // The main content view for the Permissions tab. |
44 NSView* securitySectionView_; | 41 NSView* securitySectionView_; |
45 | 42 |
46 // Displays the short security summary for the page | 43 // Displays the short security summary for the page |
47 // (private/not private/etc.). | 44 // (private/not private/etc.). |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 NSView* permissionsView_; | 82 NSView* permissionsView_; |
86 | 83 |
87 // Whether the permissionView_ shows anything. | 84 // Whether the permissionView_ shows anything. |
88 BOOL permissionsPresent_; | 85 BOOL permissionsPresent_; |
89 | 86 |
90 // The link button for showing site settings. | 87 // The link button for showing site settings. |
91 NSButton* siteSettingsButton_; | 88 NSButton* siteSettingsButton_; |
92 | 89 |
93 // The UI translates user actions to specific events and forwards them to the | 90 // The UI translates user actions to specific events and forwards them to the |
94 // |presenter_|. The |presenter_| handles these events and updates the UI. | 91 // |presenter_|. The |presenter_| handles these events and updates the UI. |
95 std::unique_ptr<WebsiteSettings> presenter_; | 92 std::unique_ptr<PageInfo> presenter_; |
96 | 93 |
97 // Bridge which implements the WebsiteSettingsUI interface and forwards | 94 // Bridge which implements the PageInfoUI interface and forwards |
98 // methods on to this class. | 95 // methods on to this class. |
99 std::unique_ptr<WebsiteSettingsUIBridge> bridge_; | 96 std::unique_ptr<PageInfoUIBridge> bridge_; |
100 } | 97 } |
101 | 98 |
102 // Designated initializer. The controller will release itself when the bubble | 99 // Designated initializer. The controller will release itself when the bubble |
103 // is closed. |parentWindow| cannot be nil. |webContents| may be nil for | 100 // is closed. |parentWindow| cannot be nil. |webContents| may be nil for |
104 // testing purposes. | 101 // testing purposes. |
105 - (id)initWithParentWindow:(NSWindow*)parentWindow | 102 - (id)initWithParentWindow:(NSWindow*)parentWindow |
106 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge | 103 pageInfoUIBridge:(PageInfoUIBridge*)bridge |
107 webContents:(content::WebContents*)webContents | 104 webContents:(content::WebContents*)webContents |
108 url:(const GURL&)url; | 105 url:(const GURL&)url; |
109 | 106 |
110 // Return the default width of the window. It may be wider to fit the content. | 107 // Return the default width of the window. It may be wider to fit the content. |
111 // This may be overriden by a subclass for testing purposes. | 108 // This may be overriden by a subclass for testing purposes. |
112 - (CGFloat)defaultWindowWidth; | 109 - (CGFloat)defaultWindowWidth; |
113 | 110 |
114 @end | 111 @end |
115 | 112 |
116 // Provides a bridge between the WebSettingsUI C++ interface and the Cocoa | 113 // Provides a bridge between the PageInfoUI C++ interface and the Cocoa |
117 // implementation in WebsiteSettingsBubbleController. | 114 // implementation in PageInfoBubbleController. |
118 class WebsiteSettingsUIBridge : public content::WebContentsObserver, | 115 class PageInfoUIBridge : public content::WebContentsObserver, |
119 public WebsiteSettingsUI { | 116 public PageInfoUI { |
120 public: | 117 public: |
121 explicit WebsiteSettingsUIBridge(content::WebContents* web_contents); | 118 explicit PageInfoUIBridge(content::WebContents* web_contents); |
122 ~WebsiteSettingsUIBridge() override; | 119 ~PageInfoUIBridge() override; |
123 | 120 |
124 // Creates a |WebsiteSettingsBubbleController| and displays the UI. |parent| | 121 // Creates a |PageInfoBubbleController| and displays the UI. |parent| |
125 // is the currently active window. |profile| points to the currently active | 122 // is the currently active window. |profile| points to the currently active |
126 // profile. |web_contents| points to the WebContents that wraps the currently | 123 // profile. |web_contents| points to the WebContents that wraps the currently |
127 // active tab. |virtual_url| is the virtual GURL of the currently active | 124 // active tab. |virtual_url| is the virtual GURL of the currently active |
128 // tab. |security_info| is the |security_state::SecurityInfo| of the | 125 // tab. |security_info| is the |security_state::SecurityInfo| of the |
129 // connection to the website in the currently active tab. | 126 // connection to the website in the currently active tab. |
130 static void Show(gfx::NativeWindow parent, | 127 static void Show(gfx::NativeWindow parent, |
131 Profile* profile, | 128 Profile* profile, |
132 content::WebContents* web_contents, | 129 content::WebContents* web_contents, |
133 const GURL& virtual_url, | 130 const GURL& virtual_url, |
134 const security_state::SecurityInfo& security_info); | 131 const security_state::SecurityInfo& security_info); |
135 | 132 |
136 void set_bubble_controller( | 133 void set_bubble_controller(PageInfoBubbleController* bubble_controller); |
137 WebsiteSettingsBubbleController* bubble_controller); | |
138 | 134 |
139 // WebContentsObserver implementation. | 135 // WebContentsObserver implementation. |
140 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; | 136 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
141 | 137 |
142 // WebsiteSettingsUI implementations. | 138 // PageInfoUI implementations. |
143 void SetCookieInfo(const CookieInfoList& cookie_info_list) override; | 139 void SetCookieInfo(const CookieInfoList& cookie_info_list) override; |
144 void SetPermissionInfo(const PermissionInfoList& permission_info_list, | 140 void SetPermissionInfo(const PermissionInfoList& permission_info_list, |
145 ChosenObjectInfoList chosen_object_info_list) override; | 141 ChosenObjectInfoList chosen_object_info_list) override; |
146 void SetIdentityInfo(const IdentityInfo& identity_info) override; | 142 void SetIdentityInfo(const IdentityInfo& identity_info) override; |
147 | 143 |
148 private: | 144 private: |
149 // The WebContents the bubble UI is attached to. | 145 // The WebContents the bubble UI is attached to. |
150 content::WebContents* web_contents_; | 146 content::WebContents* web_contents_; |
151 | 147 |
152 // The Cocoa controller for the bubble UI. | 148 // The Cocoa controller for the bubble UI. |
153 WebsiteSettingsBubbleController* bubble_controller_; | 149 PageInfoBubbleController* bubble_controller_; |
154 | 150 |
155 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsUIBridge); | 151 DISALLOW_COPY_AND_ASSIGN(PageInfoUIBridge); |
156 }; | 152 }; |
157 | 153 |
158 #endif // CHROME_BROWSER_UI_COCOA_WEBSITE_SETTINGS_WEBSITE_SETTINGS_BUBBLE_CONT
ROLLER_H_ | 154 #endif // CHROME_BROWSER_UI_COCOA_PAGE_INFO_PAGE_INFO_BUBBLE_CONTROLLER_H_ |
OLD | NEW |