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/browser_window_controller.mm

Issue 2142983002: Add desktop engagement metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 [[self window] orderOut:self]; 591 [[self window] orderOut:self];
592 return NO; 592 return NO;
593 } 593 }
594 594
595 // the tab strip is empty, it's ok to close the window 595 // the tab strip is empty, it's ok to close the window
596 return YES; 596 return YES;
597 } 597 }
598 598
599 // Called right after our window became the main window. 599 // Called right after our window became the main window.
600 - (void)windowDidBecomeMain:(NSNotification*)notification { 600 - (void)windowDidBecomeMain:(NSNotification*)notification {
601 if (chrome::GetLastActiveBrowser() != browser_.get()) { 601 // Set this window as active even if the previously active windows was the
Lei Zhang 2016/08/01 17:29:02 Funny enough, before https://codereview.chromium.o
gayane -on leave until 09-2017 2016/08/02 17:13:44 Yes, there is also this CL https://codereview.chro
602 BrowserList::SetLastActive(browser_.get()); 602 // same one. This is needed for tracking visibility changes of a browser.
603 } 603 BrowserList::SetLastActive(browser_.get());
604
604 // Always saveWindowPositionIfNeeded when becoming main, not just 605 // Always saveWindowPositionIfNeeded when becoming main, not just
605 // when |browser_| is not the last active browser. See crbug.com/536280 . 606 // when |browser_| is not the last active browser. See crbug.com/536280 .
606 [self saveWindowPositionIfNeeded]; 607 [self saveWindowPositionIfNeeded];
607 608
608 NSView* rootView = [[[self window] contentView] superview]; 609 NSView* rootView = [[[self window] contentView] superview];
609 [rootView cr_recursivelyInvokeBlock:^(id view) { 610 [rootView cr_recursivelyInvokeBlock:^(id view) {
610 if ([view conformsToProtocol:@protocol(ThemedWindowDrawing)]) 611 if ([view conformsToProtocol:@protocol(ThemedWindowDrawing)])
611 [view windowDidChangeActive]; 612 [view windowDidChangeActive];
612 }]; 613 }];
613 614
614 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile()) 615 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile())
615 ->set_registry_for_active_window(extension_keybinding_registry_.get()); 616 ->set_registry_for_active_window(extension_keybinding_registry_.get());
616 } 617 }
617 618
618 - (void)windowDidResignMain:(NSNotification*)notification { 619 - (void)windowDidResignMain:(NSNotification*)notification {
619 NSView* rootView = [[[self window] contentView] superview]; 620 NSView* rootView = [[[self window] contentView] superview];
620 [rootView cr_recursivelyInvokeBlock:^(id view) { 621 [rootView cr_recursivelyInvokeBlock:^(id view) {
621 if ([view conformsToProtocol:@protocol(ThemedWindowDrawing)]) 622 if ([view conformsToProtocol:@protocol(ThemedWindowDrawing)])
622 [view windowDidChangeActive]; 623 [view windowDidChangeActive];
623 }]; 624 }];
624 625
625 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile()) 626 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile())
626 ->set_registry_for_active_window(nullptr); 627 ->set_registry_for_active_window(nullptr);
628
629 BrowserList::NotifyBrowserNoLongerActive(browser_.get());
627 } 630 }
628 631
629 // Called when we have been minimized. 632 // Called when we have been minimized.
630 - (void)windowDidMiniaturize:(NSNotification *)notification { 633 - (void)windowDidMiniaturize:(NSNotification *)notification {
631 [self saveWindowPositionIfNeeded]; 634 [self saveWindowPositionIfNeeded];
632 } 635 }
633 636
634 // Called when we have been unminimized. 637 // Called when we have been unminimized.
635 - (void)windowDidDeminiaturize:(NSNotification *)notification { 638 - (void)windowDidDeminiaturize:(NSNotification *)notification {
636 // Make sure the window's show_state (which is now ui::SHOW_STATE_NORMAL) 639 // Make sure the window's show_state (which is now ui::SHOW_STATE_NORMAL)
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 2056
2054 - (NSRect)savedRegularWindowFrame { 2057 - (NSRect)savedRegularWindowFrame {
2055 return savedRegularWindowFrame_; 2058 return savedRegularWindowFrame_;
2056 } 2059 }
2057 2060
2058 - (BOOL)isFullscreenTransitionInProgress { 2061 - (BOOL)isFullscreenTransitionInProgress {
2059 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; 2062 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_;
2060 } 2063 }
2061 2064
2062 @end // @implementation BrowserWindowController(WindowType) 2065 @end // @implementation BrowserWindowController(WindowType)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698