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/ui/browser.h" | 5 #include "chrome/browser/ui/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 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1783 } | 1783 } |
1784 | 1784 |
1785 void Browser::ShowOptionsTab(const std::string& sub_page) { | 1785 void Browser::ShowOptionsTab(const std::string& sub_page) { |
1786 GURL url(chrome::kChromeUISettingsURL + sub_page); | 1786 GURL url(chrome::kChromeUISettingsURL + sub_page); |
1787 ShowSingletonTab(url, true); | 1787 ShowSingletonTab(url, true); |
1788 } | 1788 } |
1789 | 1789 |
1790 void Browser::OpenClearBrowsingDataDialog() { | 1790 void Browser::OpenClearBrowsingDataDialog() { |
1791 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_ShowDlg"), | 1791 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_ShowDlg"), |
1792 profile_); | 1792 profile_); |
1793 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1793 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1794 switches::kEnableTabbedOptions)) { | 1794 switches::kDisableTabbedOptions)) { |
1795 ShowOptionsTab( | 1795 ShowOptionsTab( |
1796 chrome::kAdvancedOptionsSubPage + std::string(kHashMark) + | 1796 chrome::kAdvancedOptionsSubPage + std::string(kHashMark) + |
1797 chrome::kClearBrowserDataSubPage); | 1797 chrome::kClearBrowserDataSubPage); |
1798 } else { | 1798 } else { |
1799 window_->ShowClearBrowsingDataDialog(); | 1799 window_->ShowClearBrowsingDataDialog(); |
1800 } | 1800 } |
1801 } | 1801 } |
1802 | 1802 |
1803 void Browser::OpenOptionsDialog() { | 1803 void Browser::OpenOptionsDialog() { |
1804 UserMetrics::RecordAction(UserMetricsAction("ShowOptions"), profile_); | 1804 UserMetrics::RecordAction(UserMetricsAction("ShowOptions"), profile_); |
1805 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1805 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1806 switches::kEnableTabbedOptions)) { | 1806 switches::kDisableTabbedOptions)) { |
1807 ShowOptionsTab(chrome::kDefaultOptionsSubPage); | 1807 ShowOptionsTab(chrome::kDefaultOptionsSubPage); |
1808 } else { | 1808 } else { |
1809 ShowOptionsWindow(OPTIONS_PAGE_DEFAULT, OPTIONS_GROUP_NONE, profile_); | 1809 ShowOptionsWindow(OPTIONS_PAGE_DEFAULT, OPTIONS_GROUP_NONE, profile_); |
1810 } | 1810 } |
1811 } | 1811 } |
1812 | 1812 |
1813 void Browser::OpenKeywordEditor() { | 1813 void Browser::OpenKeywordEditor() { |
1814 UserMetrics::RecordAction(UserMetricsAction("EditSearchEngines"), profile_); | 1814 UserMetrics::RecordAction(UserMetricsAction("EditSearchEngines"), profile_); |
1815 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1815 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1816 switches::kEnableTabbedOptions)) { | 1816 switches::kDisableTabbedOptions)) { |
1817 ShowOptionsTab(chrome::kSearchEnginesSubPage); | 1817 ShowOptionsTab(chrome::kSearchEnginesSubPage); |
1818 } else { | 1818 } else { |
1819 window_->ShowSearchEnginesDialog(); | 1819 window_->ShowSearchEnginesDialog(); |
1820 } | 1820 } |
1821 } | 1821 } |
1822 | 1822 |
1823 void Browser::OpenPasswordManager() { | 1823 void Browser::OpenPasswordManager() { |
1824 window_->ShowPasswordManager(); | 1824 window_->ShowPasswordManager(); |
1825 } | 1825 } |
1826 | 1826 |
1827 void Browser::OpenImportSettingsDialog() { | 1827 void Browser::OpenImportSettingsDialog() { |
1828 UserMetrics::RecordAction(UserMetricsAction("Import_ShowDlg"), profile_); | 1828 UserMetrics::RecordAction(UserMetricsAction("Import_ShowDlg"), profile_); |
1829 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1829 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1830 switches::kEnableTabbedOptions)) { | 1830 switches::kDisableTabbedOptions)) { |
1831 ShowOptionsTab( | 1831 ShowOptionsTab( |
1832 chrome::kPersonalOptionsSubPage + std::string(kHashMark) + | 1832 chrome::kPersonalOptionsSubPage + std::string(kHashMark) + |
1833 chrome::kImportDataSubPage); | 1833 chrome::kImportDataSubPage); |
1834 } else { | 1834 } else { |
1835 window_->ShowImportDialog(); | 1835 window_->ShowImportDialog(); |
1836 } | 1836 } |
1837 } | 1837 } |
1838 | 1838 |
1839 void Browser::OpenSyncMyBookmarksDialog() { | 1839 void Browser::OpenSyncMyBookmarksDialog() { |
1840 sync_ui_util::OpenSyncMyBookmarksDialog( | 1840 sync_ui_util::OpenSyncMyBookmarksDialog( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 NEW_FOREGROUND_TAB, PageTransition::LINK); | 1876 NEW_FOREGROUND_TAB, PageTransition::LINK); |
1877 window_->Activate(); | 1877 window_->Activate(); |
1878 } | 1878 } |
1879 | 1879 |
1880 void Browser::OpenAutoFillHelpTabAndActivate() { | 1880 void Browser::OpenAutoFillHelpTabAndActivate() { |
1881 GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kAutofillHelpUrl)); | 1881 GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kAutofillHelpUrl)); |
1882 AddSelectedTabWithURL(help_url, PageTransition::LINK); | 1882 AddSelectedTabWithURL(help_url, PageTransition::LINK); |
1883 } | 1883 } |
1884 | 1884 |
1885 void Browser::OpenSearchEngineOptionsDialog() { | 1885 void Browser::OpenSearchEngineOptionsDialog() { |
1886 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1886 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1887 switches::kEnableTabbedOptions)) { | 1887 switches::kDisableTabbedOptions)) { |
1888 OpenKeywordEditor(); | 1888 OpenKeywordEditor(); |
1889 } else { | 1889 } else { |
1890 ShowOptionsWindow(OPTIONS_PAGE_GENERAL, OPTIONS_GROUP_DEFAULT_SEARCH, | 1890 ShowOptionsWindow(OPTIONS_PAGE_GENERAL, OPTIONS_GROUP_DEFAULT_SEARCH, |
1891 profile_); | 1891 profile_); |
1892 } | 1892 } |
1893 } | 1893 } |
1894 | 1894 |
1895 #if defined(OS_CHROMEOS) | 1895 #if defined(OS_CHROMEOS) |
1896 void Browser::OpenSystemOptionsDialog() { | 1896 void Browser::OpenSystemOptionsDialog() { |
1897 UserMetrics::RecordAction(UserMetricsAction("OpenSystemOptionsDialog"), | 1897 UserMetrics::RecordAction(UserMetricsAction("OpenSystemOptionsDialog"), |
1898 profile_); | 1898 profile_); |
1899 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1899 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1900 switches::kEnableTabbedOptions)) { | 1900 switches::kDisableTabbedOptions)) { |
1901 ShowOptionsTab(chrome::kSystemOptionsSubPage); | 1901 ShowOptionsTab(chrome::kSystemOptionsSubPage); |
1902 } else { | 1902 } else { |
1903 ShowOptionsWindow(OPTIONS_PAGE_SYSTEM, OPTIONS_GROUP_NONE, | 1903 ShowOptionsWindow(OPTIONS_PAGE_SYSTEM, OPTIONS_GROUP_NONE, |
1904 profile_); | 1904 profile_); |
1905 } | 1905 } |
1906 } | 1906 } |
1907 | 1907 |
1908 void Browser::OpenInternetOptionsDialog() { | 1908 void Browser::OpenInternetOptionsDialog() { |
1909 UserMetrics::RecordAction(UserMetricsAction("OpenInternetOptionsDialog"), | 1909 UserMetrics::RecordAction(UserMetricsAction("OpenInternetOptionsDialog"), |
1910 profile_); | 1910 profile_); |
1911 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1911 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1912 switches::kEnableTabbedOptions)) { | 1912 switches::kDisableTabbedOptions)) { |
1913 ShowOptionsTab(chrome::kInternetOptionsSubPage); | 1913 ShowOptionsTab(chrome::kInternetOptionsSubPage); |
1914 } else { | 1914 } else { |
1915 ShowOptionsWindow(OPTIONS_PAGE_INTERNET, OPTIONS_GROUP_DEFAULT_SEARCH, | 1915 ShowOptionsWindow(OPTIONS_PAGE_INTERNET, OPTIONS_GROUP_DEFAULT_SEARCH, |
1916 profile_); | 1916 profile_); |
1917 } | 1917 } |
1918 } | 1918 } |
1919 | 1919 |
1920 void Browser::OpenLanguageOptionsDialog() { | 1920 void Browser::OpenLanguageOptionsDialog() { |
1921 UserMetrics::RecordAction(UserMetricsAction("OpenLanguageOptionsDialog"), | 1921 UserMetrics::RecordAction(UserMetricsAction("OpenLanguageOptionsDialog"), |
1922 profile_); | 1922 profile_); |
1923 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1923 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1924 switches::kEnableTabbedOptions)) { | 1924 switches::kDisableTabbedOptions)) { |
1925 ShowOptionsTab(chrome::kLanguageOptionsSubPage); | 1925 ShowOptionsTab(chrome::kLanguageOptionsSubPage); |
1926 } else { | 1926 } else { |
1927 chromeos::LanguageConfigView::Show(profile_, NULL); | 1927 chromeos::LanguageConfigView::Show(profile_, NULL); |
1928 } | 1928 } |
1929 } | 1929 } |
1930 | 1930 |
1931 void Browser::OpenSystemTabAndActivate() { | 1931 void Browser::OpenSystemTabAndActivate() { |
1932 OpenURL(GURL(chrome::kChromeUISystemInfoURL), GURL(), | 1932 OpenURL(GURL(chrome::kChromeUISystemInfoURL), GURL(), |
1933 NEW_FOREGROUND_TAB, PageTransition::LINK); | 1933 NEW_FOREGROUND_TAB, PageTransition::LINK); |
1934 window_->Activate(); | 1934 window_->Activate(); |
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3105 | 3105 |
3106 void Browser::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 3106 void Browser::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
3107 window()->HandleKeyboardEvent(event); | 3107 window()->HandleKeyboardEvent(event); |
3108 } | 3108 } |
3109 | 3109 |
3110 void Browser::ShowRepostFormWarningDialog(TabContents *tab_contents) { | 3110 void Browser::ShowRepostFormWarningDialog(TabContents *tab_contents) { |
3111 window()->ShowRepostFormWarningDialog(tab_contents); | 3111 window()->ShowRepostFormWarningDialog(tab_contents); |
3112 } | 3112 } |
3113 | 3113 |
3114 void Browser::ShowContentSettingsWindow(ContentSettingsType content_type) { | 3114 void Browser::ShowContentSettingsWindow(ContentSettingsType content_type) { |
3115 if (CommandLine::ForCurrentProcess()->HasSwitch( | 3115 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
3116 switches::kEnableTabbedOptions)) { | 3116 switches::kDisableTabbedOptions)) { |
3117 ShowOptionsTab( | 3117 ShowOptionsTab( |
3118 chrome::kContentSettingsSubPage + std::string(kHashMark) + | 3118 chrome::kContentSettingsSubPage + std::string(kHashMark) + |
3119 ContentSettingsHandler::ContentSettingsTypeToGroupName(content_type)); | 3119 ContentSettingsHandler::ContentSettingsTypeToGroupName(content_type)); |
3120 } else { | 3120 } else { |
3121 window()->ShowContentSettingsWindow(content_type, | 3121 window()->ShowContentSettingsWindow(content_type, |
3122 profile_->GetOriginalProfile()); | 3122 profile_->GetOriginalProfile()); |
3123 } | 3123 } |
3124 } | 3124 } |
3125 | 3125 |
3126 void Browser::ShowCollectedCookiesDialog(TabContents *tab_contents) { | 3126 void Browser::ShowCollectedCookiesDialog(TabContents *tab_contents) { |
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4235 // The page transition below is only for the purpose of inserting the tab. | 4235 // The page transition below is only for the purpose of inserting the tab. |
4236 browser->AddTab(view_source_contents, PageTransition::LINK); | 4236 browser->AddTab(view_source_contents, PageTransition::LINK); |
4237 } | 4237 } |
4238 | 4238 |
4239 if (profile_->HasSessionService()) { | 4239 if (profile_->HasSessionService()) { |
4240 SessionService* session_service = profile_->GetSessionService(); | 4240 SessionService* session_service = profile_->GetSessionService(); |
4241 if (session_service) | 4241 if (session_service) |
4242 session_service->TabRestored(&view_source_contents->controller(), false); | 4242 session_service->TabRestored(&view_source_contents->controller(), false); |
4243 } | 4243 } |
4244 } | 4244 } |
OLD | NEW |