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

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

Issue 1858063002: Remove Mac NPAPI things (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more build fixes Created 4 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller_private.mm » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <numeric> 8 #include <numeric>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 NSRect frame = [[self window] frame]; 400 NSRect frame = [[self window] frame];
401 frame.size.height += convertedSize.height; 401 frame.size.height += convertedSize.height;
402 frame.origin.y -= convertedSize.height; 402 frame.origin.y -= convertedSize.height;
403 [[self window] setFrame:frame display:NO]; 403 [[self window] setFrame:frame display:NO];
404 } 404 }
405 } 405 }
406 406
407 // Create the bridge for the status bubble. 407 // Create the bridge for the status bubble.
408 statusBubble_ = new StatusBubbleMac([self window], self); 408 statusBubble_ = new StatusBubbleMac([self window], self);
409 409
410 // Register for application hide/unhide notifications.
411 [[NSNotificationCenter defaultCenter]
412 addObserver:self
413 selector:@selector(applicationDidHide:)
414 name:NSApplicationDidHideNotification
415 object:nil];
416 [[NSNotificationCenter defaultCenter]
417 addObserver:self
418 selector:@selector(applicationDidUnhide:)
419 name:NSApplicationDidUnhideNotification
420 object:nil];
421
422 // This must be done after the view is added to the window since it relies 410 // This must be done after the view is added to the window since it relies
423 // on the window bounds to determine whether to show buttons or not. 411 // on the window bounds to determine whether to show buttons or not.
424 if ([self hasToolbar]) // Do not create the buttons in popups. 412 if ([self hasToolbar]) // Do not create the buttons in popups.
425 [toolbarController_ createBrowserActionButtons]; 413 [toolbarController_ createBrowserActionButtons];
426 414
427 extension_keybinding_registry_.reset( 415 extension_keybinding_registry_.reset(
428 new ExtensionKeybindingRegistryCocoa(browser_->profile(), 416 new ExtensionKeybindingRegistryCocoa(browser_->profile(),
429 [self window], 417 [self window],
430 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, 418 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS,
431 windowShim_.get())); 419 windowShim_.get()));
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 [view windowDidChangeActive]; 638 [view windowDidChangeActive];
651 }]; 639 }];
652 640
653 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile()) 641 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile())
654 ->set_registry_for_active_window(nullptr); 642 ->set_registry_for_active_window(nullptr);
655 } 643 }
656 644
657 // Called when we have been minimized. 645 // Called when we have been minimized.
658 - (void)windowDidMiniaturize:(NSNotification *)notification { 646 - (void)windowDidMiniaturize:(NSNotification *)notification {
659 [self saveWindowPositionIfNeeded]; 647 [self saveWindowPositionIfNeeded];
660
661 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
662 if (WebContents* contents = [self webContents]) {
663 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
664 rwhv->SetWindowVisibility(false);
665 }
666 } 648 }
667 649
668 // Called when we have been unminimized. 650 // Called when we have been unminimized.
669 - (void)windowDidDeminiaturize:(NSNotification *)notification { 651 - (void)windowDidDeminiaturize:(NSNotification *)notification {
670 // Make sure the window's show_state (which is now ui::SHOW_STATE_NORMAL) 652 // Make sure the window's show_state (which is now ui::SHOW_STATE_NORMAL)
671 // gets saved. 653 // gets saved.
672 [self saveWindowPositionIfNeeded]; 654 [self saveWindowPositionIfNeeded];
673
674 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
675 if (WebContents* contents = [self webContents]) {
676 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
677 rwhv->SetWindowVisibility(true);
678 }
679 }
680
681 // Called when the application has been hidden.
682 - (void)applicationDidHide:(NSNotification *)notification {
683 // Let the selected RenderWidgetHostView know, so that it can tell plugins
684 // (unless we are minimized, in which case nothing has really changed).
685 if (![[self window] isMiniaturized]) {
686 if (WebContents* contents = [self webContents]) {
687 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
688 rwhv->SetWindowVisibility(false);
689 }
690 }
691 }
692
693 // Called when the application has been unhidden.
694 - (void)applicationDidUnhide:(NSNotification *)notification {
695 // Let the selected RenderWidgetHostView know, so that it can tell plugins
696 // (unless we are minimized, in which case nothing has really changed).
697 if (![[self window] isMiniaturized]) {
698 if (WebContents* contents = [self webContents]) {
699 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
700 rwhv->SetWindowVisibility(true);
701 }
702 }
703 } 655 }
704 656
705 // Called when the user clicks the zoom button (or selects it from the Window 657 // Called when the user clicks the zoom button (or selects it from the Window
706 // menu) to determine the "standard size" of the window, based on the content 658 // menu) to determine the "standard size" of the window, based on the content
707 // and other factors. If the current size/location differs nontrivally from the 659 // and other factors. If the current size/location differs nontrivally from the
708 // standard size, Cocoa resizes the window to the standard size, and saves the 660 // standard size, Cocoa resizes the window to the standard size, and saves the
709 // current size as the "user size". If the current size/location is the same (up 661 // current size as the "user size". If the current size/location is the same (up
710 // to a fudge factor) as the standard size, Cocoa resizes the window to the 662 // to a fudge factor) as the standard size, Cocoa resizes the window to the
711 // saved user size. (It is possible for the two to coincide.) In this way, the 663 // saved user size. (It is possible for the two to coincide.) In this way, the
712 // zoom button acts as a toggle. We determine the standard size based on the 664 // zoom button acts as a toggle. We determine the standard size based on the
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 // Delegate method called when window is resized. 1674 // Delegate method called when window is resized.
1723 - (void)windowDidResize:(NSNotification*)notification { 1675 - (void)windowDidResize:(NSNotification*)notification {
1724 [self saveWindowPositionIfNeeded]; 1676 [self saveWindowPositionIfNeeded];
1725 1677
1726 // Resize (and possibly move) the status bubble. Note that we may get called 1678 // Resize (and possibly move) the status bubble. Note that we may get called
1727 // when the status bubble does not exist. 1679 // when the status bubble does not exist.
1728 if (statusBubble_) { 1680 if (statusBubble_) {
1729 statusBubble_->UpdateSizeAndPosition(); 1681 statusBubble_->UpdateSizeAndPosition();
1730 } 1682 }
1731 1683
1732 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
1733 if (WebContents* contents = [self webContents]) {
1734 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
1735 rwhv->WindowFrameChanged();
1736 }
1737
1738 // The FindBar needs to know its own position to properly detect overlaps 1684 // The FindBar needs to know its own position to properly detect overlaps
1739 // with find results. The position changes whenever the window is resized, 1685 // with find results. The position changes whenever the window is resized,
1740 // and |layoutSubviews| computes the FindBar's position. 1686 // and |layoutSubviews| computes the FindBar's position.
1741 // TODO: calling |layoutSubviews| here is a waste, find a better way to 1687 // TODO: calling |layoutSubviews| here is a waste, find a better way to
1742 // do this. 1688 // do this.
1743 if ([findBarCocoaController_ isFindBarVisible]) 1689 if ([findBarCocoaController_ isFindBarVisible])
1744 [self layoutSubviews]; 1690 [self layoutSubviews];
1745 } 1691 }
1746 1692
1747 // Handle the openLearnMoreAboutCrashLink: action from SadTabView when 1693 // Handle the openLearnMoreAboutCrashLink: action from SadTabView when
(...skipping 22 matching lines...) Expand all
1770 // Unfortunately, Cocoa sends |-windowWillMove:| too frequently (including 1716 // Unfortunately, Cocoa sends |-windowWillMove:| too frequently (including
1771 // when clicking on the title bar to activate), and of course 1717 // when clicking on the title bar to activate), and of course
1772 // |-windowWillMove| is called too early for us to apply our heuristic. (The 1718 // |-windowWillMove| is called too early for us to apply our heuristic. (The
1773 // heuristic we use for detecting window movement is that if |windowTopGrowth_ 1719 // heuristic we use for detecting window movement is that if |windowTopGrowth_
1774 // > 0|, then we should be at the bottom of the work area -- if we're not, 1720 // > 0|, then we should be at the bottom of the work area -- if we're not,
1775 // we've moved. Similarly for the other side.) 1721 // we've moved. Similarly for the other side.)
1776 if (!NSContainsRect(workarea, windowFrame) || 1722 if (!NSContainsRect(workarea, windowFrame) ||
1777 (windowTopGrowth_ > 0 && NSMinY(windowFrame) != NSMinY(workarea)) || 1723 (windowTopGrowth_ > 0 && NSMinY(windowFrame) != NSMinY(workarea)) ||
1778 (windowBottomGrowth_ > 0 && NSMaxY(windowFrame) != NSMaxY(workarea))) 1724 (windowBottomGrowth_ > 0 && NSMaxY(windowFrame) != NSMaxY(workarea)))
1779 [self resetWindowGrowthState]; 1725 [self resetWindowGrowthState];
1780
1781 // Let the selected RenderWidgetHostView know, so that it can tell plugins.
1782 if (WebContents* contents = [self webContents]) {
1783 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
1784 rwhv->WindowFrameChanged();
1785 }
1786 } 1726 }
1787 1727
1788 // Delegate method called when window will be resized; not called for 1728 // Delegate method called when window will be resized; not called for
1789 // |-setFrame:display:|. 1729 // |-setFrame:display:|.
1790 - (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize { 1730 - (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize {
1791 [self resetWindowGrowthState]; 1731 [self resetWindowGrowthState];
1792 return frameSize; 1732 return frameSize;
1793 } 1733 }
1794 1734
1795 // Delegate method: see |NSWindowDelegate| protocol. 1735 // Delegate method: see |NSWindowDelegate| protocol.
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2107 2047
2108 - (BOOL)isTabbedWindow { 2048 - (BOOL)isTabbedWindow {
2109 return browser_->is_type_tabbed(); 2049 return browser_->is_type_tabbed();
2110 } 2050 }
2111 2051
2112 - (NSRect)savedRegularWindowFrame { 2052 - (NSRect)savedRegularWindowFrame {
2113 return savedRegularWindowFrame_; 2053 return savedRegularWindowFrame_;
2114 } 2054 }
2115 2055
2116 @end // @implementation BrowserWindowController(WindowType) 2056 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller_private.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698