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" | |
Alexei Svitkine (slow)
2014/04/24 18:59:28
Nit: Remove the "This is very temporary" part of t
| |
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 omnibox will stay focused if we | |
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 startupUrls_.clear(); | |
707 } | |
708 | |
709 if (startupIndex != TabStripModel::kNoTab && | |
710 startupContent->GetVisibleURL() == GURL(chrome::kChromeUINewTabURL)) { | |
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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1451 } | 1477 } |
1452 } | 1478 } |
1453 | 1479 |
1454 return dockMenu; | 1480 return dockMenu; |
1455 } | 1481 } |
1456 | 1482 |
1457 - (const std::vector<GURL>&)startupUrls { | 1483 - (const std::vector<GURL>&)startupUrls { |
1458 return startupUrls_; | 1484 return startupUrls_; |
1459 } | 1485 } |
1460 | 1486 |
1461 - (void)clearStartupUrls { | |
1462 startupUrls_.clear(); | |
1463 } | |
1464 | |
1465 - (BookmarkMenuBridge*)bookmarkMenuBridge { | 1487 - (BookmarkMenuBridge*)bookmarkMenuBridge { |
1466 return bookmarkMenuBridge_.get(); | 1488 return bookmarkMenuBridge_.get(); |
1467 } | 1489 } |
1468 | 1490 |
1469 - (void)addObserverForWorkAreaChange:(ui::WorkAreaWatcherObserver*)observer { | 1491 - (void)addObserverForWorkAreaChange:(ui::WorkAreaWatcherObserver*)observer { |
1470 workAreaChangeObservers_.AddObserver(observer); | 1492 workAreaChangeObservers_.AddObserver(observer); |
1471 } | 1493 } |
1472 | 1494 |
1473 - (void)removeObserverForWorkAreaChange:(ui::WorkAreaWatcherObserver*)observer { | 1495 - (void)removeObserverForWorkAreaChange:(ui::WorkAreaWatcherObserver*)observer { |
1474 workAreaChangeObservers_.RemoveObserver(observer); | 1496 workAreaChangeObservers_.RemoveObserver(observer); |
(...skipping 20 matching lines...) Expand all Loading... | |
1495 | 1517 |
1496 //--------------------------------------------------------------------------- | 1518 //--------------------------------------------------------------------------- |
1497 | 1519 |
1498 namespace app_controller_mac { | 1520 namespace app_controller_mac { |
1499 | 1521 |
1500 bool IsOpeningNewWindow() { | 1522 bool IsOpeningNewWindow() { |
1501 return g_is_opening_new_window; | 1523 return g_is_opening_new_window; |
1502 } | 1524 } |
1503 | 1525 |
1504 } // namespace app_controller_mac | 1526 } // namespace app_controller_mac |
OLD | NEW |