OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser.h" | 5 #include "chrome/browser/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 #include "chrome/browser/view_ids.h" | 112 #include "chrome/browser/view_ids.h" |
113 #include "chrome/browser/views/app_launcher.h" | 113 #include "chrome/browser/views/app_launcher.h" |
114 #include "chrome/browser/views/location_bar/location_bar_view.h" | 114 #include "chrome/browser/views/location_bar/location_bar_view.h" |
115 #endif // OS_WIN | 115 #endif // OS_WIN |
116 | 116 |
117 #if defined(OS_MACOSX) | 117 #if defined(OS_MACOSX) |
118 #include "chrome/browser/cocoa/find_pasteboard.h" | 118 #include "chrome/browser/cocoa/find_pasteboard.h" |
119 #endif | 119 #endif |
120 | 120 |
121 #if defined(OS_CHROMEOS) | 121 #if defined(OS_CHROMEOS) |
| 122 #include "chrome/browser/chromeos/options/language_config_view.h" |
122 #include "chrome/browser/views/app_launcher.h" | 123 #include "chrome/browser/views/app_launcher.h" |
123 #endif | 124 #endif |
124 | 125 |
125 using base::TimeDelta; | 126 using base::TimeDelta; |
126 | 127 |
127 // How long we wait before updating the browser chrome while loading a page. | 128 // How long we wait before updating the browser chrome while loading a page. |
128 static const int kUIUpdateCoalescingTimeMS = 200; | 129 static const int kUIUpdateCoalescingTimeMS = 200; |
129 | 130 |
130 // The URL to be loaded to display Help. | 131 // The URL to be loaded to display Help. |
131 static const char* const kHelpContentUrl = | 132 static const char* const kHelpContentUrl = |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 | 663 |
663 // static | 664 // static |
664 void Browser::OpenHelpWindow(Profile* profile) { | 665 void Browser::OpenHelpWindow(Profile* profile) { |
665 Browser* browser = Browser::Create(profile); | 666 Browser* browser = Browser::Create(profile); |
666 browser->OpenHelpTab(); | 667 browser->OpenHelpTab(); |
667 browser->window()->Show(); | 668 browser->window()->Show(); |
668 } | 669 } |
669 | 670 |
670 void Browser::OpenOptionsWindow(Profile* profile) { | 671 void Browser::OpenOptionsWindow(Profile* profile) { |
671 Browser* browser = Browser::Create(profile); | 672 Browser* browser = Browser::Create(profile); |
672 browser->ShowOptionsTab(); | 673 browser->ShowOptionsTab(chrome::kDefaultOptionsSubPage); |
673 browser->window()->Show(); | 674 browser->window()->Show(); |
674 } | 675 } |
675 #endif | 676 #endif |
676 | 677 |
677 // static | 678 // static |
678 void Browser::OpenExtensionsWindow(Profile* profile) { | 679 void Browser::OpenExtensionsWindow(Profile* profile) { |
679 Browser* browser = Browser::Create(profile); | 680 Browser* browser = Browser::Create(profile); |
680 browser->ShowExtensionsTab(); | 681 browser->ShowExtensionsTab(); |
681 browser->window()->Show(); | 682 browser->window()->Show(); |
682 } | 683 } |
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 return; | 1799 return; |
1799 std::string page_url = entry->url().spec(); | 1800 std::string page_url = entry->url().spec(); |
1800 std::vector<std::string> subst; | 1801 std::vector<std::string> subst; |
1801 subst.push_back(UTF16ToASCII(page_title)); | 1802 subst.push_back(UTF16ToASCII(page_title)); |
1802 subst.push_back(page_url); | 1803 subst.push_back(page_url); |
1803 std::string report_page_url = | 1804 std::string report_page_url = |
1804 ReplaceStringPlaceholders(kBrokenPageUrl, subst, NULL); | 1805 ReplaceStringPlaceholders(kBrokenPageUrl, subst, NULL); |
1805 ShowSingletonTab(GURL(report_page_url)); | 1806 ShowSingletonTab(GURL(report_page_url)); |
1806 } | 1807 } |
1807 | 1808 |
1808 void Browser::ShowOptionsTab() { | 1809 void Browser::ShowOptionsTab(const char* sub_page) { |
1809 UserMetrics::RecordAction(UserMetricsAction("ShowOptions"), profile_); | 1810 ShowSingletonTab(GURL(StringPrintf("%s%s", |
1810 ShowSingletonTab(GURL(chrome::kChromeUIOptionsURL)); | 1811 chrome::kChromeUIOptionsURL, |
| 1812 sub_page))); |
1811 } | 1813 } |
1812 | 1814 |
1813 void Browser::OpenClearBrowsingDataDialog() { | 1815 void Browser::OpenClearBrowsingDataDialog() { |
1814 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_ShowDlg"), | 1816 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_ShowDlg"), |
1815 profile_); | 1817 profile_); |
1816 window_->ShowClearBrowsingDataDialog(); | 1818 window_->ShowClearBrowsingDataDialog(); |
1817 } | 1819 } |
1818 | 1820 |
1819 void Browser::OpenOptionsDialog() { | 1821 void Browser::OpenOptionsDialog() { |
| 1822 UserMetrics::RecordAction(UserMetricsAction("ShowOptions"), profile_); |
1820 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1823 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1821 switches::kEnableTabbedOptions)) { | 1824 switches::kEnableTabbedOptions)) { |
1822 ShowOptionsTab(); | 1825 ShowOptionsTab(chrome::kDefaultOptionsSubPage); |
1823 } else { | 1826 } else { |
1824 UserMetrics::RecordAction(UserMetricsAction("ShowOptions"), profile_); | |
1825 ShowOptionsWindow(OPTIONS_PAGE_DEFAULT, OPTIONS_GROUP_NONE, profile_); | 1827 ShowOptionsWindow(OPTIONS_PAGE_DEFAULT, OPTIONS_GROUP_NONE, profile_); |
1826 } | 1828 } |
1827 } | 1829 } |
1828 | 1830 |
1829 void Browser::OpenKeywordEditor() { | 1831 void Browser::OpenKeywordEditor() { |
1830 UserMetrics::RecordAction(UserMetricsAction("EditSearchEngines"), profile_); | 1832 UserMetrics::RecordAction(UserMetricsAction("EditSearchEngines"), profile_); |
1831 window_->ShowSearchEnginesDialog(); | 1833 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1834 switches::kEnableTabbedOptions)) { |
| 1835 ShowOptionsTab(chrome::kSearchEnginesOptionsSubPage); |
| 1836 } else { |
| 1837 window_->ShowSearchEnginesDialog(); |
| 1838 } |
1832 } | 1839 } |
1833 | 1840 |
1834 void Browser::OpenPasswordManager() { | 1841 void Browser::OpenPasswordManager() { |
1835 window_->ShowPasswordManager(); | 1842 window_->ShowPasswordManager(); |
1836 } | 1843 } |
1837 | 1844 |
1838 void Browser::OpenImportSettingsDialog() { | 1845 void Browser::OpenImportSettingsDialog() { |
1839 UserMetrics::RecordAction(UserMetricsAction("Import_ShowDlg"), profile_); | 1846 UserMetrics::RecordAction(UserMetricsAction("Import_ShowDlg"), profile_); |
1840 window_->ShowImportDialog(); | 1847 window_->ShowImportDialog(); |
1841 } | 1848 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); | 1889 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
1883 window_->Activate(); | 1890 window_->Activate(); |
1884 } | 1891 } |
1885 | 1892 |
1886 void Browser::OpenAutoFillHelpTabAndActivate() { | 1893 void Browser::OpenAutoFillHelpTabAndActivate() { |
1887 OpenURL(GURL(l10n_util::GetStringUTF8(IDS_AUTOFILL_HELP_URL)), | 1894 OpenURL(GURL(l10n_util::GetStringUTF8(IDS_AUTOFILL_HELP_URL)), |
1888 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); | 1895 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
1889 window_->Activate(); | 1896 window_->Activate(); |
1890 } | 1897 } |
1891 | 1898 |
| 1899 void Browser::OpenSearchEngineOptionsDialog() { |
| 1900 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1901 switches::kEnableTabbedOptions)) { |
| 1902 OpenKeywordEditor(); |
| 1903 } else { |
| 1904 ShowOptionsWindow(OPTIONS_PAGE_GENERAL, OPTIONS_GROUP_DEFAULT_SEARCH, |
| 1905 profile_); |
| 1906 } |
| 1907 } |
| 1908 |
1892 #if defined(OS_CHROMEOS) | 1909 #if defined(OS_CHROMEOS) |
1893 void Browser::OpenSystemOptionsDialog() { | 1910 void Browser::OpenSystemOptionsDialog() { |
1894 UserMetrics::RecordAction(UserMetricsAction("OpenSystemOptionsDialog"), | 1911 UserMetrics::RecordAction(UserMetricsAction("OpenSystemOptionsDialog"), |
1895 profile_); | 1912 profile_); |
1896 ShowOptionsWindow(OPTIONS_PAGE_SYSTEM, OPTIONS_GROUP_NONE, profile_); | 1913 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1914 switches::kEnableTabbedOptions)) { |
| 1915 ShowOptionsTab(chrome::kSystemOptionsSubPage); |
| 1916 } else { |
| 1917 ShowOptionsWindow(OPTIONS_PAGE_SYSTEM, OPTIONS_GROUP_NONE, |
| 1918 profile_); |
| 1919 } |
1897 } | 1920 } |
1898 | 1921 |
1899 void Browser::OpenInternetOptionsDialog() { | 1922 void Browser::OpenInternetOptionsDialog() { |
1900 UserMetrics::RecordAction(UserMetricsAction("OpenInternetOptionsDialog"), | 1923 UserMetrics::RecordAction(UserMetricsAction("OpenInternetOptionsDialog"), |
1901 profile_); | 1924 profile_); |
1902 ShowOptionsWindow(OPTIONS_PAGE_INTERNET, OPTIONS_GROUP_NONE, profile_); | 1925 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1926 switches::kEnableTabbedOptions)) { |
| 1927 ShowOptionsTab(chrome::kInternetOptionsSubPage); |
| 1928 } else { |
| 1929 ShowOptionsWindow(OPTIONS_PAGE_INTERNET, OPTIONS_GROUP_DEFAULT_SEARCH, |
| 1930 profile_); |
| 1931 } |
| 1932 } |
| 1933 |
| 1934 void Browser::OpenLanguageOptionsDialog() { |
| 1935 UserMetrics::RecordAction(UserMetricsAction("OpenLanguageOptionsDialog"), |
| 1936 profile_); |
| 1937 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1938 switches::kEnableTabbedOptions)) { |
| 1939 ShowOptionsTab(chrome::kLanguageOptionsSubPage); |
| 1940 } else { |
| 1941 chromeos::LanguageConfigView::Show(profile_, NULL); |
| 1942 } |
1903 } | 1943 } |
1904 #endif | 1944 #endif |
1905 | 1945 |
1906 /////////////////////////////////////////////////////////////////////////////// | 1946 /////////////////////////////////////////////////////////////////////////////// |
1907 | 1947 |
1908 // static | 1948 // static |
1909 void Browser::SetNewHomePagePrefs(PrefService* prefs) { | 1949 void Browser::SetNewHomePagePrefs(PrefService* prefs) { |
1910 const PrefService::Preference* home_page_pref = | 1950 const PrefService::Preference* home_page_pref = |
1911 prefs->FindPreference(prefs::kHomePage); | 1951 prefs->FindPreference(prefs::kHomePage); |
1912 if (home_page_pref && | 1952 if (home_page_pref && |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 case IDC_ABOUT: | 2196 case IDC_ABOUT: |
2157 if (Singleton<UpgradeDetector>::get()->notify_upgrade()) | 2197 if (Singleton<UpgradeDetector>::get()->notify_upgrade()) |
2158 OpenUpdateChromeDialog(); | 2198 OpenUpdateChromeDialog(); |
2159 else | 2199 else |
2160 OpenAboutChromeDialog(); | 2200 OpenAboutChromeDialog(); |
2161 break; | 2201 break; |
2162 case IDC_HELP_PAGE: OpenHelpTab(); break; | 2202 case IDC_HELP_PAGE: OpenHelpTab(); break; |
2163 #if defined(OS_CHROMEOS) | 2203 #if defined(OS_CHROMEOS) |
2164 case IDC_SYSTEM_OPTIONS: OpenSystemOptionsDialog(); break; | 2204 case IDC_SYSTEM_OPTIONS: OpenSystemOptionsDialog(); break; |
2165 case IDC_INTERNET_OPTIONS: OpenInternetOptionsDialog(); break; | 2205 case IDC_INTERNET_OPTIONS: OpenInternetOptionsDialog(); break; |
| 2206 case IDC_LANGUAGE_OPTIONS: OpenLanguageOptionsDialog(); break; |
2166 #endif | 2207 #endif |
2167 | 2208 |
2168 default: | 2209 default: |
2169 LOG(WARNING) << "Received Unimplemented Command: " << id; | 2210 LOG(WARNING) << "Received Unimplemented Command: " << id; |
2170 break; | 2211 break; |
2171 } | 2212 } |
2172 } | 2213 } |
2173 | 2214 |
2174 bool Browser::IsReservedCommand(int command_id) { | 2215 bool Browser::IsReservedCommand(int command_id) { |
2175 return command_id == IDC_CLOSE_TAB || | 2216 return command_id == IDC_CLOSE_TAB || |
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4134 } | 4175 } |
4135 | 4176 |
4136 bool Browser::IsPinned(TabContents* source) { | 4177 bool Browser::IsPinned(TabContents* source) { |
4137 int index = tabstrip_model_.GetIndexOfTabContents(source); | 4178 int index = tabstrip_model_.GetIndexOfTabContents(source); |
4138 if (index == TabStripModel::kNoTab) { | 4179 if (index == TabStripModel::kNoTab) { |
4139 NOTREACHED() << "IsPinned called for tab not in our strip"; | 4180 NOTREACHED() << "IsPinned called for tab not in our strip"; |
4140 return false; | 4181 return false; |
4141 } | 4182 } |
4142 return tabstrip_model_.IsTabPinned(index); | 4183 return tabstrip_model_.IsTabPinned(index); |
4143 } | 4184 } |
OLD | NEW |