| 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 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 bool IsInternalURL(const GURL& url) { | 186 bool IsInternalURL(const GURL& url) { |
| 187 return url.SchemeIs(content::kChromeUIScheme) || | 187 return url.SchemeIs(content::kChromeUIScheme) || |
| 188 url.SchemeIs(extensions::kExtensionScheme) || | 188 url.SchemeIs(extensions::kExtensionScheme) || |
| 189 url.SchemeIs(content::kViewSourceScheme); | 189 url.SchemeIs(content::kViewSourceScheme); |
| 190 } | 190 } |
| 191 | 191 |
| 192 - (id)initWithParentWindow:(NSWindow*)parentWindow | 192 - (id)initWithParentWindow:(NSWindow*)parentWindow |
| 193 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge | 193 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge |
| 194 webContents:(content::WebContents*)webContents | 194 webContents:(content::WebContents*)webContents |
| 195 forProfile:(Profile*)profile |
| 195 url:(const GURL&)url | 196 url:(const GURL&)url |
| 196 isDevToolsDisabled:(BOOL)isDevToolsDisabled { | 197 isDevToolsDisabled:(BOOL)isDevToolsDisabled { |
| 197 DCHECK(parentWindow); | 198 DCHECK(parentWindow); |
| 198 | 199 |
| 199 webContents_ = webContents; | 200 webContents_ = webContents; |
| 200 permissionsPresent_ = NO; | 201 permissionsPresent_ = NO; |
| 201 isDevToolsDisabled_ = isDevToolsDisabled; | 202 isDevToolsDisabled_ = isDevToolsDisabled; |
| 202 url_ = url; | 203 url_ = url; |
| 204 profile_ = profile; |
| 203 | 205 |
| 204 // Use an arbitrary height; it will be changed in performLayout. | 206 // Use an arbitrary height; it will be changed in performLayout. |
| 205 NSRect contentRect = NSMakeRect(0, 0, [self defaultWindowWidth], 1); | 207 NSRect contentRect = NSMakeRect(0, 0, [self defaultWindowWidth], 1); |
| 206 // Create an empty window into which content is placed. | 208 // Create an empty window into which content is placed. |
| 207 base::scoped_nsobject<InfoBubbleWindow> window( | 209 base::scoped_nsobject<InfoBubbleWindow> window( |
| 208 [[InfoBubbleWindow alloc] initWithContentRect:contentRect | 210 [[InfoBubbleWindow alloc] initWithContentRect:contentRect |
| 209 styleMask:NSBorderlessWindowMask | 211 styleMask:NSBorderlessWindowMask |
| 210 backing:NSBackingStoreBuffered | 212 backing:NSBackingStoreBuffered |
| 211 defer:NO]); | 213 defer:NO]); |
| 212 | 214 |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 | 732 |
| 731 GURL url = webContents_ ? webContents_->GetURL() : GURL(); | 733 GURL url = webContents_ ? webContents_->GetURL() : GURL(); |
| 732 __block WebsiteSettingsBubbleController* weakSelf = self; | 734 __block WebsiteSettingsBubbleController* weakSelf = self; |
| 733 PermissionMenuModel::ChangeCallback callback = | 735 PermissionMenuModel::ChangeCallback callback = |
| 734 base::BindBlock(^(const WebsiteSettingsUI::PermissionInfo& permission) { | 736 base::BindBlock(^(const WebsiteSettingsUI::PermissionInfo& permission) { |
| 735 [weakSelf onPermissionChanged:permission.type to:permission.setting]; | 737 [weakSelf onPermissionChanged:permission.type to:permission.setting]; |
| 736 }); | 738 }); |
| 737 base::scoped_nsobject<PermissionSelectorButton> button( | 739 base::scoped_nsobject<PermissionSelectorButton> button( |
| 738 [[PermissionSelectorButton alloc] initWithPermissionInfo:permissionInfo | 740 [[PermissionSelectorButton alloc] initWithPermissionInfo:permissionInfo |
| 739 forURL:url | 741 forURL:url |
| 740 withCallback:callback]); | 742 withCallback:callback |
| 743 forProfile:profile_]); |
| 741 | 744 |
| 742 // Determine the largest possible size for this button. | 745 // Determine the largest possible size for this button. |
| 743 CGFloat maxTitleWidth = [button | 746 CGFloat maxTitleWidth = |
| 744 maxTitleWidthForContentSettingsType:permissionInfo.type | 747 [button maxTitleWidthForContentSettingsType:permissionInfo.type |
| 745 withDefaultSetting:permissionInfo.default_setting]; | 748 withDefaultSetting:permissionInfo.default_setting |
| 749 forProfile:profile_]; |
| 746 | 750 |
| 747 // Ensure the containing view is large enough to contain the button with its | 751 // Ensure the containing view is large enough to contain the button with its |
| 748 // widest possible title. | 752 // widest possible title. |
| 749 NSRect containerFrame = [view frame]; | 753 NSRect containerFrame = [view frame]; |
| 750 containerFrame.size.width = | 754 containerFrame.size.width = |
| 751 std::max(NSWidth(containerFrame), | 755 std::max(NSWidth(containerFrame), |
| 752 point.x + maxTitleWidth + kSectionHorizontalPadding); | 756 point.x + maxTitleWidth + kSectionHorizontalPadding); |
| 753 [view setFrame:containerFrame]; | 757 [view setFrame:containerFrame]; |
| 754 [view addSubview:button.get()]; | 758 [view addSubview:button.get()]; |
| 755 return button.get(); | 759 return button.get(); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 bool is_devtools_disabled = | 1152 bool is_devtools_disabled = |
| 1149 profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); | 1153 profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); |
| 1150 | 1154 |
| 1151 // Create the bubble controller. It will dealloc itself when it closes, | 1155 // Create the bubble controller. It will dealloc itself when it closes, |
| 1152 // resetting |g_is_popup_showing|. | 1156 // resetting |g_is_popup_showing|. |
| 1153 WebsiteSettingsBubbleController* bubble_controller = | 1157 WebsiteSettingsBubbleController* bubble_controller = |
| 1154 [[WebsiteSettingsBubbleController alloc] | 1158 [[WebsiteSettingsBubbleController alloc] |
| 1155 initWithParentWindow:parent | 1159 initWithParentWindow:parent |
| 1156 websiteSettingsUIBridge:bridge | 1160 websiteSettingsUIBridge:bridge |
| 1157 webContents:web_contents | 1161 webContents:web_contents |
| 1162 forProfile:profile |
| 1158 url:virtual_url | 1163 url:virtual_url |
| 1159 isDevToolsDisabled:is_devtools_disabled]; | 1164 isDevToolsDisabled:is_devtools_disabled]; |
| 1160 | 1165 |
| 1161 if (!IsInternalURL(virtual_url)) { | 1166 if (!IsInternalURL(virtual_url)) { |
| 1162 // Initialize the presenter, which holds the model and controls the UI. | 1167 // Initialize the presenter, which holds the model and controls the UI. |
| 1163 // This is also owned by the bubble controller. | 1168 // This is also owned by the bubble controller. |
| 1164 WebsiteSettings* presenter = new WebsiteSettings( | 1169 WebsiteSettings* presenter = new WebsiteSettings( |
| 1165 bridge, profile, | 1170 bridge, profile, |
| 1166 TabSpecificContentSettings::FromWebContents(web_contents), web_contents, | 1171 TabSpecificContentSettings::FromWebContents(web_contents), web_contents, |
| 1167 virtual_url, security_info); | 1172 virtual_url, security_info); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1191 void WebsiteSettingsUIBridge::SetPermissionInfo( | 1196 void WebsiteSettingsUIBridge::SetPermissionInfo( |
| 1192 const PermissionInfoList& permission_info_list, | 1197 const PermissionInfoList& permission_info_list, |
| 1193 const ChosenObjectInfoList& chosen_object_info_list) { | 1198 const ChosenObjectInfoList& chosen_object_info_list) { |
| 1194 [bubble_controller_ setPermissionInfo:permission_info_list | 1199 [bubble_controller_ setPermissionInfo:permission_info_list |
| 1195 andChosenObjects:chosen_object_info_list]; | 1200 andChosenObjects:chosen_object_info_list]; |
| 1196 } | 1201 } |
| 1197 | 1202 |
| 1198 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { | 1203 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { |
| 1199 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) | 1204 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) |
| 1200 } | 1205 } |
| OLD | NEW |