| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 - (void)initMenuState; | 45 - (void)initMenuState; |
| 46 - (void)openURLs:(const std::vector<GURL>&)urls; | 46 - (void)openURLs:(const std::vector<GURL>&)urls; |
| 47 - (void)openPendingURLs; | 47 - (void)openPendingURLs; |
| 48 - (void)getUrl:(NSAppleEventDescriptor*)event | 48 - (void)getUrl:(NSAppleEventDescriptor*)event |
| 49 withReply:(NSAppleEventDescriptor*)reply; | 49 withReply:(NSAppleEventDescriptor*)reply; |
| 50 - (void)openFiles:(NSAppleEventDescriptor*)event | 50 - (void)openFiles:(NSAppleEventDescriptor*)event |
| 51 withReply:(NSAppleEventDescriptor*)reply; | 51 withReply:(NSAppleEventDescriptor*)reply; |
| 52 - (void)windowLayeringDidChange:(NSNotification*)inNotification; | 52 - (void)windowLayeringDidChange:(NSNotification*)inNotification; |
| 53 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; | 53 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; |
| 54 - (BOOL)shouldQuitWithInProgressDownloads; | 54 - (BOOL)shouldQuitWithInProgressDownloads; |
| 55 - (void)showPreferencesWindow:(id)sender |
| 56 page:(OptionsPage)page |
| 57 profile:(Profile*)profile; |
| 55 @end | 58 @end |
| 56 | 59 |
| 57 // True while AppController is calling Browser::OpenEmptyWindow(). We need a | 60 // True while AppController is calling Browser::OpenEmptyWindow(). We need a |
| 58 // global flag here, analogue to BrowserInit::InProcessStartup() because | 61 // global flag here, analogue to BrowserInit::InProcessStartup() because |
| 59 // otherwise the SessionService will try to restore sessions when we make a new | 62 // otherwise the SessionService will try to restore sessions when we make a new |
| 60 // window while there are no other active windows. | 63 // window while there are no other active windows. |
| 61 static bool g_is_opening_new_window = false; | 64 static bool g_is_opening_new_window = false; |
| 62 | 65 |
| 63 @implementation AppController | 66 @implementation AppController |
| 64 | 67 |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 [[NSNotificationCenter defaultCenter] | 682 [[NSNotificationCenter defaultCenter] |
| 680 removeObserver:self | 683 removeObserver:self |
| 681 name:kUserDoneEditingPrefsNotification | 684 name:kUserDoneEditingPrefsNotification |
| 682 object:prefsController_.get()]; | 685 object:prefsController_.get()]; |
| 683 prefsController_.reset(NULL); | 686 prefsController_.reset(NULL); |
| 684 } | 687 } |
| 685 | 688 |
| 686 // Show the preferences window, or bring it to the front if it's already | 689 // Show the preferences window, or bring it to the front if it's already |
| 687 // visible. | 690 // visible. |
| 688 - (IBAction)showPreferences:(id)sender { | 691 - (IBAction)showPreferences:(id)sender { |
| 689 if (!prefsController_.get()) { | 692 [self showPreferencesWindow:sender |
| 693 page:OPTIONS_PAGE_DEFAULT |
| 694 profile:[self defaultProfile]]; |
| 695 } |
| 696 |
| 697 - (void)showPreferencesWindow:(id)sender |
| 698 page:(OptionsPage)page |
| 699 profile:(Profile*)profile { |
| 700 if (prefsController_.get()) { |
| 701 [prefsController_ switchToPage:page animate:YES]; |
| 702 } else { |
| 690 prefsController_.reset([[PreferencesWindowController alloc] | 703 prefsController_.reset([[PreferencesWindowController alloc] |
| 691 initWithProfile:[self defaultProfile]]); | 704 initWithProfile:profile |
| 705 initialPage:page]); |
| 692 // Watch for a notification of when it goes away so that we can destroy | 706 // Watch for a notification of when it goes away so that we can destroy |
| 693 // the controller. | 707 // the controller. |
| 694 [[NSNotificationCenter defaultCenter] | 708 [[NSNotificationCenter defaultCenter] |
| 695 addObserver:self | 709 addObserver:self |
| 696 selector:@selector(prefsWindowClosed:) | 710 selector:@selector(prefsWindowClosed:) |
| 697 name:kUserDoneEditingPrefsNotification | 711 name:kUserDoneEditingPrefsNotification |
| 698 object:prefsController_.get()]; | 712 object:prefsController_.get()]; |
| 699 } | 713 } |
| 700 [prefsController_ showPreferences:sender]; | 714 [prefsController_ showPreferences:sender]; |
| 701 } | 715 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 [item setTag:IDC_NEW_INCOGNITO_WINDOW]; | 769 [item setTag:IDC_NEW_INCOGNITO_WINDOW]; |
| 756 [dockMenu addItem:item]; | 770 [dockMenu addItem:item]; |
| 757 | 771 |
| 758 return dockMenu; | 772 return dockMenu; |
| 759 } | 773 } |
| 760 | 774 |
| 761 @end | 775 @end |
| 762 | 776 |
| 763 //--------------------------------------------------------------------------- | 777 //--------------------------------------------------------------------------- |
| 764 | 778 |
| 765 // Stub for cross-platform method that isn't called on Mac OS X. | |
| 766 void ShowOptionsWindow(OptionsPage page, | 779 void ShowOptionsWindow(OptionsPage page, |
| 767 OptionsGroup highlight_group, | 780 OptionsGroup highlight_group, |
| 768 Profile* profile) { | 781 Profile* profile) { |
| 769 NOTIMPLEMENTED(); | 782 // TODO(akalin): Use highlight_group. |
| 783 AppController* appController = [NSApp delegate]; |
| 784 [appController showPreferencesWindow:nil page:page profile:profile]; |
| 770 } | 785 } |
| 771 | 786 |
| 772 namespace app_controller_mac { | 787 namespace app_controller_mac { |
| 773 | 788 |
| 774 bool IsOpeningNewWindow() { | 789 bool IsOpeningNewWindow() { |
| 775 return g_is_opening_new_window; | 790 return g_is_opening_new_window; |
| 776 } | 791 } |
| 777 | 792 |
| 778 } // namespace app_controller_mac | 793 } // namespace app_controller_mac |
| OLD | NEW |