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 "apps/app_shim/extension_app_shim_handler_mac.h" | 7 #include "apps/app_shim/extension_app_shim_handler_mac.h" |
8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "chrome/browser/background/background_mode_manager.h" | 23 #include "chrome/browser/background/background_mode_manager.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/browser_shutdown.h" | 25 #include "chrome/browser/browser_shutdown.h" |
26 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
27 #include "chrome/browser/command_updater.h" | 27 #include "chrome/browser/command_updater.h" |
28 #include "chrome/browser/download/download_service.h" | 28 #include "chrome/browser/download/download_service.h" |
29 #include "chrome/browser/download/download_service_factory.h" | 29 #include "chrome/browser/download/download_service_factory.h" |
30 #include "chrome/browser/extensions/extension_service.h" | 30 #include "chrome/browser/extensions/extension_service.h" |
31 #include "chrome/browser/first_run/first_run.h" | 31 #include "chrome/browser/first_run/first_run.h" |
32 #include "chrome/browser/lifetime/application_lifetime.h" | 32 #include "chrome/browser/lifetime/application_lifetime.h" |
33 #include "chrome/browser/mac/mac_startup_profiler.h" | |
33 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 34 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
34 #include "chrome/browser/profiles/profile_manager.h" | 35 #include "chrome/browser/profiles/profile_manager.h" |
35 #include "chrome/browser/profiles/profiles_state.h" | 36 #include "chrome/browser/profiles/profiles_state.h" |
36 #include "chrome/browser/sessions/session_restore.h" | 37 #include "chrome/browser/sessions/session_restore.h" |
37 #include "chrome/browser/sessions/session_service.h" | 38 #include "chrome/browser/sessions/session_service.h" |
38 #include "chrome/browser/sessions/session_service_factory.h" | 39 #include "chrome/browser/sessions/session_service_factory.h" |
39 #include "chrome/browser/sessions/tab_restore_service.h" | 40 #include "chrome/browser/sessions/tab_restore_service.h" |
40 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 41 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
41 #include "chrome/browser/signin/signin_manager_factory.h" | 42 #include "chrome/browser/signin/signin_manager_factory.h" |
42 #include "chrome/browser/signin/signin_promo.h" | 43 #include "chrome/browser/signin/signin_promo.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 }; | 275 }; |
275 | 276 |
276 @implementation AppController | 277 @implementation AppController |
277 | 278 |
278 @synthesize startupComplete = startupComplete_; | 279 @synthesize startupComplete = startupComplete_; |
279 | 280 |
280 // This method is called very early in application startup (ie, before | 281 // This method is called very early in application startup (ie, before |
281 // the profile is loaded or any preferences have been registered). Defer any | 282 // the profile is loaded or any preferences have been registered). Defer any |
282 // user-data initialization until -applicationDidFinishLaunching:. | 283 // user-data initialization until -applicationDidFinishLaunching:. |
283 - (void)awakeFromNib { | 284 - (void)awakeFromNib { |
285 MacStartupProfiler::GetInstance()->Profile( | |
286 MacStartupProfiler::AWAKE_FROM_NIB); | |
284 // We need to register the handlers early to catch events fired on launch. | 287 // We need to register the handlers early to catch events fired on launch. |
285 NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager]; | 288 NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager]; |
286 [em setEventHandler:self | 289 [em setEventHandler:self |
287 andSelector:@selector(getUrl:withReply:) | 290 andSelector:@selector(getUrl:withReply:) |
288 forEventClass:kInternetEventClass | 291 forEventClass:kInternetEventClass |
289 andEventID:kAEGetURL]; | 292 andEventID:kAEGetURL]; |
290 [em setEventHandler:self | 293 [em setEventHandler:self |
291 andSelector:@selector(getUrl:withReply:) | 294 andSelector:@selector(getUrl:withReply:) |
292 forEventClass:'WWW!' // A particularly ancient AppleEvent that dates | 295 forEventClass:'WWW!' // A particularly ancient AppleEvent that dates |
293 andEventID:'OURL']; // back to the Spyglass days. | 296 andEventID:'OURL']; // back to the Spyglass days. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 andEventID:cloud_print::kAECloudPrintClass]; | 356 andEventID:cloud_print::kAECloudPrintClass]; |
354 [em removeEventHandlerForEventClass:'WWW!' | 357 [em removeEventHandlerForEventClass:'WWW!' |
355 andEventID:'OURL']; | 358 andEventID:'OURL']; |
356 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 359 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
357 [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self]; | 360 [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self]; |
358 } | 361 } |
359 | 362 |
360 // (NSApplicationDelegate protocol) This is the Apple-approved place to override | 363 // (NSApplicationDelegate protocol) This is the Apple-approved place to override |
361 // the default handlers. | 364 // the default handlers. |
362 - (void)applicationWillFinishLaunching:(NSNotification*)notification { | 365 - (void)applicationWillFinishLaunching:(NSNotification*)notification { |
366 MacStartupProfiler::GetInstance()->Profile( | |
367 MacStartupProfiler::WILL_FINISH_LAUNCHING); | |
363 // Nothing here right now. | 368 // Nothing here right now. |
jeremy
2014/07/16 08:19:23
nit: Remove this comment ?
erikchen
2014/07/16 22:00:32
Done.
| |
364 } | 369 } |
365 | 370 |
366 - (BOOL)tryToTerminateApplication:(NSApplication*)app { | 371 - (BOOL)tryToTerminateApplication:(NSApplication*)app { |
367 // Check for in-process downloads, and prompt the user if they really want | 372 // Check for in-process downloads, and prompt the user if they really want |
368 // to quit (and thus cancel downloads). Only check if we're not already | 373 // to quit (and thus cancel downloads). Only check if we're not already |
369 // shutting down, else the user might be prompted multiple times if the | 374 // shutting down, else the user might be prompted multiple times if the |
370 // download isn't stopped before terminate is called again. | 375 // download isn't stopped before terminate is called again. |
371 if (!browser_shutdown::IsTryingToQuit() && | 376 if (!browser_shutdown::IsTryingToQuit() && |
372 ![self shouldQuitWithInProgressDownloads]) | 377 ![self shouldQuitWithInProgressDownloads]) |
373 return NO; | 378 return NO; |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 if (startupIndex != TabStripModel::kNoTab && | 732 if (startupIndex != TabStripModel::kNoTab && |
728 startupContent->GetVisibleURL() == GURL(chrome::kChromeUINewTabURL)) { | 733 startupContent->GetVisibleURL() == GURL(chrome::kChromeUINewTabURL)) { |
729 browser->tab_strip_model()->CloseWebContentsAt(startupIndex, | 734 browser->tab_strip_model()->CloseWebContentsAt(startupIndex, |
730 TabStripModel::CLOSE_NONE); | 735 TabStripModel::CLOSE_NONE); |
731 } | 736 } |
732 } | 737 } |
733 | 738 |
734 // This is called after profiles have been loaded and preferences registered. | 739 // This is called after profiles have been loaded and preferences registered. |
735 // It is safe to access the default profile here. | 740 // It is safe to access the default profile here. |
736 - (void)applicationDidFinishLaunching:(NSNotification*)notify { | 741 - (void)applicationDidFinishLaunching:(NSNotification*)notify { |
742 MacStartupProfiler::GetInstance()->Profile( | |
743 MacStartupProfiler::DID_FINISH_LAUNCHING); | |
744 MacStartupProfiler::GetInstance()->RecordMetrics(); | |
745 | |
737 // Notify BrowserList to keep the application running so it doesn't go away | 746 // Notify BrowserList to keep the application running so it doesn't go away |
738 // when all the browser windows get closed. | 747 // when all the browser windows get closed. |
739 chrome::IncrementKeepAliveCount(); | 748 chrome::IncrementKeepAliveCount(); |
740 | 749 |
741 [self setUpdateCheckInterval]; | 750 [self setUpdateCheckInterval]; |
742 | 751 |
743 // Start managing the menu for app windows. This needs to be done here because | 752 // Start managing the menu for app windows. This needs to be done here because |
744 // main menu item titles are not yet initialized in awakeFromNib. | 753 // main menu item titles are not yet initialized in awakeFromNib. |
745 [self initAppShimMenuController]; | 754 [self initAppShimMenuController]; |
746 | 755 |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1537 | 1546 |
1538 //--------------------------------------------------------------------------- | 1547 //--------------------------------------------------------------------------- |
1539 | 1548 |
1540 namespace app_controller_mac { | 1549 namespace app_controller_mac { |
1541 | 1550 |
1542 bool IsOpeningNewWindow() { | 1551 bool IsOpeningNewWindow() { |
1543 return g_is_opening_new_window; | 1552 return g_is_opening_new_window; |
1544 } | 1553 } |
1545 | 1554 |
1546 } // namespace app_controller_mac | 1555 } // namespace app_controller_mac |
OLD | NEW |