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 #include "chrome/browser/ui/browser_init.h" | 5 #include "chrome/browser/ui/browser_init.h" |
6 | 6 |
7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1713 if (process_startup) { | 1713 if (process_startup) { |
1714 if (command_line.HasSwitch(switches::kDisablePromptOnRepost)) | 1714 if (command_line.HasSwitch(switches::kDisablePromptOnRepost)) |
1715 content::NavigationController::DisablePromptOnRepost(); | 1715 content::NavigationController::DisablePromptOnRepost(); |
1716 | 1716 |
1717 #if defined(OS_CHROMEOS) | 1717 #if defined(OS_CHROMEOS) |
1718 // crosbug.com/26446. | 1718 // crosbug.com/26446. |
1719 LOG(ERROR) << "RegisterComponentsForUpdate"; | 1719 LOG(ERROR) << "RegisterComponentsForUpdate"; |
1720 #endif | 1720 #endif |
1721 RegisterComponentsForUpdate(command_line); | 1721 RegisterComponentsForUpdate(command_line); |
1722 | 1722 |
1723 #if defined(ENABLE_AUTOMATION) | |
1723 // Look for the testing channel ID ONLY during process startup | 1724 // Look for the testing channel ID ONLY during process startup |
1724 if (command_line.HasSwitch(switches::kTestingChannelID)) { | 1725 if (command_line.HasSwitch(switches::kTestingChannelID)) { |
1725 std::string testing_channel_id = command_line.GetSwitchValueASCII( | 1726 std::string testing_channel_id = command_line.GetSwitchValueASCII( |
1726 switches::kTestingChannelID); | 1727 switches::kTestingChannelID); |
1727 // TODO(sanjeevr) Check if we need to make this a singleton for | 1728 // TODO(sanjeevr) Check if we need to make this a singleton for |
1728 // compatibility with the old testing code | 1729 // compatibility with the old testing code |
1729 // If there are any extra parameters, we expect each one to generate a | 1730 // If there are any extra parameters, we expect each one to generate a |
1730 // new tab; if there are none then we get one homepage tab. | 1731 // new tab; if there are none then we get one homepage tab. |
1731 int expected_tab_count = 1; | 1732 int expected_tab_count = 1; |
1732 if (command_line.HasSwitch(switches::kNoStartupWindow)) { | 1733 if (command_line.HasSwitch(switches::kNoStartupWindow)) { |
(...skipping 17 matching lines...) Expand all Loading... | |
1750 #if defined(OS_CHROMEOS) | 1751 #if defined(OS_CHROMEOS) |
1751 // crosbug.com/26446. | 1752 // crosbug.com/26446. |
1752 LOG(ERROR) << "CreatingAutomationProvider"; | 1753 LOG(ERROR) << "CreatingAutomationProvider"; |
1753 #endif | 1754 #endif |
1754 if (!CreateAutomationProvider<TestingAutomationProvider>( | 1755 if (!CreateAutomationProvider<TestingAutomationProvider>( |
1755 testing_channel_id, | 1756 testing_channel_id, |
1756 last_used_profile, | 1757 last_used_profile, |
1757 static_cast<size_t>(expected_tab_count))) | 1758 static_cast<size_t>(expected_tab_count))) |
1758 return false; | 1759 return false; |
1759 } | 1760 } |
1761 #endif // enabled(ENABLE_AUTOMATION) | |
1760 } | 1762 } |
1761 | 1763 |
1762 bool silent_launch = false; | 1764 bool silent_launch = false; |
jam
2012/03/14 17:48:13
nit: move this to line 1723 and then you can have
Xianzhu
2012/03/14 18:02:31
Done (with if (process_startup) also merged into t
| |
1763 | 1765 |
1766 #if defined(ENABLE_AUTOMATION) | |
1764 if (command_line.HasSwitch(switches::kAutomationClientChannelID)) { | 1767 if (command_line.HasSwitch(switches::kAutomationClientChannelID)) { |
1765 std::string automation_channel_id = command_line.GetSwitchValueASCII( | 1768 std::string automation_channel_id = command_line.GetSwitchValueASCII( |
1766 switches::kAutomationClientChannelID); | 1769 switches::kAutomationClientChannelID); |
1767 // If there are any extra parameters, we expect each one to generate a | 1770 // If there are any extra parameters, we expect each one to generate a |
1768 // new tab; if there are none then we have no tabs | 1771 // new tab; if there are none then we have no tabs |
1769 std::vector<GURL> urls_to_open = GetURLsFromCommandLine( | 1772 std::vector<GURL> urls_to_open = GetURLsFromCommandLine( |
1770 command_line, cur_dir, last_used_profile); | 1773 command_line, cur_dir, last_used_profile); |
1771 size_t expected_tabs = | 1774 size_t expected_tabs = |
1772 std::max(static_cast<int>(urls_to_open.size()), 0); | 1775 std::max(static_cast<int>(urls_to_open.size()), 0); |
1773 if (expected_tabs == 0) | 1776 if (expected_tabs == 0) |
1774 silent_launch = true; | 1777 silent_launch = true; |
1775 | 1778 |
1776 if (command_line.HasSwitch(switches::kChromeFrame)) { | 1779 if (command_line.HasSwitch(switches::kChromeFrame)) { |
1777 #if !defined(USE_AURA) | 1780 #if !defined(USE_AURA) |
1778 if (!CreateAutomationProvider<ChromeFrameAutomationProvider>( | 1781 if (!CreateAutomationProvider<ChromeFrameAutomationProvider>( |
1779 automation_channel_id, last_used_profile, expected_tabs)) | 1782 automation_channel_id, last_used_profile, expected_tabs)) |
1780 return false; | 1783 return false; |
1781 #endif | 1784 #endif |
1782 } else { | 1785 } else { |
1783 if (!CreateAutomationProvider<AutomationProvider>( | 1786 if (!CreateAutomationProvider<AutomationProvider>( |
1784 automation_channel_id, last_used_profile, expected_tabs)) | 1787 automation_channel_id, last_used_profile, expected_tabs)) |
1785 return false; | 1788 return false; |
1786 } | 1789 } |
1787 } | 1790 } |
1791 #endif // defined(ENABLE_AUTOMATION) | |
1788 | 1792 |
1789 // If we have been invoked to display a desktop notification on behalf of | 1793 // If we have been invoked to display a desktop notification on behalf of |
1790 // the service process, we do not want to open any browser windows. | 1794 // the service process, we do not want to open any browser windows. |
1791 if (command_line.HasSwitch(switches::kNotifyCloudPrintTokenExpired)) { | 1795 if (command_line.HasSwitch(switches::kNotifyCloudPrintTokenExpired)) { |
1792 silent_launch = true; | 1796 silent_launch = true; |
1793 CloudPrintProxyServiceFactory::GetForProfile(last_used_profile)-> | 1797 CloudPrintProxyServiceFactory::GetForProfile(last_used_profile)-> |
1794 ShowTokenExpiredNotification(); | 1798 ShowTokenExpiredNotification(); |
1795 } | 1799 } |
1796 | 1800 |
1797 // If we are just displaying a print dialog we shouldn't open browser | 1801 // If we are just displaying a print dialog we shouldn't open browser |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1898 } | 1902 } |
1899 } | 1903 } |
1900 } | 1904 } |
1901 return true; | 1905 return true; |
1902 } | 1906 } |
1903 | 1907 |
1904 template <class AutomationProviderClass> | 1908 template <class AutomationProviderClass> |
1905 bool BrowserInit::CreateAutomationProvider(const std::string& channel_id, | 1909 bool BrowserInit::CreateAutomationProvider(const std::string& channel_id, |
1906 Profile* profile, | 1910 Profile* profile, |
1907 size_t expected_tabs) { | 1911 size_t expected_tabs) { |
1912 #if defined(ENABLE_AUTOMATION) | |
1908 scoped_refptr<AutomationProviderClass> automation = | 1913 scoped_refptr<AutomationProviderClass> automation = |
1909 new AutomationProviderClass(profile); | 1914 new AutomationProviderClass(profile); |
1910 #if defined(OS_CHROMEOS) | 1915 #if defined(OS_CHROMEOS) |
1911 // crosbug.com/26446. | 1916 // crosbug.com/26446. |
1912 LOG(ERROR) << "CreateAutomationProvider: channel=" << channel_id; | 1917 LOG(ERROR) << "CreateAutomationProvider: channel=" << channel_id; |
1913 #endif | 1918 #endif |
1914 if (!automation->InitializeChannel(channel_id)) | 1919 if (!automation->InitializeChannel(channel_id)) |
1915 return false; | 1920 return false; |
1916 automation->SetExpectedTabCount(expected_tabs); | 1921 automation->SetExpectedTabCount(expected_tabs); |
1917 | 1922 |
1918 AutomationProviderList* list = g_browser_process->GetAutomationProviderList(); | 1923 AutomationProviderList* list = g_browser_process->GetAutomationProviderList(); |
1919 DCHECK(list); | 1924 DCHECK(list); |
1920 list->AddProvider(automation); | 1925 list->AddProvider(automation); |
1926 #endif // defined(ENABLE_AUTOMATION) | |
1921 | 1927 |
1922 return true; | 1928 return true; |
1923 } | 1929 } |
1924 | 1930 |
1925 // static | 1931 // static |
1926 void BrowserInit::ProcessCommandLineOnProfileCreated( | 1932 void BrowserInit::ProcessCommandLineOnProfileCreated( |
1927 const CommandLine& cmd_line, | 1933 const CommandLine& cmd_line, |
1928 const FilePath& cur_dir, | 1934 const FilePath& cur_dir, |
1929 Profile* profile, | 1935 Profile* profile, |
1930 Profile::CreateStatus status) { | 1936 Profile::CreateStatus status) { |
(...skipping 17 matching lines...) Expand all Loading... | |
1948 | 1954 |
1949 Profile* profile = ProfileManager::GetLastUsedProfile(); | 1955 Profile* profile = ProfileManager::GetLastUsedProfile(); |
1950 if (!profile) { | 1956 if (!profile) { |
1951 // We should only be able to get here if the profile already exists and | 1957 // We should only be able to get here if the profile already exists and |
1952 // has been created. | 1958 // has been created. |
1953 NOTREACHED(); | 1959 NOTREACHED(); |
1954 return; | 1960 return; |
1955 } | 1961 } |
1956 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); | 1962 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); |
1957 } | 1963 } |
OLD | NEW |