| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/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/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
| 12 #include "base/mac/mac_util.h" | 12 #include "base/mac/mac_util.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/sys_string_conversions.h" | 15 #include "base/sys_string_conversions.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
| 18 #include "chrome/browser/background/background_application_list_model.h" | 18 #include "chrome/browser/background/background_application_list_model.h" |
| 19 #include "chrome/browser/background/background_mode_manager.h" | 19 #include "chrome/browser/background/background_mode_manager.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/browser_shutdown.h" | 21 #include "chrome/browser/browser_shutdown.h" |
| 22 #include "chrome/browser/command_updater.h" | 22 #include "chrome/browser/command_updater.h" |
| 23 #include "chrome/browser/download/download_service.h" | 23 #include "chrome/browser/download/download_service.h" |
| 24 #include "chrome/browser/download/download_service_factory.h" | 24 #include "chrome/browser/download/download_service_factory.h" |
| 25 #include "chrome/browser/first_run/first_run.h" | 25 #include "chrome/browser/first_run/first_run.h" |
| 26 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" | |
| 27 #include "chrome/browser/lifetime/application_lifetime.h" | 26 #include "chrome/browser/lifetime/application_lifetime.h" |
| 28 #include "chrome/browser/prefs/pref_service.h" | 27 #include "chrome/browser/prefs/pref_service.h" |
| 29 #include "chrome/browser/printing/cloud_print/virtual_driver_install_helper.h" | 28 #include "chrome/browser/printing/cloud_print/virtual_driver_install_helper.h" |
| 30 #include "chrome/browser/printing/print_dialog_cloud.h" | 29 #include "chrome/browser/printing/print_dialog_cloud.h" |
| 31 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
| 32 #include "chrome/browser/service/service_process_control.h" | 31 #include "chrome/browser/service/service_process_control.h" |
| 33 #include "chrome/browser/sessions/session_service.h" | 32 #include "chrome/browser/sessions/session_service.h" |
| 34 #include "chrome/browser/sessions/session_service_factory.h" | 33 #include "chrome/browser/sessions/session_service_factory.h" |
| 35 #include "chrome/browser/sessions/tab_restore_service.h" | 34 #include "chrome/browser/sessions/tab_restore_service.h" |
| 36 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 35 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 37 #include "chrome/browser/sync/profile_sync_service.h" | 36 #include "chrome/browser/sync/profile_sync_service.h" |
| 38 #include "chrome/browser/sync/sync_ui_util.h" | 37 #include "chrome/browser/sync/sync_ui_util.h" |
| 39 #include "chrome/browser/sync/sync_ui_util_mac.h" | 38 #include "chrome/browser/sync/sync_ui_util_mac.h" |
| 40 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
| 41 #include "chrome/browser/ui/browser_commands.h" | 40 #include "chrome/browser/ui/browser_commands.h" |
| 42 #include "chrome/browser/ui/browser_finder.h" | 41 #include "chrome/browser/ui/browser_finder.h" |
| 43 #include "chrome/browser/ui/browser_list.h" | 42 #include "chrome/browser/ui/browser_list.h" |
| 44 #include "chrome/browser/ui/browser_mac.h" | 43 #include "chrome/browser/ui/browser_mac.h" |
| 45 #include "chrome/browser/ui/browser_window.h" | 44 #include "chrome/browser/ui/browser_window.h" |
| 46 #include "chrome/browser/ui/chrome_pages.h" | 45 #include "chrome/browser/ui/chrome_pages.h" |
| 47 #include "chrome/browser/ui/startup/startup_browser_creator.h" | |
| 48 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | |
| 49 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" | 46 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
| 50 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 47 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 51 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 48 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 52 #import "chrome/browser/ui/cocoa/confirm_quit.h" | 49 #import "chrome/browser/ui/cocoa/confirm_quit.h" |
| 53 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" | 50 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" |
| 54 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" | 51 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" |
| 55 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" | 52 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" |
| 53 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
| 56 #import "chrome/browser/ui/cocoa/profile_menu_controller.h" | 54 #import "chrome/browser/ui/cocoa/profile_menu_controller.h" |
| 57 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 55 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
| 58 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" | 56 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" |
| 59 #include "chrome/browser/ui/cocoa/task_manager_mac.h" | 57 #include "chrome/browser/ui/cocoa/task_manager_mac.h" |
| 58 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 59 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 60 #include "chrome/common/chrome_notification_types.h" | 60 #include "chrome/common/chrome_notification_types.h" |
| 61 #include "chrome/common/chrome_paths_internal.h" | 61 #include "chrome/common/chrome_paths_internal.h" |
| 62 #include "chrome/common/chrome_switches.h" | 62 #include "chrome/common/chrome_switches.h" |
| 63 #include "chrome/common/cloud_print/cloud_print_class_mac.h" | 63 #include "chrome/common/cloud_print/cloud_print_class_mac.h" |
| 64 #include "chrome/common/mac/app_mode_common.h" | 64 #include "chrome/common/mac/app_mode_common.h" |
| 65 #include "chrome/common/pref_names.h" | 65 #include "chrome/common/pref_names.h" |
| 66 #include "chrome/common/service_messages.h" | 66 #include "chrome/common/service_messages.h" |
| 67 #include "chrome/common/url_constants.h" | 67 #include "chrome/common/url_constants.h" |
| 68 #include "content/public/browser/browser_thread.h" | 68 #include "content/public/browser/browser_thread.h" |
| 69 #include "content/public/browser/download_manager.h" | 69 #include "content/public/browser/download_manager.h" |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 if (flag && command_line.HasSwitch(switches::kAppId)) | 998 if (flag && command_line.HasSwitch(switches::kAppId)) |
| 999 return YES; | 999 return YES; |
| 1000 | 1000 |
| 1001 // Otherwise open a new window. | 1001 // Otherwise open a new window. |
| 1002 { | 1002 { |
| 1003 AutoReset<bool> auto_reset_in_run(&g_is_opening_new_window, true); | 1003 AutoReset<bool> auto_reset_in_run(&g_is_opening_new_window, true); |
| 1004 int return_code; | 1004 int return_code; |
| 1005 StartupBrowserCreator browser_creator; | 1005 StartupBrowserCreator browser_creator; |
| 1006 browser_creator.LaunchBrowser( | 1006 browser_creator.LaunchBrowser( |
| 1007 command_line, [self lastProfile], FilePath(), | 1007 command_line, [self lastProfile], FilePath(), |
| 1008 browser::startup::IS_NOT_PROCESS_STARTUP, | 1008 chrome::startup::IS_NOT_PROCESS_STARTUP, |
| 1009 browser::startup::IS_NOT_FIRST_RUN, &return_code); | 1009 chrome::startup::IS_NOT_FIRST_RUN, &return_code); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 // We've handled the reopen event, so return NO to tell AppKit not | 1012 // We've handled the reopen event, so return NO to tell AppKit not |
| 1013 // to do anything. | 1013 // to do anything. |
| 1014 return NO; | 1014 return NO; |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 - (void)initMenuState { | 1017 - (void)initMenuState { |
| 1018 menuState_.reset(new CommandUpdater(NULL)); | 1018 menuState_.reset(new CommandUpdater(NULL)); |
| 1019 menuState_->UpdateCommandEnabled(IDC_NEW_TAB, true); | 1019 menuState_->UpdateCommandEnabled(IDC_NEW_TAB, true); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 } | 1104 } |
| 1105 | 1105 |
| 1106 Browser* browser = browser::GetLastActiveBrowser(); | 1106 Browser* browser = browser::GetLastActiveBrowser(); |
| 1107 // if no browser window exists then create one with no tabs to be filled in | 1107 // if no browser window exists then create one with no tabs to be filled in |
| 1108 if (!browser) { | 1108 if (!browser) { |
| 1109 browser = Browser::Create([self lastProfile]); | 1109 browser = Browser::Create([self lastProfile]); |
| 1110 browser->window()->Show(); | 1110 browser->window()->Show(); |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 CommandLine dummy(CommandLine::NO_PROGRAM); | 1113 CommandLine dummy(CommandLine::NO_PROGRAM); |
| 1114 browser::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? | 1114 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? |
| 1115 browser::startup::IS_FIRST_RUN : browser::startup::IS_NOT_FIRST_RUN; | 1115 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; |
| 1116 StartupBrowserCreatorImpl launch(FilePath(), dummy, first_run); | 1116 StartupBrowserCreatorImpl launch(FilePath(), dummy, first_run); |
| 1117 launch.OpenURLsInBrowser(browser, false, urls); | 1117 launch.OpenURLsInBrowser(browser, false, urls); |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 - (void)getUrl:(NSAppleEventDescriptor*)event | 1120 - (void)getUrl:(NSAppleEventDescriptor*)event |
| 1121 withReply:(NSAppleEventDescriptor*)reply { | 1121 withReply:(NSAppleEventDescriptor*)reply { |
| 1122 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject] | 1122 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject] |
| 1123 stringValue]; | 1123 stringValue]; |
| 1124 | 1124 |
| 1125 GURL gurl(base::SysNSStringToUTF8(urlStr)); | 1125 GURL gurl(base::SysNSStringToUTF8(urlStr)); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 | 1321 |
| 1322 } // namespace browser | 1322 } // namespace browser |
| 1323 | 1323 |
| 1324 namespace app_controller_mac { | 1324 namespace app_controller_mac { |
| 1325 | 1325 |
| 1326 bool IsOpeningNewWindow() { | 1326 bool IsOpeningNewWindow() { |
| 1327 return g_is_opening_new_window; | 1327 return g_is_opening_new_window; |
| 1328 } | 1328 } |
| 1329 | 1329 |
| 1330 } // namespace app_controller_mac | 1330 } // namespace app_controller_mac |
| OLD | NEW |