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 #import "chrome/browser/ui/cocoa/website_settings/website_settings_bubble_contro
ller.h" | 5 #import "chrome/browser/ui/cocoa/website_settings/website_settings_bubble_contro
ller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #import <AppKit/AppKit.h> | 9 #import <AppKit/AppKit.h> |
10 | 10 |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 } | 1164 } |
1165 | 1165 |
1166 - (void)setSelectedTab:(WebsiteSettingsUI::TabId)tabId { | 1166 - (void)setSelectedTab:(WebsiteSettingsUI::TabId)tabId { |
1167 NSInteger index = static_cast<NSInteger>(tabId); | 1167 NSInteger index = static_cast<NSInteger>(tabId); |
1168 [segmentedControl_ setSelectedSegment:index]; | 1168 [segmentedControl_ setSelectedSegment:index]; |
1169 [tabView_ selectTabViewItemAtIndex:index]; | 1169 [tabView_ selectTabViewItemAtIndex:index]; |
1170 } | 1170 } |
1171 | 1171 |
1172 @end | 1172 @end |
1173 | 1173 |
1174 WebsiteSettingsUIBridge::WebsiteSettingsUIBridge() | 1174 WebsiteSettingsUIBridge::WebsiteSettingsUIBridge( |
1175 : bubble_controller_(nil) { | 1175 content::WebContents* web_contents) |
1176 } | 1176 : content::WebContentsObserver(web_contents), |
| 1177 web_contents_(web_contents), |
| 1178 bubble_controller_(nil) {} |
1177 | 1179 |
1178 WebsiteSettingsUIBridge::~WebsiteSettingsUIBridge() { | 1180 WebsiteSettingsUIBridge::~WebsiteSettingsUIBridge() { |
1179 } | 1181 } |
1180 | 1182 |
1181 void WebsiteSettingsUIBridge::set_bubble_controller( | 1183 void WebsiteSettingsUIBridge::set_bubble_controller( |
1182 WebsiteSettingsBubbleController* controller) { | 1184 WebsiteSettingsBubbleController* controller) { |
1183 bubble_controller_ = controller; | 1185 bubble_controller_ = controller; |
1184 } | 1186 } |
1185 | 1187 |
1186 void WebsiteSettingsUIBridge::Show(gfx::NativeWindow parent, | 1188 void WebsiteSettingsUIBridge::Show(gfx::NativeWindow parent, |
1187 Profile* profile, | 1189 Profile* profile, |
1188 content::WebContents* web_contents, | 1190 content::WebContents* web_contents, |
1189 const GURL& url, | 1191 const GURL& url, |
1190 const content::SSLStatus& ssl) { | 1192 const content::SSLStatus& ssl) { |
1191 if (chrome::ToolkitViewsDialogsEnabled()) { | 1193 if (chrome::ToolkitViewsDialogsEnabled()) { |
1192 chrome::ShowWebsiteSettingsBubbleViewsAtPoint( | 1194 chrome::ShowWebsiteSettingsBubbleViewsAtPoint( |
1193 gfx::ScreenPointFromNSPoint(AnchorPointForWindow(parent)), profile, | 1195 gfx::ScreenPointFromNSPoint(AnchorPointForWindow(parent)), profile, |
1194 web_contents, url, ssl); | 1196 web_contents, url, ssl); |
1195 return; | 1197 return; |
1196 } | 1198 } |
1197 | 1199 |
1198 bool is_internal_page = InternalChromePage(url); | 1200 bool is_internal_page = InternalChromePage(url); |
1199 | 1201 |
1200 // Create the bridge. This will be owned by the bubble controller. | 1202 // Create the bridge. This will be owned by the bubble controller. |
1201 WebsiteSettingsUIBridge* bridge = new WebsiteSettingsUIBridge(); | 1203 WebsiteSettingsUIBridge* bridge = new WebsiteSettingsUIBridge(web_contents); |
1202 | 1204 |
1203 // Create the bubble controller. It will dealloc itself when it closes. | 1205 // Create the bubble controller. It will dealloc itself when it closes. |
1204 WebsiteSettingsBubbleController* bubble_controller = | 1206 WebsiteSettingsBubbleController* bubble_controller = |
1205 [[WebsiteSettingsBubbleController alloc] | 1207 [[WebsiteSettingsBubbleController alloc] |
1206 initWithParentWindow:parent | 1208 initWithParentWindow:parent |
1207 websiteSettingsUIBridge:bridge | 1209 websiteSettingsUIBridge:bridge |
1208 webContents:web_contents | 1210 webContents:web_contents |
1209 isInternalPage:is_internal_page]; | 1211 isInternalPage:is_internal_page]; |
1210 | 1212 |
1211 if (!is_internal_page) { | 1213 if (!is_internal_page) { |
1212 // Initialize the presenter, which holds the model and controls the UI. | 1214 // Initialize the presenter, which holds the model and controls the UI. |
1213 // This is also owned by the bubble controller. | 1215 // This is also owned by the bubble controller. |
1214 WebsiteSettings* presenter = new WebsiteSettings( | 1216 WebsiteSettings* presenter = new WebsiteSettings( |
1215 bridge, | 1217 bridge, profile, |
1216 profile, | 1218 TabSpecificContentSettings::FromWebContents(web_contents), web_contents, |
1217 TabSpecificContentSettings::FromWebContents(web_contents), | 1219 url, ssl, content::CertStore::GetInstance()); |
1218 InfoBarService::FromWebContents(web_contents), | |
1219 url, | |
1220 ssl, | |
1221 content::CertStore::GetInstance()); | |
1222 [bubble_controller setPresenter:presenter]; | 1220 [bubble_controller setPresenter:presenter]; |
1223 } | 1221 } |
1224 | 1222 |
1225 [bubble_controller showWindow:nil]; | 1223 [bubble_controller showWindow:nil]; |
1226 } | 1224 } |
1227 | 1225 |
1228 void WebsiteSettingsUIBridge::SetIdentityInfo( | 1226 void WebsiteSettingsUIBridge::SetIdentityInfo( |
1229 const WebsiteSettingsUI::IdentityInfo& identity_info) { | 1227 const WebsiteSettingsUI::IdentityInfo& identity_info) { |
1230 [bubble_controller_ setIdentityInfo:identity_info]; | 1228 [bubble_controller_ setIdentityInfo:identity_info]; |
1231 } | 1229 } |
1232 | 1230 |
| 1231 void WebsiteSettingsUIBridge::RenderFrameDeleted( |
| 1232 content::RenderFrameHost* render_frame_host) { |
| 1233 if (render_frame_host == web_contents_->GetMainFrame()) { |
| 1234 [bubble_controller_ close]; |
| 1235 } |
| 1236 } |
| 1237 |
1233 void WebsiteSettingsUIBridge::SetCookieInfo( | 1238 void WebsiteSettingsUIBridge::SetCookieInfo( |
1234 const CookieInfoList& cookie_info_list) { | 1239 const CookieInfoList& cookie_info_list) { |
1235 [bubble_controller_ setCookieInfo:cookie_info_list]; | 1240 [bubble_controller_ setCookieInfo:cookie_info_list]; |
1236 } | 1241 } |
1237 | 1242 |
1238 void WebsiteSettingsUIBridge::SetPermissionInfo( | 1243 void WebsiteSettingsUIBridge::SetPermissionInfo( |
1239 const PermissionInfoList& permission_info_list) { | 1244 const PermissionInfoList& permission_info_list) { |
1240 [bubble_controller_ setPermissionInfo:permission_info_list]; | 1245 [bubble_controller_ setPermissionInfo:permission_info_list]; |
1241 } | 1246 } |
1242 | 1247 |
1243 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { | 1248 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { |
1244 [bubble_controller_ setSelectedTab:tab_id]; | 1249 [bubble_controller_ setSelectedTab:tab_id]; |
1245 } | 1250 } |
OLD | NEW |