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

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: 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
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 52 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
53 #include "ui/resources/grit/ui_resources.h" 53 #include "ui/resources/grit/ui_resources.h"
54 54
55 using ChosenObjectInfoPtr = 55 using ChosenObjectInfoPtr =
56 std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo>; 56 std::unique_ptr<WebsiteSettingsUI::ChosenObjectInfo>;
57 using ChosenObjectDeleteCallback = 57 using ChosenObjectDeleteCallback =
58 base::Callback<void(const WebsiteSettingsUI::ChosenObjectInfo&)>; 58 base::Callback<void(const WebsiteSettingsUI::ChosenObjectInfo&)>;
59 59
60 namespace { 60 namespace {
61 61
62 // NOTE: This assumes that there will never be more than one website settings
63 // popup shown, and that the one that is shown is associated with the current
64 // window. This matches the behaviour in views: see WebsiteSettingsPopupView.
65 bool is_popup_showing = false;
tapted 2016/06/06 05:06:37 g_is_popup_showing. Also move down to the end of t
dominickn 2016/06/08 03:03:08 Done.
66
62 // The default width of the window, in view coordinates. It may be larger to 67 // The default width of the window, in view coordinates. It may be larger to
63 // fit the content. 68 // fit the content.
64 const CGFloat kDefaultWindowWidth = 310; 69 const CGFloat kDefaultWindowWidth = 310;
65 70
66 // Padding between the window frame and content. 71 // Padding between the window frame and content.
67 const CGFloat kFramePadding = 20; 72 const CGFloat kFramePadding = 20;
68 73
69 // Padding between the window frame and content. 74 // Padding between the window frame and content.
70 const CGFloat kVerticalSectionMargin = 16; 75 const CGFloat kVerticalSectionMargin = 16;
71 76
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 bridge_.reset(bridge); 228 bridge_.reset(bridge);
224 bridge_->set_bubble_controller(self); 229 bridge_->set_bubble_controller(self);
225 } 230 }
226 return self; 231 return self;
227 } 232 }
228 233
229 - (void)windowWillClose:(NSNotification*)notification { 234 - (void)windowWillClose:(NSNotification*)notification {
230 if (presenter_.get()) 235 if (presenter_.get())
231 presenter_->OnUIClosing(); 236 presenter_->OnUIClosing();
232 presenter_.reset(); 237 presenter_.reset();
238 is_popup_showing = false;
233 [super windowWillClose:notification]; 239 [super windowWillClose:notification];
234 } 240 }
235 241
236 - (void)setPresenter:(WebsiteSettings*)presenter { 242 - (void)setPresenter:(WebsiteSettings*)presenter {
237 presenter_.reset(presenter); 243 presenter_.reset(presenter);
238 } 244 }
239 245
240 // Create the subviews for the bubble for internal Chrome pages. 246 // Create the subviews for the bubble for internal Chrome pages.
241 - (void)initializeContentsForInternalPage:(BOOL)isExtensionPage { 247 - (void)initializeContentsForInternalPage:(BOOL)isExtensionPage {
242 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 248 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 1098
1093 @end 1099 @end
1094 1100
1095 WebsiteSettingsUIBridge::WebsiteSettingsUIBridge( 1101 WebsiteSettingsUIBridge::WebsiteSettingsUIBridge(
1096 content::WebContents* web_contents) 1102 content::WebContents* web_contents)
1097 : content::WebContentsObserver(web_contents), 1103 : content::WebContentsObserver(web_contents),
1098 web_contents_(web_contents), 1104 web_contents_(web_contents),
1099 bubble_controller_(nil) {} 1105 bubble_controller_(nil) {}
1100 1106
1101 WebsiteSettingsUIBridge::~WebsiteSettingsUIBridge() { 1107 WebsiteSettingsUIBridge::~WebsiteSettingsUIBridge() {
1108 is_popup_showing = false;
tapted 2016/06/06 05:06:37 why is this needed twice? Can we just tie the life
dominickn 2016/06/08 03:03:08 Done.
1102 } 1109 }
1103 1110
1104 void WebsiteSettingsUIBridge::set_bubble_controller( 1111 void WebsiteSettingsUIBridge::set_bubble_controller(
1105 WebsiteSettingsBubbleController* controller) { 1112 WebsiteSettingsBubbleController* controller) {
1106 bubble_controller_ = controller; 1113 bubble_controller_ = controller;
1107 } 1114 }
1108 1115
1109 void WebsiteSettingsUIBridge::Show( 1116 void WebsiteSettingsUIBridge::Show(
1110 gfx::NativeWindow parent, 1117 gfx::NativeWindow parent,
1111 Profile* profile, 1118 Profile* profile,
1112 content::WebContents* web_contents, 1119 content::WebContents* web_contents,
1113 const GURL& virtual_url, 1120 const GURL& virtual_url,
1114 const security_state::SecurityStateModel::SecurityInfo& security_info) { 1121 const security_state::SecurityStateModel::SecurityInfo& security_info) {
1115 if (chrome::ToolkitViewsWebUIDialogsEnabled()) { 1122 if (chrome::ToolkitViewsWebUIDialogsEnabled()) {
1116 chrome::ShowWebsiteSettingsBubbleViewsAtPoint( 1123 chrome::ShowWebsiteSettingsBubbleViewsAtPoint(
1117 gfx::ScreenPointFromNSPoint(AnchorPointForWindow(parent)), profile, 1124 gfx::ScreenPointFromNSPoint(AnchorPointForWindow(parent)), profile,
1118 web_contents, virtual_url, security_info); 1125 web_contents, virtual_url, security_info);
1119 return; 1126 return;
1120 } 1127 }
1121 1128
1129 // If the WebsiteSettings are already being shown, don't show them again.
1130 // This effectively means that clicking on the location icon when
1131 // WebsiteSettings is already visible dismisses the open popup, destroying
1132 // this object and setting |is_popup_showing| to false.
1133 if (is_popup_showing)
1134 return;
1135
1136 is_popup_showing = true;
1122 BubbleType bubble_type = WEB_PAGE; 1137 BubbleType bubble_type = WEB_PAGE;
1123 if (virtual_url.SchemeIs(content::kChromeUIScheme)) 1138 if (virtual_url.SchemeIs(content::kChromeUIScheme))
1124 bubble_type = INTERNAL_PAGE; 1139 bubble_type = INTERNAL_PAGE;
1125 else if (virtual_url.SchemeIs(extensions::kExtensionScheme)) 1140 else if (virtual_url.SchemeIs(extensions::kExtensionScheme))
1126 bubble_type = EXTENSION_PAGE; 1141 bubble_type = EXTENSION_PAGE;
1127 1142
1128 // Create the bridge. This will be owned by the bubble controller. 1143 // Create the bridge. This will be owned by the bubble controller.
1129 WebsiteSettingsUIBridge* bridge = new WebsiteSettingsUIBridge(web_contents); 1144 WebsiteSettingsUIBridge* bridge = new WebsiteSettingsUIBridge(web_contents);
1130 1145
1131 bool is_devtools_disabled = 1146 bool is_devtools_disabled =
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 void WebsiteSettingsUIBridge::SetPermissionInfo( 1188 void WebsiteSettingsUIBridge::SetPermissionInfo(
1174 const PermissionInfoList& permission_info_list, 1189 const PermissionInfoList& permission_info_list,
1175 const ChosenObjectInfoList& chosen_object_info_list) { 1190 const ChosenObjectInfoList& chosen_object_info_list) {
1176 [bubble_controller_ setPermissionInfo:permission_info_list 1191 [bubble_controller_ setPermissionInfo:permission_info_list
1177 andChosenObjects:chosen_object_info_list]; 1192 andChosenObjects:chosen_object_info_list];
1178 } 1193 }
1179 1194
1180 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { 1195 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) {
1181 // TODO(lgarron): Remove this from the interface. (crbug.com/571533) 1196 // TODO(lgarron): Remove this from the interface. (crbug.com/571533)
1182 } 1197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698