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

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 402066: Moved a whole pile of unittests over to CocoaTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/app_controller_mac.h" 5 #import "chrome/browser/app_controller_mac.h"
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/mac_util.h" 9 #include "base/mac_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 BrowserList::CloseAllBrowsers(true); 159 BrowserList::CloseAllBrowsers(true);
160 160
161 // On Windows, this is done in Browser::OnWindowClosing, but that's not 161 // On Windows, this is done in Browser::OnWindowClosing, but that's not
162 // appropriate on Mac since we don't shut down when we reach zero windows. 162 // appropriate on Mac since we don't shut down when we reach zero windows.
163 browser_shutdown::OnShutdownStarting(browser_shutdown::BROWSER_EXIT); 163 browser_shutdown::OnShutdownStarting(browser_shutdown::BROWSER_EXIT);
164 164
165 // Release the reference to the browser process. Once all the browsers get 165 // Release the reference to the browser process. Once all the browsers get
166 // dealloc'd, it will stop the RunLoop and fall back into main(). 166 // dealloc'd, it will stop the RunLoop and fall back into main().
167 g_browser_process->ReleaseModule(); 167 g_browser_process->ReleaseModule();
168 168
169 // Close these off if they have open windows.
170 [prefsController_ close];
171 [aboutController_ close];
172
169 [[NSNotificationCenter defaultCenter] removeObserver:self]; 173 [[NSNotificationCenter defaultCenter] removeObserver:self];
170 } 174 }
171 175
172 - (void)didEndMainMessageLoop { 176 - (void)didEndMainMessageLoop {
173 DCHECK(!BrowserList::HasBrowserWithProfile([self defaultProfile])); 177 DCHECK(!BrowserList::HasBrowserWithProfile([self defaultProfile]));
174 if (!BrowserList::HasBrowserWithProfile([self defaultProfile])) { 178 if (!BrowserList::HasBrowserWithProfile([self defaultProfile])) {
175 // As we're shutting down, we need to nuke the TabRestoreService, which 179 // As we're shutting down, we need to nuke the TabRestoreService, which
176 // will start the shutdown of the NavigationControllers and allow for 180 // will start the shutdown of the NavigationControllers and allow for
177 // proper shutdown. If we don't do this, Chrome won't shut down cleanly, 181 // proper shutdown. If we don't do this, Chrome won't shut down cleanly,
178 // and may end up crashing when some thread tries to use the IO thread (or 182 // and may end up crashing when some thread tries to use the IO thread (or
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 continue; 679 continue;
676 GURL gurl(std::string((char*)[fileURLData bytes], [fileURLData length])); 680 GURL gurl(std::string((char*)[fileURLData bytes], [fileURLData length]));
677 gurlVector.push_back(gurl); 681 gurlVector.push_back(gurl);
678 } 682 }
679 683
680 [self openURLs:gurlVector]; 684 [self openURLs:gurlVector];
681 } 685 }
682 686
683 // Called when the preferences window is closed. We use this to release the 687 // Called when the preferences window is closed. We use this to release the
684 // window controller. 688 // window controller.
685 - (void)prefsWindowClosed:(NSNotification*)notify { 689 - (void)prefsWindowClosed:(NSNotification*)notification {
686 [[NSNotificationCenter defaultCenter] 690 NSWindow* window = [prefsController_ window];
687 removeObserver:self 691 DCHECK([notification object] == window);
688 name:kUserDoneEditingPrefsNotification 692 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
689 object:prefsController_.get()]; 693 [defaultCenter removeObserver:self
690 prefsController_.reset(NULL); 694 name:NSWindowWillCloseNotification
695 object:window];
696 // PreferencesWindowControllers are autoreleased in
697 // -[PreferencesWindowController windowWillClose:].
698 prefsController_ = nil;
691 } 699 }
692 700
693 // Show the preferences window, or bring it to the front if it's already 701 // Show the preferences window, or bring it to the front if it's already
694 // visible. 702 // visible.
695 - (IBAction)showPreferences:(id)sender { 703 - (IBAction)showPreferences:(id)sender {
696 [self showPreferencesWindow:sender 704 [self showPreferencesWindow:sender
697 page:OPTIONS_PAGE_DEFAULT 705 page:OPTIONS_PAGE_DEFAULT
698 profile:[self defaultProfile]]; 706 profile:[self defaultProfile]];
699 } 707 }
700 708
701 - (void)showPreferencesWindow:(id)sender 709 - (void)showPreferencesWindow:(id)sender
702 page:(OptionsPage)page 710 page:(OptionsPage)page
703 profile:(Profile*)profile { 711 profile:(Profile*)profile {
704 if (prefsController_.get()) { 712 if (prefsController_) {
705 [prefsController_ switchToPage:page animate:YES]; 713 [prefsController_ switchToPage:page animate:YES];
706 } else { 714 } else {
707 prefsController_.reset([[PreferencesWindowController alloc] 715 prefsController_ =
708 initWithProfile:profile 716 [[PreferencesWindowController alloc] initWithProfile:profile
709 initialPage:page]); 717 initialPage:page];
710 // Watch for a notification of when it goes away so that we can destroy 718 // Watch for a notification of when it goes away so that we can destroy
711 // the controller. 719 // the controller.
712 [[NSNotificationCenter defaultCenter] 720 [[NSNotificationCenter defaultCenter]
713 addObserver:self 721 addObserver:self
714 selector:@selector(prefsWindowClosed:) 722 selector:@selector(prefsWindowClosed:)
715 name:kUserDoneEditingPrefsNotification 723 name:NSWindowWillCloseNotification
716 object:prefsController_.get()]; 724 object:[prefsController_ window]];
717 } 725 }
718 [prefsController_ showPreferences:sender]; 726 [prefsController_ showPreferences:sender];
719 } 727 }
720 728
721 // Called when the about window is closed. We use this to release the 729 // Called when the about window is closed. We use this to release the
722 // window controller. 730 // window controller.
723 - (void)aboutWindowClosed:(NSNotification*)notify { 731 - (void)aboutWindowClosed:(NSNotification*)notification {
732 NSWindow* window = [aboutController_ window];
733 DCHECK(window == [notification object]);
724 [[NSNotificationCenter defaultCenter] 734 [[NSNotificationCenter defaultCenter]
725 removeObserver:self 735 removeObserver:self
726 name:kUserClosedAboutNotification 736 name:NSWindowWillCloseNotification
727 object:aboutController_.get()]; 737 object:window];
728 aboutController_.reset(nil); 738 // AboutWindowControllers are autoreleased in
739 // -[AboutWindowController windowWillClose:].
740 aboutController_ = nil;
729 } 741 }
730 742
731 - (IBAction)orderFrontStandardAboutPanel:(id)sender { 743 - (IBAction)orderFrontStandardAboutPanel:(id)sender {
732 if (!aboutController_) { 744 if (!aboutController_) {
733 aboutController_.reset([[AboutWindowController alloc] 745 aboutController_ =
734 initWithProfile:[self defaultProfile]]); 746 [[AboutWindowController alloc] initWithProfile:[self defaultProfile]];
735 747
736 // Watch for a notification of when it goes away so that we can destroy 748 // Watch for a notification of when it goes away so that we can destroy
737 // the controller. 749 // the controller.
738 [[NSNotificationCenter defaultCenter] 750 [[NSNotificationCenter defaultCenter]
739 addObserver:self 751 addObserver:self
740 selector:@selector(aboutWindowClosed:) 752 selector:@selector(aboutWindowClosed:)
741 name:kUserClosedAboutNotification 753 name:NSWindowWillCloseNotification
742 object:aboutController_.get()]; 754 object:[aboutController_ window]];
743 } 755 }
744 756
745 if (![[aboutController_ window] isVisible]) 757 if (![[aboutController_ window] isVisible])
746 [[aboutController_ window] center]; 758 [[aboutController_ window] center];
747 759
748 [aboutController_ showWindow:self]; 760 [aboutController_ showWindow:self];
749 } 761 }
750 762
751 // Explicitly bring to the foreground when creating new windows from the dock. 763 // Explicitly bring to the foreground when creating new windows from the dock.
752 - (void)newWindowFromDock:(id)sender { 764 - (void)newWindowFromDock:(id)sender {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 [appController showPreferencesWindow:nil page:page profile:profile]; 800 [appController showPreferencesWindow:nil page:page profile:profile];
789 } 801 }
790 802
791 namespace app_controller_mac { 803 namespace app_controller_mac {
792 804
793 bool IsOpeningNewWindow() { 805 bool IsOpeningNewWindow() {
794 return g_is_opening_new_window; 806 return g_is_opening_new_window;
795 } 807 }
796 808
797 } // namespace app_controller_mac 809 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/cocoa/about_ipc_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698