Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm

Issue 2041723002: [Mac] Dismiss an open page info dialog when the location icon is clicked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nit Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/browser_dialogs_views_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Extra spacing after a headline on the Permissions tab. 103 // Extra spacing after a headline on the Permissions tab.
104 const CGFloat kPermissionsHeadlineSpacing = 2; 104 const CGFloat kPermissionsHeadlineSpacing = 2;
105 105
106 // The amount of horizontal space between a permission label and the popup. 106 // The amount of horizontal space between a permission label and the popup.
107 const CGFloat kPermissionPopUpXSpacing = 3; 107 const CGFloat kPermissionPopUpXSpacing = 3;
108 108
109 // The amount of padding to *remove* when placing 109 // The amount of padding to *remove* when placing
110 // |IDS_WEBSITE_SETTINGS_{FIRST,THIRD}_PARTY_SITE_DATA| next to each other. 110 // |IDS_WEBSITE_SETTINGS_{FIRST,THIRD}_PARTY_SITE_DATA| next to each other.
111 const CGFloat kTextLabelXPadding = 5; 111 const CGFloat kTextLabelXPadding = 5;
112 112
113 // NOTE: This assumes that there will never be more than one website settings
114 // popup shown, and that the one that is shown is associated with the current
115 // window. This matches the behaviour in views: see WebsiteSettingsPopupView.
116 bool g_is_popup_showing = false;
117
113 // Takes in the parent window, which should be a BrowserWindow, and gets the 118 // Takes in the parent window, which should be a BrowserWindow, and gets the
114 // proper anchor point for the bubble. The returned point is in screen 119 // proper anchor point for the bubble. The returned point is in screen
115 // coordinates. 120 // coordinates.
116 NSPoint AnchorPointForWindow(NSWindow* parent) { 121 NSPoint AnchorPointForWindow(NSWindow* parent) {
117 BrowserWindowController* controller = [parent windowController]; 122 BrowserWindowController* controller = [parent windowController];
118 NSPoint origin = NSZeroPoint; 123 NSPoint origin = NSZeroPoint;
119 if ([controller isKindOfClass:[BrowserWindowController class]]) { 124 if ([controller isKindOfClass:[BrowserWindowController class]]) {
120 LocationBarViewMac* location_bar = [controller locationBarBridge]; 125 LocationBarViewMac* location_bar = [controller locationBarBridge];
121 if (location_bar) { 126 if (location_bar) {
122 NSPoint bubble_point = location_bar->GetPageInfoBubblePoint(); 127 NSPoint bubble_point = location_bar->GetPageInfoBubblePoint();
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 NSMakeSize(NSWidth([permissionsView_ frame]), controlOrigin.y)]; 1094 NSMakeSize(NSWidth([permissionsView_ frame]), controlOrigin.y)];
1090 [self performLayout]; 1095 [self performLayout];
1091 } 1096 }
1092 1097
1093 @end 1098 @end
1094 1099
1095 WebsiteSettingsUIBridge::WebsiteSettingsUIBridge( 1100 WebsiteSettingsUIBridge::WebsiteSettingsUIBridge(
1096 content::WebContents* web_contents) 1101 content::WebContents* web_contents)
1097 : content::WebContentsObserver(web_contents), 1102 : content::WebContentsObserver(web_contents),
1098 web_contents_(web_contents), 1103 web_contents_(web_contents),
1099 bubble_controller_(nil) {} 1104 bubble_controller_(nil) {
1105 DCHECK(!g_is_popup_showing);
1106 g_is_popup_showing = true;
1107 }
1100 1108
1101 WebsiteSettingsUIBridge::~WebsiteSettingsUIBridge() { 1109 WebsiteSettingsUIBridge::~WebsiteSettingsUIBridge() {
1110 DCHECK(g_is_popup_showing);
1111 g_is_popup_showing = false;
1102 } 1112 }
1103 1113
1104 void WebsiteSettingsUIBridge::set_bubble_controller( 1114 void WebsiteSettingsUIBridge::set_bubble_controller(
1105 WebsiteSettingsBubbleController* controller) { 1115 WebsiteSettingsBubbleController* controller) {
1106 bubble_controller_ = controller; 1116 bubble_controller_ = controller;
1107 } 1117 }
1108 1118
1109 void WebsiteSettingsUIBridge::Show( 1119 void WebsiteSettingsUIBridge::Show(
1110 gfx::NativeWindow parent, 1120 gfx::NativeWindow parent,
1111 Profile* profile, 1121 Profile* profile,
1112 content::WebContents* web_contents, 1122 content::WebContents* web_contents,
1113 const GURL& virtual_url, 1123 const GURL& virtual_url,
1114 const security_state::SecurityStateModel::SecurityInfo& security_info) { 1124 const security_state::SecurityStateModel::SecurityInfo& security_info) {
1115 if (chrome::ToolkitViewsWebUIDialogsEnabled()) { 1125 if (chrome::ToolkitViewsWebUIDialogsEnabled()) {
1116 chrome::ShowWebsiteSettingsBubbleViewsAtPoint( 1126 chrome::ShowWebsiteSettingsBubbleViewsAtPoint(
1117 gfx::ScreenPointFromNSPoint(AnchorPointForWindow(parent)), profile, 1127 gfx::ScreenPointFromNSPoint(AnchorPointForWindow(parent)), profile,
1118 web_contents, virtual_url, security_info); 1128 web_contents, virtual_url, security_info);
1119 return; 1129 return;
1120 } 1130 }
1121 1131
1132 // Don't show the popup if it's already being shown. Since this method is
1133 // called each time the location icon is clicked, each click toggles the popup
1134 // in and out.
1135 if (g_is_popup_showing)
1136 return;
1137
1122 BubbleType bubble_type = WEB_PAGE; 1138 BubbleType bubble_type = WEB_PAGE;
1123 if (virtual_url.SchemeIs(content::kChromeUIScheme)) 1139 if (virtual_url.SchemeIs(content::kChromeUIScheme))
1124 bubble_type = INTERNAL_PAGE; 1140 bubble_type = INTERNAL_PAGE;
1125 else if (virtual_url.SchemeIs(extensions::kExtensionScheme)) 1141 else if (virtual_url.SchemeIs(extensions::kExtensionScheme))
1126 bubble_type = EXTENSION_PAGE; 1142 bubble_type = EXTENSION_PAGE;
1127 1143
1128 // Create the bridge. This will be owned by the bubble controller. 1144 // Create the bridge. This will be owned by the bubble controller.
1129 WebsiteSettingsUIBridge* bridge = new WebsiteSettingsUIBridge(web_contents); 1145 WebsiteSettingsUIBridge* bridge = new WebsiteSettingsUIBridge(web_contents);
1130 1146
1131 bool is_devtools_disabled = 1147 bool is_devtools_disabled =
1132 profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); 1148 profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled);
1133 1149
1134 // Create the bubble controller. It will dealloc itself when it closes. 1150 // Create the bubble controller. It will dealloc itself when it closes,
1151 // resetting |g_is_popup_showing|.
1135 WebsiteSettingsBubbleController* bubble_controller = 1152 WebsiteSettingsBubbleController* bubble_controller =
1136 [[WebsiteSettingsBubbleController alloc] 1153 [[WebsiteSettingsBubbleController alloc]
1137 initWithParentWindow:parent 1154 initWithParentWindow:parent
1138 websiteSettingsUIBridge:bridge 1155 websiteSettingsUIBridge:bridge
1139 webContents:web_contents 1156 webContents:web_contents
1140 bubbleType:bubble_type 1157 bubbleType:bubble_type
1141 isDevToolsDisabled:is_devtools_disabled]; 1158 isDevToolsDisabled:is_devtools_disabled];
1142 1159
1143 if (bubble_type == WEB_PAGE) { 1160 if (bubble_type == WEB_PAGE) {
1144 // Initialize the presenter, which holds the model and controls the UI. 1161 // Initialize the presenter, which holds the model and controls the UI.
(...skipping 28 matching lines...) Expand all
1173 void WebsiteSettingsUIBridge::SetPermissionInfo( 1190 void WebsiteSettingsUIBridge::SetPermissionInfo(
1174 const PermissionInfoList& permission_info_list, 1191 const PermissionInfoList& permission_info_list,
1175 const ChosenObjectInfoList& chosen_object_info_list) { 1192 const ChosenObjectInfoList& chosen_object_info_list) {
1176 [bubble_controller_ setPermissionInfo:permission_info_list 1193 [bubble_controller_ setPermissionInfo:permission_info_list
1177 andChosenObjects:chosen_object_info_list]; 1194 andChosenObjects:chosen_object_info_list];
1178 } 1195 }
1179 1196
1180 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { 1197 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) {
1181 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) 1198 // TODO(lgarron): Remove this from the interface. (crbug.com/571533)
1182 } 1199 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/browser_dialogs_views_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698