OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/background_application_list_model.h" | 15 #include "chrome/browser/background_application_list_model.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/browser_shutdown.h" | 17 #include "chrome/browser/browser_shutdown.h" |
18 #include "chrome/browser/command_updater.h" | 18 #include "chrome/browser/command_updater.h" |
19 #include "chrome/browser/download/download_manager.h" | 19 #include "chrome/browser/download/download_manager.h" |
| 20 #include "chrome/browser/fonts_languages_window.h" |
20 #include "chrome/browser/metrics/user_metrics.h" | 21 #include "chrome/browser/metrics/user_metrics.h" |
21 #include "chrome/browser/printing/print_job_manager.h" | 22 #include "chrome/browser/printing/print_job_manager.h" |
22 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
23 #include "chrome/browser/sessions/tab_restore_service.h" | 24 #include "chrome/browser/sessions/tab_restore_service.h" |
24 #include "chrome/browser/sync/profile_sync_service.h" | 25 #include "chrome/browser/sync/profile_sync_service.h" |
25 #include "chrome/browser/sync/sync_ui_util.h" | 26 #include "chrome/browser/sync/sync_ui_util.h" |
26 #include "chrome/browser/sync/sync_ui_util_mac.h" | 27 #include "chrome/browser/sync/sync_ui_util_mac.h" |
27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
28 #include "chrome/browser/ui/browser_init.h" | 29 #include "chrome/browser/ui/browser_init.h" |
29 #include "chrome/browser/ui/browser_list.h" | 30 #include "chrome/browser/ui/browser_list.h" |
30 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
31 #import "chrome/browser/ui/cocoa/about_window_controller.h" | 32 #import "chrome/browser/ui/cocoa/about_window_controller.h" |
32 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" | 33 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
33 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 34 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
34 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 35 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
35 #import "chrome/browser/ui/cocoa/bug_report_window_controller.h" | 36 #import "chrome/browser/ui/cocoa/bug_report_window_controller.h" |
36 #import "chrome/browser/ui/cocoa/clear_browsing_data_controller.h" | |
37 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" | 37 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" |
38 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" | 38 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" |
39 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" | 39 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" |
40 #import "chrome/browser/ui/cocoa/importer/import_dialog_cocoa.h" | 40 #import "chrome/browser/ui/cocoa/importer/import_dialog_cocoa.h" |
41 #import "chrome/browser/ui/cocoa/options/preferences_window_controller.h" | |
42 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
43 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" | 42 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" |
44 #include "chrome/browser/ui/cocoa/task_manager_mac.h" | 43 #include "chrome/browser/ui/cocoa/task_manager_mac.h" |
45 #include "chrome/browser/ui/options/options_window.h" | 44 #include "chrome/browser/ui/options/options_window.h" |
46 #include "chrome/common/app_mode_common_mac.h" | 45 #include "chrome/common/app_mode_common_mac.h" |
47 #include "chrome/common/chrome_paths_internal.h" | 46 #include "chrome/common/chrome_paths_internal.h" |
48 #include "chrome/common/chrome_switches.h" | 47 #include "chrome/common/chrome_switches.h" |
49 #include "chrome/common/url_constants.h" | 48 #include "chrome/common/url_constants.h" |
50 #include "content/browser/browser_thread.h" | 49 #include "content/browser/browser_thread.h" |
51 #include "content/browser/tab_contents/tab_contents.h" | 50 #include "content/browser/tab_contents/tab_contents.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 @interface AppController(Private) | 143 @interface AppController(Private) |
145 - (void)initMenuState; | 144 - (void)initMenuState; |
146 - (void)registerServicesMenuTypesTo:(NSApplication*)app; | 145 - (void)registerServicesMenuTypesTo:(NSApplication*)app; |
147 - (void)openUrls:(const std::vector<GURL>&)urls; | 146 - (void)openUrls:(const std::vector<GURL>&)urls; |
148 - (void)getUrl:(NSAppleEventDescriptor*)event | 147 - (void)getUrl:(NSAppleEventDescriptor*)event |
149 withReply:(NSAppleEventDescriptor*)reply; | 148 withReply:(NSAppleEventDescriptor*)reply; |
150 - (void)windowLayeringDidChange:(NSNotification*)inNotification; | 149 - (void)windowLayeringDidChange:(NSNotification*)inNotification; |
151 - (void)checkForAnyKeyWindows; | 150 - (void)checkForAnyKeyWindows; |
152 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; | 151 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; |
153 - (BOOL)shouldQuitWithInProgressDownloads; | 152 - (BOOL)shouldQuitWithInProgressDownloads; |
154 - (void)showPreferencesWindow:(id)sender | |
155 page:(OptionsPage)page | |
156 profile:(Profile*)profile; | |
157 - (void)executeApplication:(id)sender; | 153 - (void)executeApplication:(id)sender; |
158 @end | 154 @end |
159 | 155 |
160 @implementation AppController | 156 @implementation AppController |
161 | 157 |
162 @synthesize startupComplete = startupComplete_; | 158 @synthesize startupComplete = startupComplete_; |
163 | 159 |
164 // This method is called very early in application startup (ie, before | 160 // This method is called very early in application startup (ie, before |
165 // the profile is loaded or any preferences have been registered). Defer any | 161 // the profile is loaded or any preferences have been registered). Defer any |
166 // user-data initialization until -applicationDidFinishLaunching:. | 162 // user-data initialization until -applicationDidFinishLaunching:. |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 gurlVector.push_back(gurl); | 1008 gurlVector.push_back(gurl); |
1013 } | 1009 } |
1014 if (!gurlVector.empty()) | 1010 if (!gurlVector.empty()) |
1015 [self openUrls:gurlVector]; | 1011 [self openUrls:gurlVector]; |
1016 else | 1012 else |
1017 NOTREACHED() << "Nothing to open!"; | 1013 NOTREACHED() << "Nothing to open!"; |
1018 | 1014 |
1019 [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; | 1015 [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; |
1020 } | 1016 } |
1021 | 1017 |
1022 // Called when the preferences window is closed. We use this to release the | |
1023 // window controller. | |
1024 - (void)prefsWindowClosed:(NSNotification*)notification { | |
1025 NSWindow* window = [prefsController_ window]; | |
1026 DCHECK_EQ([notification object], window); | |
1027 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; | |
1028 [defaultCenter removeObserver:self | |
1029 name:NSWindowWillCloseNotification | |
1030 object:window]; | |
1031 // PreferencesWindowControllers are autoreleased in | |
1032 // -[PreferencesWindowController windowWillClose:]. | |
1033 prefsController_ = nil; | |
1034 } | |
1035 | |
1036 // Show the preferences window, or bring it to the front if it's already | 1018 // Show the preferences window, or bring it to the front if it's already |
1037 // visible. | 1019 // visible. |
1038 - (IBAction)showPreferences:(id)sender { | 1020 - (IBAction)showPreferences:(id)sender { |
1039 if (Browser* browser = ActivateBrowser([self defaultProfile])) { | 1021 if (Browser* browser = ActivateBrowser([self defaultProfile])) { |
1040 // Show options tab in the active browser window. | 1022 // Show options tab in the active browser window. |
1041 browser->OpenOptionsDialog(); | 1023 browser->OpenOptionsDialog(); |
1042 } else { | 1024 } else { |
1043 // No browser window, so create one for the options tab. | 1025 // No browser window, so create one for the options tab. |
1044 Browser::OpenOptionsWindow([self defaultProfile]); | 1026 Browser::OpenOptionsWindow([self defaultProfile]); |
1045 } | 1027 } |
1046 } | 1028 } |
1047 | 1029 |
1048 - (void)showPreferencesWindow:(id)sender | |
1049 page:(OptionsPage)page | |
1050 profile:(Profile*)profile { | |
1051 if (prefsController_) { | |
1052 [prefsController_ switchToPage:page animate:YES]; | |
1053 } else { | |
1054 prefsController_ = | |
1055 [[PreferencesWindowController alloc] initWithProfile:profile | |
1056 initialPage:page]; | |
1057 // Watch for a notification of when it goes away so that we can destroy | |
1058 // the controller. | |
1059 [[NSNotificationCenter defaultCenter] | |
1060 addObserver:self | |
1061 selector:@selector(prefsWindowClosed:) | |
1062 name:NSWindowWillCloseNotification | |
1063 object:[prefsController_ window]]; | |
1064 } | |
1065 [prefsController_ showPreferences:sender]; | |
1066 } | |
1067 | |
1068 // Called when the about window is closed. We use this to release the | 1030 // Called when the about window is closed. We use this to release the |
1069 // window controller. | 1031 // window controller. |
1070 - (void)aboutWindowClosed:(NSNotification*)notification { | 1032 - (void)aboutWindowClosed:(NSNotification*)notification { |
1071 NSWindow* window = [aboutController_ window]; | 1033 NSWindow* window = [aboutController_ window]; |
1072 DCHECK_EQ([notification object], window); | 1034 DCHECK_EQ([notification object], window); |
1073 [[NSNotificationCenter defaultCenter] | 1035 [[NSNotificationCenter defaultCenter] |
1074 removeObserver:self | 1036 removeObserver:self |
1075 name:NSWindowWillCloseNotification | 1037 name:NSWindowWillCloseNotification |
1076 object:window]; | 1038 object:window]; |
1077 // AboutWindowControllers are autoreleased in | 1039 // AboutWindowControllers are autoreleased in |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 | 1134 |
1173 @end // @implementation AppController | 1135 @end // @implementation AppController |
1174 | 1136 |
1175 //--------------------------------------------------------------------------- | 1137 //--------------------------------------------------------------------------- |
1176 | 1138 |
1177 void ShowOptionsWindow(OptionsPage page, | 1139 void ShowOptionsWindow(OptionsPage page, |
1178 OptionsGroup highlight_group, | 1140 OptionsGroup highlight_group, |
1179 Profile* profile) { | 1141 Profile* profile) { |
1180 // TODO(akalin): Use highlight_group. | 1142 // TODO(akalin): Use highlight_group. |
1181 AppController* appController = [NSApp delegate]; | 1143 AppController* appController = [NSApp delegate]; |
1182 [appController showPreferencesWindow:nil page:page profile:profile]; | 1144 [appController showPreferences:nil]; |
| 1145 } |
| 1146 |
| 1147 void ShowFontsLanguagesWindow(gfx::NativeWindow window, |
| 1148 FontsLanguagesPage page, |
| 1149 Profile* profile) { |
| 1150 NOTIMPLEMENTED(); |
1183 } | 1151 } |
1184 | 1152 |
1185 namespace app_controller_mac { | 1153 namespace app_controller_mac { |
1186 | 1154 |
1187 bool IsOpeningNewWindow() { | 1155 bool IsOpeningNewWindow() { |
1188 return g_is_opening_new_window; | 1156 return g_is_opening_new_window; |
1189 } | 1157 } |
1190 | 1158 |
1191 } // namespace app_controller_mac | 1159 } // namespace app_controller_mac |
OLD | NEW |