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

Side by Side Diff: chrome/browser/ui/panels/panel_window_controller_cocoa.mm

Issue 9956145: Remove wrench button from panel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 8 years, 8 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 | Annotate | Revision Log
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 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h" 5 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 14 matching lines...) Expand all
25 #import "chrome/browser/ui/cocoa/event_utils.h" 25 #import "chrome/browser/ui/cocoa/event_utils.h"
26 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" 26 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
27 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" 27 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
28 #import "chrome/browser/ui/cocoa/menu_controller.h" 28 #import "chrome/browser/ui/cocoa/menu_controller.h"
29 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" 29 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h"
30 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 30 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
31 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" 31 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h"
32 #include "chrome/browser/ui/panels/panel_bounds_animation.h" 32 #include "chrome/browser/ui/panels/panel_bounds_animation.h"
33 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" 33 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h"
34 #include "chrome/browser/ui/panels/panel_manager.h" 34 #include "chrome/browser/ui/panels/panel_manager.h"
35 #include "chrome/browser/ui/panels/panel_settings_menu_model.h"
36 #include "chrome/browser/ui/panels/panel_strip.h" 35 #include "chrome/browser/ui/panels/panel_strip.h"
37 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" 36 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h"
38 #import "chrome/browser/ui/panels/panel_utils_cocoa.h" 37 #import "chrome/browser/ui/panels/panel_utils_cocoa.h"
39 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 38 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
40 #include "chrome/common/chrome_notification_types.h" 39 #include "chrome/common/chrome_notification_types.h"
41 #include "content/public/browser/notification_service.h" 40 #include "content/public/browser/notification_service.h"
42 #include "content/public/browser/render_widget_host_view.h" 41 #include "content/public/browser/render_widget_host_view.h"
43 #include "content/public/browser/web_contents.h" 42 #include "content/public/browser/web_contents.h"
44 #include "grit/ui_resources.h" 43 #include "grit/ui_resources.h"
45 #include "ui/base/resource/resource_bundle.h" 44 #include "ui/base/resource/resource_bundle.h"
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { 435 if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
437 windowShim_.reset(window); 436 windowShim_.reset(window);
438 animateOnBoundsChange_ = YES; 437 animateOnBoundsChange_ = YES;
439 canBecomeKeyWindow_ = YES; 438 canBecomeKeyWindow_ = YES;
440 contentsController_.reset( 439 contentsController_.reset(
441 [[TabContentsController alloc] initWithContents:nil]); 440 [[TabContentsController alloc] initWithContents:nil]);
442 } 441 }
443 return self; 442 return self;
444 } 443 }
445 444
446 - (void)dealloc {
447 if (windowTrackingArea_.get()) {
448 [[[[self window] contentView] superview]
449 removeTrackingArea:windowTrackingArea_.get()];
450 }
451 [super dealloc];
452 }
453
454 - (ui::ThemeProvider*)themeProvider { 445 - (ui::ThemeProvider*)themeProvider {
455 return ThemeServiceFactory::GetForProfile(windowShim_->browser()->profile()); 446 return ThemeServiceFactory::GetForProfile(windowShim_->browser()->profile());
456 } 447 }
457 448
458 - (ThemedWindowStyle)themedWindowStyle { 449 - (ThemedWindowStyle)themedWindowStyle {
459 ThemedWindowStyle style = THEMED_POPUP; 450 ThemedWindowStyle style = THEMED_POPUP;
460 if (windowShim_->browser()->profile()->IsOffTheRecord()) 451 if (windowShim_->browser()->profile()->IsOffTheRecord())
461 style |= THEMED_INCOGNITO; 452 style |= THEMED_INCOGNITO;
462 return style; 453 return style;
463 } 454 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 NSView* superview = [[window contentView] superview]; 491 NSView* superview = [[window contentView] superview];
501 NSRect bounds = [superview bounds]; 492 NSRect bounds = [superview bounds];
502 overlayView_.reset( 493 overlayView_.reset(
503 [[PanelResizeByMouseOverlay alloc] initWithFrame:bounds 494 [[PanelResizeByMouseOverlay alloc] initWithFrame:bounds
504 panel:windowShim_->panel()]); 495 panel:windowShim_->panel()]);
505 // Set autoresizing behavior: glued to edges. 496 // Set autoresizing behavior: glued to edges.
506 [overlayView_ setAutoresizingMask:(NSViewHeightSizable | NSViewWidthSizable)]; 497 [overlayView_ setAutoresizingMask:(NSViewHeightSizable | NSViewWidthSizable)];
507 [superview addSubview:overlayView_ positioned:NSWindowAbove relativeTo:nil]; 498 [superview addSubview:overlayView_ positioned:NSWindowAbove relativeTo:nil];
508 } 499 }
509 500
510 - (void)mouseEntered:(NSEvent*)event {
511 [titlebar_view_ updateSettingsButtonVisibility:YES];
512 }
513
514 - (void)mouseExited:(NSEvent*)event {
515 // We sometimes get an exit event from a tracking area that has
516 // already been removed. So we need this check.
517 NSPoint mouse = [NSEvent mouseLocation];
518 NSRect frame = [[self window] frame];
519 if (!NSMouseInRect(mouse, frame, NO)) {
520 [titlebar_view_ updateSettingsButtonVisibility:NO];
521 }
522 }
523
524 - (void)disableTabContentsViewAutosizing { 501 - (void)disableTabContentsViewAutosizing {
525 [[[self window] contentView] setAutoresizesSubviews:NO]; 502 [[[self window] contentView] setAutoresizesSubviews:NO];
526 } 503 }
527 504
528 - (void)enableTabContentsViewAutosizing { 505 - (void)enableTabContentsViewAutosizing {
529 NSView* contentView = [[self window] contentView]; 506 NSView* contentView = [[self window] contentView];
530 NSView* controllerView = [contentsController_ view]; 507 NSView* controllerView = [contentsController_ view];
531 508
532 DCHECK([controllerView superview] == contentView); 509 DCHECK([controllerView superview] == contentView);
533 DCHECK([controllerView autoresizingMask] & NSViewHeightSizable); 510 DCHECK([controllerView autoresizingMask] & NSViewHeightSizable);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 windowShim_->DidCloseNativeWindow(); 725 windowShim_->DidCloseNativeWindow();
749 // Call |-autorelease| after a zero-length delay to avoid deadlock from 726 // Call |-autorelease| after a zero-length delay to avoid deadlock from
750 // code in the current run loop that waits on BROWSER_CLOSED notification. 727 // code in the current run loop that waits on BROWSER_CLOSED notification.
751 // The notification is sent when this object is freed, but this object 728 // The notification is sent when this object is freed, but this object
752 // cannot be freed until the current run loop completes. 729 // cannot be freed until the current run loop completes.
753 [self performSelector:@selector(autorelease) 730 [self performSelector:@selector(autorelease)
754 withObject:nil 731 withObject:nil
755 afterDelay:0]; 732 afterDelay:0];
756 } 733 }
757 734
758 - (void)runSettingsMenu:(NSView*)button {
759 Panel* panel = windowShim_->panel();
760 DCHECK(panel->GetExtension());
761
762 scoped_ptr<PanelSettingsMenuModel> settingsMenuModel(
763 new PanelSettingsMenuModel(panel));
764 scoped_nsobject<MenuController> settingsMenuController(
765 [[MenuController alloc] initWithModel:settingsMenuModel.get()
766 useWithPopUpButtonCell:NO]);
767
768 [NSMenu popUpContextMenu:[settingsMenuController menu]
769 withEvent:[NSApp currentEvent]
770 forView:button];
771 }
772
773 - (BOOL)isDraggable { 735 - (BOOL)isDraggable {
774 return windowShim_->panel()->draggable(); 736 return windowShim_->panel()->draggable();
775 } 737 }
776 738
777 - (void)startDrag:(NSPoint)mouseLocation { 739 - (void)startDrag:(NSPoint)mouseLocation {
778 // Convert from Cocoa's screen coordinates to platform-indepedent screen 740 // Convert from Cocoa's screen coordinates to platform-indepedent screen
779 // coordinates because PanelManager method takes platform-indepedent screen 741 // coordinates because PanelManager method takes platform-indepedent screen
780 // coordinates. 742 // coordinates.
781 windowShim_->panel()->manager()->StartDragging( 743 windowShim_->panel()->manager()->StartDragging(
782 windowShim_->panel(), 744 windowShim_->panel(),
783 cocoa_utils::ConvertPointFromCocoaCoordinates(mouseLocation)); 745 cocoa_utils::ConvertPointFromCocoaCoordinates(mouseLocation));
784 } 746 }
785 747
786 - (void)endDrag:(BOOL)cancelled { 748 - (void)endDrag:(BOOL)cancelled {
787 windowShim_->panel()->manager()->EndDragging(cancelled); 749 windowShim_->panel()->manager()->EndDragging(cancelled);
788 } 750 }
789 751
790 - (void)drag:(NSPoint)mouseLocation { 752 - (void)drag:(NSPoint)mouseLocation {
791 // Convert from Cocoa's screen coordinates to platform-indepedent screen 753 // Convert from Cocoa's screen coordinates to platform-indepedent screen
792 // coordinates because PanelManager method takes platform-indepedent screen 754 // coordinates because PanelManager method takes platform-indepedent screen
793 // coordinates. 755 // coordinates.
794 windowShim_->panel()->manager()->Drag( 756 windowShim_->panel()->manager()->Drag(
795 cocoa_utils::ConvertPointFromCocoaCoordinates(mouseLocation)); 757 cocoa_utils::ConvertPointFromCocoaCoordinates(mouseLocation));
796 } 758 }
797 759
798 - (void)setPanelFrame:(NSRect)frame 760 - (void)setPanelFrame:(NSRect)frame
799 animate:(BOOL)animate { 761 animate:(BOOL)animate {
800 // Setup the whole window as the tracking area so that we can get notified
801 // when the mouse enters or leaves the window. This will make us be able to
802 // show or hide settings button accordingly.
803 NSRect localBounds = frame;
804 localBounds.origin = NSZeroPoint;
805
806 if (windowTrackingArea_.get()) {
807 [[[[self window] contentView] superview]
808 removeTrackingArea:windowTrackingArea_.get()];
809 }
810
811 windowTrackingArea_.reset(
812 [[CrTrackingArea alloc] initWithRect:localBounds
813 options:(NSTrackingMouseEnteredAndExited |
814 NSTrackingActiveAlways)
815 proxiedOwner:self
816 userInfo:nil]);
817 [windowTrackingArea_.get() clearOwnerWhenWindowWillClose:[self window]];
818 [[[[self window] contentView] superview]
819 addTrackingArea:windowTrackingArea_.get()];
820
821 BOOL jumpToDestination = (!animateOnBoundsChange_ || !animate); 762 BOOL jumpToDestination = (!animateOnBoundsChange_ || !animate);
822 763
823 // If no animation is in progress, apply bounds change instantly. 764 // If no animation is in progress, apply bounds change instantly.
824 if (jumpToDestination && ![self isAnimatingBounds]) { 765 if (jumpToDestination && ![self isAnimatingBounds]) {
825 [[self window] setFrame:frame display:YES animate:NO]; 766 [[self window] setFrame:frame display:YES animate:NO];
826 return; 767 return;
827 } 768 }
828 769
829 NSDictionary *windowResize = [NSDictionary dictionaryWithObjectsAndKeys: 770 NSDictionary *windowResize = [NSDictionary dictionaryWithObjectsAndKeys:
830 [self window], NSViewAnimationTargetKey, 771 [self window], NSViewAnimationTargetKey,
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 if (![self isWindowLoaded]) 1025 if (![self isWindowLoaded])
1085 return; 1026 return;
1086 [[self window] invalidateCursorRectsForView:overlayView_]; 1027 [[self window] invalidateCursorRectsForView:overlayView_];
1087 } 1028 }
1088 1029
1089 - (BOOL)isActivationByClickingTitlebarEnabled { 1030 - (BOOL)isActivationByClickingTitlebarEnabled {
1090 return !windowShim_->panel()->always_on_top(); 1031 return !windowShim_->panel()->always_on_top();
1091 } 1032 }
1092 1033
1093 @end 1034 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698