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 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1754 std::vector<std::string> subst; | 1754 std::vector<std::string> subst; |
1755 subst.push_back(UTF16ToASCII(page_title)); | 1755 subst.push_back(UTF16ToASCII(page_title)); |
1756 subst.push_back(page_url); | 1756 subst.push_back(page_url); |
1757 std::string report_page_url = | 1757 std::string report_page_url = |
1758 ReplaceStringPlaceholders(kBrokenPageUrl, subst, NULL); | 1758 ReplaceStringPlaceholders(kBrokenPageUrl, subst, NULL); |
1759 ShowSingletonTab(GURL(report_page_url)); | 1759 ShowSingletonTab(GURL(report_page_url)); |
1760 } | 1760 } |
1761 | 1761 |
1762 void Browser::ShowOptionsTab(const std::string& sub_page) { | 1762 void Browser::ShowOptionsTab(const std::string& sub_page) { |
1763 GURL url(chrome::kChromeUISettingsURL + sub_page); | 1763 GURL url(chrome::kChromeUISettingsURL + sub_page); |
1764 | 1764 browser::NavigateParams params(this, url, PageTransition::AUTO_BOOKMARK); |
1765 // See if there is already an options tab open that we can use. | 1765 params.disposition = SINGLETON_TAB; |
1766 TabStripModel* model = tab_handler_->GetTabStripModel(); | 1766 params.show_window = true; |
1767 for (int i = 0; i < model->count(); i++) { | 1767 params.ignore_path = true; |
1768 TabContents* tc = model->GetTabContentsAt(i); | 1768 browser::Navigate(¶ms); |
Ben Goodger (Google)
2010/11/17 00:20:45
How about changing Browser::ShowSingletonTab() to
James Hawkins
2010/11/17 00:31:16
Done.
| |
1769 const GURL& tab_url = tc->GetURL(); | |
1770 | |
1771 if (tab_url.scheme() == url.scheme() && tab_url.host() == url.host()) { | |
1772 // We found an existing options tab, load the URL in this tab. (Note: | |
1773 // this may cause us to unnecessarily reload the same page. We can't | |
1774 // really detect that unless the options page is permitted to change the | |
1775 // URL in the address bar, but security policy doesn't allow that. | |
1776 browser::NavigateParams params(this, url, PageTransition::GENERATED); | |
1777 params.source_contents = tc; | |
1778 browser::Navigate(¶ms); | |
1779 model->SelectTabContentsAt(i, false); | |
1780 return; | |
1781 } | |
1782 } | |
1783 | |
1784 // No options tab found, so create a new one. | |
1785 AddSelectedTabWithURL(url, PageTransition::AUTO_BOOKMARK); | |
1786 } | 1769 } |
1787 | 1770 |
1788 void Browser::OpenClearBrowsingDataDialog() { | 1771 void Browser::OpenClearBrowsingDataDialog() { |
1789 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_ShowDlg"), | 1772 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_ShowDlg"), |
1790 profile_); | 1773 profile_); |
1791 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1774 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1792 switches::kEnableTabbedOptions)) { | 1775 switches::kEnableTabbedOptions)) { |
1793 ShowOptionsTab( | 1776 ShowOptionsTab( |
1794 chrome::kAdvancedOptionsSubPage + std::string(kHashMark) + | 1777 chrome::kAdvancedOptionsSubPage + std::string(kHashMark) + |
1795 chrome::kClearBrowserDataSubPage); | 1778 chrome::kClearBrowserDataSubPage); |
(...skipping 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4097 NOTREACHED(); | 4080 NOTREACHED(); |
4098 return false; | 4081 return false; |
4099 } | 4082 } |
4100 | 4083 |
4101 void Browser::CreateInstantIfNecessary() { | 4084 void Browser::CreateInstantIfNecessary() { |
4102 if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) && | 4085 if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) && |
4103 !profile()->IsOffTheRecord()) { | 4086 !profile()->IsOffTheRecord()) { |
4104 instant_.reset(new InstantController(profile_, this)); | 4087 instant_.reset(new InstantController(profile_, this)); |
4105 } | 4088 } |
4106 } | 4089 } |
OLD | NEW |