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

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

Issue 2752623003: [Mac] Fix for the security chip (Closed)
Patch Set: . Created 3 years, 9 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/permission_bubble_controller.h " 5 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h "
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/mac/bind_objc_block.h" 9 #include "base/mac/bind_objc_block.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/permissions/permission_request.h" 13 #include "chrome/browser/permissions/permission_request.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_finder.h" 15 #include "chrome/browser/ui/browser_finder.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 17 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
18 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 18 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
19 #import "chrome/browser/ui/cocoa/chrome_style.h" 19 #import "chrome/browser/ui/cocoa/chrome_style.h"
20 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" 20 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
21 #import "chrome/browser/ui/cocoa/hover_close_button.h" 21 #import "chrome/browser/ui/cocoa/hover_close_button.h"
22 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 22 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
23 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 23 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
24 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h"
24 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 25 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
25 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" 26 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h"
26 #include "chrome/browser/ui/cocoa/website_settings/permission_selector_button.h" 27 #include "chrome/browser/ui/cocoa/website_settings/permission_selector_button.h"
27 #include "chrome/browser/ui/cocoa/website_settings/split_block_button.h" 28 #include "chrome/browser/ui/cocoa/website_settings/split_block_button.h"
28 #include "chrome/browser/ui/cocoa/website_settings/website_settings_utils_cocoa. h" 29 #include "chrome/browser/ui/cocoa/website_settings/website_settings_utils_cocoa. h"
29 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" 30 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
30 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" 31 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
31 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 32 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
32 #include "chrome/browser/ui/website_settings/permission_menu_model.h" 33 #include "chrome/browser/ui/website_settings/permission_menu_model.h"
33 #include "chrome/browser/ui/website_settings/permission_prompt.h" 34 #include "chrome/browser/ui/website_settings/permission_prompt.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 bridge_ = bridge; 226 bridge_ = bridge;
226 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 227 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
227 [center addObserver:self 228 [center addObserver:self
228 selector:@selector(parentWindowDidMove:) 229 selector:@selector(parentWindowDidMove:)
229 name:NSWindowDidMoveNotification 230 name:NSWindowDidMoveNotification
230 object:[self getExpectedParentWindow]]; 231 object:[self getExpectedParentWindow]];
231 } 232 }
232 return self; 233 return self;
233 } 234 }
234 235
235 - (LocationBarDecoration*)decorationForBubble {
236 if (![self hasVisibleLocationBar])
237 return nullptr;
238
239 LocationBarViewMac* location_bar =
240 [[self.parentWindow windowController] locationBarBridge];
241 return location_bar->GetPageInfoDecoration();
242 }
243
244 + (NSPoint)getAnchorPointForBrowser:(Browser*)browser { 236 + (NSPoint)getAnchorPointForBrowser:(Browser*)browser {
245 NSPoint anchor; 237 NSPoint anchor;
246 NSWindow* parentWindow = browser->window()->GetNativeWindow(); 238 NSWindow* parentWindow = browser->window()->GetNativeWindow();
247 if ([PermissionBubbleController hasVisibleLocationBarForBrowser:browser]) { 239 if ([PermissionBubbleController hasVisibleLocationBarForBrowser:browser]) {
248 LocationBarViewMac* location_bar = 240 LocationBarViewMac* location_bar =
249 [[parentWindow windowController] locationBarBridge]; 241 [[parentWindow windowController] locationBarBridge];
250 anchor = location_bar->GetPageInfoBubblePoint(); 242 anchor = location_bar->GetPageInfoBubblePoint();
251 } else { 243 } else {
252 // Position the bubble on the left of the screen if there is no page info 244 // Position the bubble on the left of the screen if there is no page info
253 // button to point at. 245 // button to point at.
(...skipping 29 matching lines...) Expand all
283 275
284 - (void)windowWillClose:(NSNotification*)notification { 276 - (void)windowWillClose:(NSNotification*)notification {
285 [[NSNotificationCenter defaultCenter] 277 [[NSNotificationCenter defaultCenter]
286 removeObserver:self 278 removeObserver:self
287 name:NSWindowDidMoveNotification 279 name:NSWindowDidMoveNotification
288 object:nil]; 280 object:nil];
289 bridge_->OnBubbleClosing(); 281 bridge_->OnBubbleClosing();
290 [super windowWillClose:notification]; 282 [super windowWillClose:notification];
291 } 283 }
292 284
285 - (void)showWindow:(id)sender {
Robert Sesek 2017/03/15 17:35:09 What about the ![self hasVisibileLocationBar] chec
spqchan 2017/03/15 21:18:47 Whoops, thanks for catching that!
286 decoration_ = [[self.parentWindow windowController] locationBarBridge]
287 ->GetPageInfoDecoration();
288 decoration_->SetActive(true);
289 [super showWindow:sender];
290 }
291
292 - (void)close {
Robert Sesek 2017/03/15 17:35:09 What's the destruction order of the bubble w.r.t.
spqchan 2017/03/15 21:18:47 The bubble will close before the decoration and th
293 if (decoration_) {
294 decoration_->SetActive(false);
295 decoration_ = nullptr;
296 }
297
298 [super close];
299 }
300
293 - (void)parentWindowWillToggleFullScreen:(NSNotification*)notification { 301 - (void)parentWindowWillToggleFullScreen:(NSNotification*)notification {
294 // Override the base class implementation, which would have closed the bubble. 302 // Override the base class implementation, which would have closed the bubble.
295 } 303 }
296 304
297 - (void)parentWindowDidResize:(NSNotification*)notification { 305 - (void)parentWindowDidResize:(NSNotification*)notification {
298 // Override the base class implementation, which sets the anchor point. But 306 // Override the base class implementation, which sets the anchor point. But
299 // it's not necessary since BrowserWindowController will notify the 307 // it's not necessary since BrowserWindowController will notify the
300 // PermissionRequestManager to update the anchor position on a resize. 308 // PermissionRequestManager to update the anchor position on a resize.
301 } 309 }
302 310
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 } 654 }
647 655
648 - (IBAction)cancel:(id)sender { 656 - (IBAction)cancel:(id)sender {
649 // This is triggered by ESC when the bubble has focus. 657 // This is triggered by ESC when the bubble has focus.
650 if (delegate_) 658 if (delegate_)
651 delegate_->Closing(); 659 delegate_->Closing();
652 [super cancel:sender]; 660 [super cancel:sender];
653 } 661 }
654 662
655 @end // implementation PermissionBubbleController 663 @end // implementation PermissionBubbleController
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698