Chromium Code Reviews| 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/app_shim_mac.h" | 7 #include "apps/app_shim/app_shim_mac.h" |
| 8 #include "apps/app_shim/extension_app_shim_handler_mac.h" | 8 #include "apps/app_shim/extension_app_shim_handler_mac.h" |
| 9 #include "apps/app_window_registry.h" | 9 #include "apps/app_window_registry.h" |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 674 CFPropertyListRef plist = CFPreferencesCopyAppValue(checkInterval, app); | 674 CFPropertyListRef plist = CFPreferencesCopyAppValue(checkInterval, app); |
| 675 if (!plist) { | 675 if (!plist) { |
| 676 const float fiveHoursInSeconds = 5.0 * 60.0 * 60.0; | 676 const float fiveHoursInSeconds = 5.0 * 60.0 * 60.0; |
| 677 NSNumber* value = [NSNumber numberWithFloat:fiveHoursInSeconds]; | 677 NSNumber* value = [NSNumber numberWithFloat:fiveHoursInSeconds]; |
| 678 CFPreferencesSetAppValue(checkInterval, value, app); | 678 CFPreferencesSetAppValue(checkInterval, value, app); |
| 679 CFPreferencesAppSynchronize(app); | 679 CFPreferencesAppSynchronize(app); |
| 680 } | 680 } |
| 681 #endif | 681 #endif |
| 682 } | 682 } |
| 683 | 683 |
| 684 - (void)openStartupUrls { | |
| 685 // TODO(viettrungluu): This is very temporary, since this should be done "in" | |
| 686 // |BrowserMain()|, i.e., this list of startup URLs should be appended to the | |
| 687 // (probably-empty) list of URLs from the command line. | |
| 688 if (startupUrls_.empty()) | |
| 689 return; | |
| 690 | |
| 691 // The browser is already loaded at this point. | |
| 692 // If there's only 1 tab and the tab is NTP, close this NTP tab and open all | |
| 693 // startup urls in new tabs, because the omnibar will stay focused if we | |
|
Alexei Svitkine (slow)
2014/04/22 15:42:00
Nit: omnibox
| |
| 694 // load url in NTP tab. | |
| 695 Browser* browser = chrome::GetLastActiveBrowser(); | |
| 696 int startupIndex = TabStripModel::kNoTab; | |
| 697 content::WebContents* startupContent = NULL; | |
| 698 | |
| 699 if (browser && browser->tab_strip_model()->count() == 1) { | |
| 700 startupIndex = browser->tab_strip_model()->active_index(); | |
| 701 startupContent = browser->tab_strip_model()->GetActiveWebContents(); | |
| 702 } | |
| 703 | |
| 704 if (startupUrls_.size()) { | |
| 705 [self openUrls:startupUrls_]; | |
| 706 [self clearStartupUrls]; | |
|
Alexei Svitkine (slow)
2014/04/22 15:42:00
Doesn't seem like -clearStartupUrls is used from a
| |
| 707 } | |
| 708 | |
| 709 if (startupIndex != TabStripModel::kNoTab && | |
| 710 startupContent->GetVisibleURL() == GURL(chrome::kChromeUINewTabURL)) { | |
|
Alexei Svitkine (slow)
2014/04/22 15:42:00
I see other code doing the following check instead
wjywbs
2014/04/22 21:51:51
I tested this current method with a NTP override e
| |
| 711 browser->tab_strip_model()->CloseWebContentsAt(startupIndex, | |
| 712 TabStripModel::CLOSE_NONE); | |
| 713 } | |
| 714 } | |
| 715 | |
| 684 // This is called after profiles have been loaded and preferences registered. | 716 // This is called after profiles have been loaded and preferences registered. |
| 685 // It is safe to access the default profile here. | 717 // It is safe to access the default profile here. |
| 686 - (void)applicationDidFinishLaunching:(NSNotification*)notify { | 718 - (void)applicationDidFinishLaunching:(NSNotification*)notify { |
| 687 // Notify BrowserList to keep the application running so it doesn't go away | 719 // Notify BrowserList to keep the application running so it doesn't go away |
| 688 // when all the browser windows get closed. | 720 // when all the browser windows get closed. |
| 689 chrome::IncrementKeepAliveCount(); | 721 chrome::IncrementKeepAliveCount(); |
| 690 | 722 |
| 691 [self setUpdateCheckInterval]; | 723 [self setUpdateCheckInterval]; |
| 692 | 724 |
| 693 // Start managing the menu for app windows. This needs to be done here because | 725 // Start managing the menu for app windows. This needs to be done here because |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 718 // I/O. | 750 // I/O. |
| 719 BrowserThread::PostTask( | 751 BrowserThread::PostTask( |
| 720 BrowserThread::FILE, FROM_HERE, | 752 BrowserThread::FILE, FROM_HERE, |
| 721 base::Bind(&RecordLastRunAppBundlePath)); | 753 base::Bind(&RecordLastRunAppBundlePath)); |
| 722 | 754 |
| 723 // Makes "Services" menu items available. | 755 // Makes "Services" menu items available. |
| 724 [self registerServicesMenuTypesTo:[notify object]]; | 756 [self registerServicesMenuTypesTo:[notify object]]; |
| 725 | 757 |
| 726 startupComplete_ = YES; | 758 startupComplete_ = YES; |
| 727 | 759 |
| 728 // TODO(viettrungluu): This is very temporary, since this should be done "in" | 760 [self openStartupUrls]; |
| 729 // |BrowserMain()|, i.e., this list of startup URLs should be appended to the | |
| 730 // (probably-empty) list of URLs from the command line. | |
| 731 if (startupUrls_.size()) { | |
| 732 [self openUrls:startupUrls_]; | |
| 733 [self clearStartupUrls]; | |
| 734 } | |
| 735 | 761 |
| 736 PrefService* localState = g_browser_process->local_state(); | 762 PrefService* localState = g_browser_process->local_state(); |
| 737 if (localState) { | 763 if (localState) { |
| 738 localPrefRegistrar_.Init(localState); | 764 localPrefRegistrar_.Init(localState); |
| 739 localPrefRegistrar_.Add( | 765 localPrefRegistrar_.Add( |
| 740 prefs::kAllowFileSelectionDialogs, | 766 prefs::kAllowFileSelectionDialogs, |
| 741 base::Bind(&chrome::BrowserCommandController::UpdateOpenFileState, | 767 base::Bind(&chrome::BrowserCommandController::UpdateOpenFileState, |
| 742 menuState_.get())); | 768 menuState_.get())); |
| 743 } | 769 } |
| 744 } | 770 } |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1495 | 1521 |
| 1496 //--------------------------------------------------------------------------- | 1522 //--------------------------------------------------------------------------- |
| 1497 | 1523 |
| 1498 namespace app_controller_mac { | 1524 namespace app_controller_mac { |
| 1499 | 1525 |
| 1500 bool IsOpeningNewWindow() { | 1526 bool IsOpeningNewWindow() { |
| 1501 return g_is_opening_new_window; | 1527 return g_is_opening_new_window; |
| 1502 } | 1528 } |
| 1503 | 1529 |
| 1504 } // namespace app_controller_mac | 1530 } // namespace app_controller_mac |
| OLD | NEW |