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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 2081103002: Rename PermissionBubbleManager to PermissionRequestManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser_window_controller_private.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #import "base/auto_reset.h" 9 #import "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/mac/bind_objc_block.h" 11 #include "base/mac/bind_objc_block.h"
12 #include "base/mac/foundation_util.h" 12 #include "base/mac/foundation_util.h"
13 #include "base/mac/mac_util.h" 13 #include "base/mac/mac_util.h"
14 #import "base/mac/scoped_nsobject.h" 14 #import "base/mac/scoped_nsobject.h"
15 #import "base/mac/sdk_forward_declarations.h" 15 #import "base/mac/sdk_forward_declarations.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/permissions/permission_request_manager.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 20 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
20 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 21 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
21 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_window_state.h" 23 #include "chrome/browser/ui/browser_window_state.h"
23 #import "chrome/browser/ui/cocoa/browser_window_fullscreen_transition.h" 24 #import "chrome/browser/ui/cocoa/browser_window_fullscreen_transition.h"
24 #import "chrome/browser/ui/cocoa/browser_window_layout.h" 25 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
25 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h" 26 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h"
26 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h" 27 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h"
27 #import "chrome/browser/ui/cocoa/custom_frame_view.h" 28 #import "chrome/browser/ui/cocoa/custom_frame_view.h"
(...skipping 10 matching lines...) Expand all
38 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" 39 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h"
39 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" 40 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h"
40 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" 41 #import "chrome/browser/ui/cocoa/status_bubble_mac.h"
41 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" 42 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h"
42 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 43 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
43 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 44 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
44 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 45 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
45 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" 46 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h"
46 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 47 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
47 #include "chrome/browser/ui/tabs/tab_strip_model.h" 48 #include "chrome/browser/ui/tabs/tab_strip_model.h"
48 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
49 #include "chrome/common/chrome_switches.h" 49 #include "chrome/common/chrome_switches.h"
50 #include "components/prefs/pref_service.h" 50 #include "components/prefs/pref_service.h"
51 #include "components/prefs/scoped_user_pref_update.h" 51 #include "components/prefs/scoped_user_pref_update.h"
52 #include "content/public/browser/render_widget_host_view.h" 52 #include "content/public/browser/render_widget_host_view.h"
53 #include "content/public/browser/web_contents.h" 53 #include "content/public/browser/web_contents.h"
54 #import "ui/base/cocoa/focus_tracker.h" 54 #import "ui/base/cocoa/focus_tracker.h"
55 #import "ui/base/cocoa/nsview_additions.h" 55 #import "ui/base/cocoa/nsview_additions.h"
56 #include "ui/base/ui_base_types.h" 56 #include "ui/base/ui_base_types.h"
57 57
58 using content::RenderWidgetHostView; 58 using content::RenderWidgetHostView;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 base::scoped_nsobject<BrowserWindowLayout> layout( 262 base::scoped_nsobject<BrowserWindowLayout> layout(
263 [[BrowserWindowLayout alloc] init]); 263 [[BrowserWindowLayout alloc] init]);
264 [self updateLayoutParameters:layout]; 264 [self updateLayoutParameters:layout];
265 [self applyLayout:layout]; 265 [self applyLayout:layout];
266 266
267 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]]; 267 [toolbarController_ setDividerOpacity:[self toolbarDividerOpacity]];
268 268
269 // Will update the location of the permission bubble when showing/hiding the 269 // Will update the location of the permission bubble when showing/hiding the
270 // top level toolbar in fullscreen. 270 // top level toolbar in fullscreen.
271 PermissionBubbleManager* manager = [self permissionBubbleManager]; 271 PermissionRequestManager* manager = [self permissionRequestManager];
272 if (manager) 272 if (manager)
273 manager->UpdateAnchorPosition(); 273 manager->UpdateAnchorPosition();
274 274
275 browser_->GetBubbleManager()->UpdateAllBubbleAnchors(); 275 browser_->GetBubbleManager()->UpdateAllBubbleAnchors();
276 } 276 }
277 277
278 - (void)applyTabStripLayout:(const chrome::TabStripLayout&)layout { 278 - (void)applyTabStripLayout:(const chrome::TabStripLayout&)layout {
279 // Update the presence of the window controls. 279 // Update the presence of the window controls.
280 if (layout.addCustomWindowControls) 280 if (layout.addCustomWindowControls)
281 [tabStripController_ addCustomWindowControls]; 281 [tabStripController_ addCustomWindowControls];
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 414
415 [sourceWindow setWindowController:nil]; 415 [sourceWindow setWindowController:nil];
416 [self setWindow:destWindow]; 416 [self setWindow:destWindow];
417 [destWindow setWindowController:self]; 417 [destWindow setWindowController:self];
418 418
419 // Move the status bubble over, if we have one. 419 // Move the status bubble over, if we have one.
420 if (statusBubble_) 420 if (statusBubble_)
421 statusBubble_->SwitchParentWindow(destWindow); 421 statusBubble_->SwitchParentWindow(destWindow);
422 422
423 // Updates the bubble position. 423 // Updates the bubble position.
424 PermissionBubbleManager* manager = [self permissionBubbleManager]; 424 PermissionRequestManager* manager = [self permissionRequestManager];
425 if (manager) 425 if (manager)
426 manager->UpdateAnchorPosition(); 426 manager->UpdateAnchorPosition();
427 427
428 // Move the title over. 428 // Move the title over.
429 [destWindow setTitle:[sourceWindow title]]; 429 [destWindow setTitle:[sourceWindow title]];
430 430
431 // The window needs to be onscreen before we can set its first responder. 431 // The window needs to be onscreen before we can set its first responder.
432 // Ordering the window to the front can change the active Space (either to 432 // Ordering the window to the front can change the active Space (either to
433 // the window's old Space or to the application's assigned Space). To prevent 433 // the window's old Space or to the application's assigned Space). To prevent
434 // this by temporarily change the collectionBehavior. 434 // this by temporarily change the collectionBehavior.
(...skipping 26 matching lines...) Expand all
461 delay:YES]; 461 delay:YES];
462 } 462 }
463 463
464 - (void)configureFullscreenToolbarController { 464 - (void)configureFullscreenToolbarController {
465 BOOL fullscreenForTab = [self isFullscreenForTabContentOrExtension]; 465 BOOL fullscreenForTab = [self isFullscreenForTabContentOrExtension];
466 BOOL kioskMode = 466 BOOL kioskMode =
467 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); 467 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode);
468 BOOL showDropdown = 468 BOOL showDropdown =
469 !fullscreenForTab && !kioskMode && ([self floatingBarHasFocus]); 469 !fullscreenForTab && !kioskMode && ([self floatingBarHasFocus]);
470 470
471 PermissionBubbleManager* manager = [self permissionBubbleManager]; 471 PermissionRequestManager* manager = [self permissionRequestManager];
472 if (manager && manager->IsBubbleVisible()) { 472 if (manager && manager->IsBubbleVisible()) {
473 NSWindow* bubbleWindow = manager->GetBubbleWindow(); 473 NSWindow* bubbleWindow = manager->GetBubbleWindow();
474 DCHECK(bubbleWindow); 474 DCHECK(bubbleWindow);
475 // A visible permission bubble will force the dropdown to remain 475 // A visible permission bubble will force the dropdown to remain
476 // visible. 476 // visible.
477 [self lockBarVisibilityForOwner:bubbleWindow withAnimation:NO delay:NO]; 477 [self lockBarVisibilityForOwner:bubbleWindow withAnimation:NO delay:NO];
478 showDropdown = YES; 478 showDropdown = YES;
479 // Register to be notified when the permission bubble is closed, to 479 // Register to be notified when the permission bubble is closed, to
480 // allow fullscreen to hide the dropdown. 480 // allow fullscreen to hide the dropdown.
481 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 481 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 808
809 if (notification) // For System Fullscreen when non-nil. 809 if (notification) // For System Fullscreen when non-nil.
810 [self deregisterForContentViewResizeNotifications]; 810 [self deregisterForContentViewResizeNotifications];
811 811
812 browser_->WindowFullscreenStateChanged(); 812 browser_->WindowFullscreenStateChanged();
813 [self.chromeContentView setAutoresizesSubviews:YES]; 813 [self.chromeContentView setAutoresizesSubviews:YES];
814 814
815 [self resetCustomAppKitFullscreenVariables]; 815 [self resetCustomAppKitFullscreenVariables];
816 816
817 // Ensures that the permission bubble shows up properly at the front. 817 // Ensures that the permission bubble shows up properly at the front.
818 PermissionBubbleManager* manager = [self permissionBubbleManager]; 818 PermissionRequestManager* manager = [self permissionRequestManager];
819 if (manager && manager->IsBubbleVisible()) { 819 if (manager && manager->IsBubbleVisible()) {
820 NSWindow* bubbleWindow = manager->GetBubbleWindow(); 820 NSWindow* bubbleWindow = manager->GetBubbleWindow();
821 DCHECK(bubbleWindow); 821 DCHECK(bubbleWindow);
822 [bubbleWindow orderFront:nil]; 822 [bubbleWindow orderFront:nil];
823 } 823 }
824 824
825 // Ensure that the window is layout properly. 825 // Ensure that the window is layout properly.
826 [self layoutSubviews]; 826 [self layoutSubviews];
827 } 827 }
828 828
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 if ([fullscreenTransition_ shouldWindowBeUnconstrained]) 1267 if ([fullscreenTransition_ shouldWindowBeUnconstrained])
1268 return NO; 1268 return NO;
1269 1269
1270 return [super shouldConstrainFrameRect]; 1270 return [super shouldConstrainFrameRect];
1271 } 1271 }
1272 1272
1273 - (WebContents*)webContents { 1273 - (WebContents*)webContents {
1274 return browser_->tab_strip_model()->GetActiveWebContents(); 1274 return browser_->tab_strip_model()->GetActiveWebContents();
1275 } 1275 }
1276 1276
1277 - (PermissionBubbleManager*)permissionBubbleManager { 1277 - (PermissionRequestManager*)permissionRequestManager {
1278 if (WebContents* contents = [self webContents]) 1278 if (WebContents* contents = [self webContents])
1279 return PermissionBubbleManager::FromWebContents(contents); 1279 return PermissionRequestManager::FromWebContents(contents);
1280 return nil; 1280 return nil;
1281 } 1281 }
1282 1282
1283 - (BOOL)isFullscreenForTabContentOrExtension { 1283 - (BOOL)isFullscreenForTabContentOrExtension {
1284 FullscreenController* controller = 1284 FullscreenController* controller =
1285 browser_->exclusive_access_manager()->fullscreen_controller(); 1285 browser_->exclusive_access_manager()->fullscreen_controller();
1286 return controller->IsWindowFullscreenForTabOrPending() || 1286 return controller->IsWindowFullscreenForTabOrPending() ||
1287 controller->IsExtensionFullscreenOrPending(); 1287 controller->IsExtensionFullscreenOrPending();
1288 } 1288 }
1289 1289
1290 - (void)windowWillBeginSheet:(NSNotification*)notification { 1290 - (void)windowWillBeginSheet:(NSNotification*)notification {
1291 if (fullscreenLowPowerCoordinator_) 1291 if (fullscreenLowPowerCoordinator_)
1292 fullscreenLowPowerCoordinator_->SetHasActiveSheet(true); 1292 fullscreenLowPowerCoordinator_->SetHasActiveSheet(true);
1293 } 1293 }
1294 1294
1295 - (void)windowDidEndSheet:(NSNotification*)notification { 1295 - (void)windowDidEndSheet:(NSNotification*)notification {
1296 if (fullscreenLowPowerCoordinator_) 1296 if (fullscreenLowPowerCoordinator_)
1297 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false); 1297 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false);
1298 } 1298 }
1299 1299
1300 - (void)childWindowsDidChange { 1300 - (void)childWindowsDidChange {
1301 if (fullscreenLowPowerCoordinator_) 1301 if (fullscreenLowPowerCoordinator_)
1302 fullscreenLowPowerCoordinator_->ChildWindowsChanged(); 1302 fullscreenLowPowerCoordinator_->ChildWindowsChanged();
1303 } 1303 }
1304 1304
1305 @end // @implementation BrowserWindowController(Private) 1305 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698