| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // OS_WIN | 10 #endif // OS_WIN |
| (...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 } | 966 } |
| 967 | 967 |
| 968 SkBitmap Browser::GetCurrentPageIcon() const { | 968 SkBitmap Browser::GetCurrentPageIcon() const { |
| 969 TabContentsWrapper* contents = GetSelectedTabContentsWrapper(); | 969 TabContentsWrapper* contents = GetSelectedTabContentsWrapper(); |
| 970 // |contents| can be NULL since GetCurrentPageIcon() is called by the window | 970 // |contents| can be NULL since GetCurrentPageIcon() is called by the window |
| 971 // during the window's creation (before tabs have been added). | 971 // during the window's creation (before tabs have been added). |
| 972 return contents ? contents->favicon_tab_helper()->GetFavicon() : SkBitmap(); | 972 return contents ? contents->favicon_tab_helper()->GetFavicon() : SkBitmap(); |
| 973 } | 973 } |
| 974 | 974 |
| 975 string16 Browser::GetWindowTitleForCurrentTab() const { | 975 string16 Browser::GetWindowTitleForCurrentTab() const { |
| 976 TabContents* contents = GetSelectedTabContents(); | 976 WebContents* contents = GetSelectedWebContents(); |
| 977 string16 title; | 977 string16 title; |
| 978 | 978 |
| 979 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the | 979 // |contents| can be NULL because GetWindowTitleForCurrentTab is called by the |
| 980 // window during the window's creation (before tabs have been added). | 980 // window during the window's creation (before tabs have been added). |
| 981 if (contents) { | 981 if (contents) { |
| 982 title = contents->GetTitle(); | 982 title = contents->GetTitle(); |
| 983 FormatTitleForDisplay(&title); | 983 FormatTitleForDisplay(&title); |
| 984 } | 984 } |
| 985 if (title.empty()) | 985 if (title.empty()) |
| 986 title = CoreTabHelper::GetDefaultTitle(); | 986 title = CoreTabHelper::GetDefaultTitle(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 chrome::NOTIFICATION_BROWSER_CLOSING, | 1073 chrome::NOTIFICATION_BROWSER_CLOSING, |
| 1074 content::Source<Browser>(this), | 1074 content::Source<Browser>(this), |
| 1075 content::Details<bool>(&exiting)); | 1075 content::Details<bool>(&exiting)); |
| 1076 | 1076 |
| 1077 CloseAllTabs(); | 1077 CloseAllTabs(); |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 void Browser::OnWindowActivated() { | 1080 void Browser::OnWindowActivated() { |
| 1081 // On some platforms we want to automatically reload tabs that are | 1081 // On some platforms we want to automatically reload tabs that are |
| 1082 // killed when the user selects them. | 1082 // killed when the user selects them. |
| 1083 TabContents* contents = GetSelectedTabContents(); | 1083 WebContents* contents = GetSelectedWebContents(); |
| 1084 if (contents && contents->GetCrashedStatus() == | 1084 if (contents && contents->GetCrashedStatus() == |
| 1085 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 1085 base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { |
| 1086 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1086 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1087 switches::kReloadKilledTabs)) { | 1087 switches::kReloadKilledTabs)) { |
| 1088 Reload(CURRENT_TAB); | 1088 Reload(CURRENT_TAB); |
| 1089 } | 1089 } |
| 1090 } | 1090 } |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 //////////////////////////////////////////////////////////////////////////////// | 1093 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 | 1180 |
| 1181 int Browser::GetIndexOfController( | 1181 int Browser::GetIndexOfController( |
| 1182 const NavigationController* controller) const { | 1182 const NavigationController* controller) const { |
| 1183 return tab_handler_->GetTabStripModel()->GetIndexOfController(controller); | 1183 return tab_handler_->GetTabStripModel()->GetIndexOfController(controller); |
| 1184 } | 1184 } |
| 1185 | 1185 |
| 1186 TabContentsWrapper* Browser::GetSelectedTabContentsWrapper() const { | 1186 TabContentsWrapper* Browser::GetSelectedTabContentsWrapper() const { |
| 1187 return tabstrip_model()->GetActiveTabContents(); | 1187 return tabstrip_model()->GetActiveTabContents(); |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 WebContents* Browser::GetSelectedWebContents() const { |
| 1191 TabContentsWrapper* wrapper = GetSelectedTabContentsWrapper(); |
| 1192 return wrapper ? wrapper->web_contents() : NULL; |
| 1193 } |
| 1194 |
| 1190 TabContentsWrapper* Browser::GetTabContentsWrapperAt(int index) const { | 1195 TabContentsWrapper* Browser::GetTabContentsWrapperAt(int index) const { |
| 1191 return tabstrip_model()->GetTabContentsAt(index); | 1196 return tabstrip_model()->GetTabContentsAt(index); |
| 1192 } | 1197 } |
| 1193 | 1198 |
| 1194 TabContents* Browser::GetSelectedTabContents() const { | 1199 TabContents* Browser::GetSelectedTabContents() const { |
| 1195 TabContentsWrapper* wrapper = GetSelectedTabContentsWrapper(); | 1200 TabContentsWrapper* wrapper = GetSelectedTabContentsWrapper(); |
| 1196 if (wrapper) | 1201 if (wrapper) |
| 1197 return wrapper->tab_contents(); | 1202 return wrapper->tab_contents(); |
| 1198 return NULL; | 1203 return NULL; |
| 1199 } | 1204 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 | 1405 |
| 1401 void Browser::ShowSingletonTabRespectRef(const GURL& url) { | 1406 void Browser::ShowSingletonTabRespectRef(const GURL& url) { |
| 1402 browser::NavigateParams params(GetSingletonTabNavigateParams(url)); | 1407 browser::NavigateParams params(GetSingletonTabNavigateParams(url)); |
| 1403 params.ref_behavior = browser::NavigateParams::RESPECT_REF; | 1408 params.ref_behavior = browser::NavigateParams::RESPECT_REF; |
| 1404 browser::Navigate(¶ms); | 1409 browser::Navigate(¶ms); |
| 1405 } | 1410 } |
| 1406 | 1411 |
| 1407 void Browser::ShowSingletonTabOverwritingNTP( | 1412 void Browser::ShowSingletonTabOverwritingNTP( |
| 1408 const browser::NavigateParams& params) { | 1413 const browser::NavigateParams& params) { |
| 1409 browser::NavigateParams local_params(params); | 1414 browser::NavigateParams local_params(params); |
| 1410 TabContents* contents = GetSelectedTabContents(); | 1415 WebContents* contents = GetSelectedWebContents(); |
| 1411 if (contents) { | 1416 if (contents) { |
| 1412 const GURL& contents_url = contents->GetURL(); | 1417 const GURL& contents_url = contents->GetURL(); |
| 1413 if ((contents_url == GURL(chrome::kChromeUINewTabURL) || | 1418 if ((contents_url == GURL(chrome::kChromeUINewTabURL) || |
| 1414 contents_url == GURL(chrome::kAboutBlankURL)) && | 1419 contents_url == GURL(chrome::kAboutBlankURL)) && |
| 1415 browser::GetIndexOfSingletonTab(&local_params) < 0) { | 1420 browser::GetIndexOfSingletonTab(&local_params) < 0) { |
| 1416 local_params.disposition = CURRENT_TAB; | 1421 local_params.disposition = CURRENT_TAB; |
| 1417 } | 1422 } |
| 1418 } | 1423 } |
| 1419 | 1424 |
| 1420 browser::Navigate(&local_params); | 1425 browser::Navigate(&local_params); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 } | 1545 } |
| 1541 | 1546 |
| 1542 void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) { | 1547 void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) { |
| 1543 content::RecordAction(UserMetricsAction("ReloadIgnoringCache")); | 1548 content::RecordAction(UserMetricsAction("ReloadIgnoringCache")); |
| 1544 ReloadInternal(disposition, true); | 1549 ReloadInternal(disposition, true); |
| 1545 } | 1550 } |
| 1546 | 1551 |
| 1547 void Browser::ReloadInternal(WindowOpenDisposition disposition, | 1552 void Browser::ReloadInternal(WindowOpenDisposition disposition, |
| 1548 bool ignore_cache) { | 1553 bool ignore_cache) { |
| 1549 // If we are showing an interstitial, treat this as an OpenURL. | 1554 // If we are showing an interstitial, treat this as an OpenURL. |
| 1550 TabContents* current_tab = GetSelectedTabContents(); | 1555 WebContents* current_tab = GetSelectedWebContents(); |
| 1551 if (current_tab && current_tab->ShowingInterstitialPage()) { | 1556 if (current_tab && current_tab->ShowingInterstitialPage()) { |
| 1552 NavigationEntry* entry = current_tab->GetController().GetActiveEntry(); | 1557 NavigationEntry* entry = current_tab->GetController().GetActiveEntry(); |
| 1553 DCHECK(entry); // Should exist if interstitial is showing. | 1558 DCHECK(entry); // Should exist if interstitial is showing. |
| 1554 OpenURL(OpenURLParams( | 1559 OpenURL(OpenURLParams( |
| 1555 entry->GetURL(), Referrer(), disposition, | 1560 entry->GetURL(), Referrer(), disposition, |
| 1556 content::PAGE_TRANSITION_RELOAD, false)); | 1561 content::PAGE_TRANSITION_RELOAD, false)); |
| 1557 return; | 1562 return; |
| 1558 } | 1563 } |
| 1559 | 1564 |
| 1560 // As this is caused by a user action, give the focus to the page. | 1565 // As this is caused by a user action, give the focus to the page. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1585 | 1590 |
| 1586 WindowOpenDisposition open_disposition = | 1591 WindowOpenDisposition open_disposition = |
| 1587 location_bar->GetWindowOpenDisposition(); | 1592 location_bar->GetWindowOpenDisposition(); |
| 1588 if (OpenInstant(open_disposition)) | 1593 if (OpenInstant(open_disposition)) |
| 1589 return; | 1594 return; |
| 1590 | 1595 |
| 1591 GURL url(location_bar->GetInputString()); | 1596 GURL url(location_bar->GetInputString()); |
| 1592 | 1597 |
| 1593 if (open_disposition == CURRENT_TAB && TabFinder::IsEnabled()) { | 1598 if (open_disposition == CURRENT_TAB && TabFinder::IsEnabled()) { |
| 1594 Browser* existing_browser = NULL; | 1599 Browser* existing_browser = NULL; |
| 1595 TabContents* existing_tab = TabFinder::GetInstance()->FindTab( | 1600 WebContents* existing_tab = TabFinder::GetInstance()->FindTab( |
| 1596 this, url, &existing_browser); | 1601 this, url, &existing_browser); |
| 1597 if (existing_tab) { | 1602 if (existing_tab) { |
| 1598 existing_browser->ActivateContents(existing_tab); | 1603 existing_browser->ActivateContents(existing_tab); |
| 1599 return; | 1604 return; |
| 1600 } | 1605 } |
| 1601 } | 1606 } |
| 1602 | 1607 |
| 1603 browser::NavigateParams params(this, url, location_bar->GetPageTransition()); | 1608 browser::NavigateParams params(this, url, location_bar->GetPageTransition()); |
| 1604 params.disposition = open_disposition; | 1609 params.disposition = open_disposition; |
| 1605 // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least | 1610 // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1740 return; | 1745 return; |
| 1741 | 1746 |
| 1742 service->RestoreMostRecentEntry(tab_restore_service_delegate()); | 1747 service->RestoreMostRecentEntry(tab_restore_service_delegate()); |
| 1743 } | 1748 } |
| 1744 | 1749 |
| 1745 void Browser::WriteCurrentURLToClipboard() { | 1750 void Browser::WriteCurrentURLToClipboard() { |
| 1746 // TODO(ericu): There isn't currently a metric for this. Should there be? | 1751 // TODO(ericu): There isn't currently a metric for this. Should there be? |
| 1747 // We don't appear to track the action when it comes from the | 1752 // We don't appear to track the action when it comes from the |
| 1748 // RenderContextViewMenu. | 1753 // RenderContextViewMenu. |
| 1749 | 1754 |
| 1750 TabContents* contents = GetSelectedTabContents(); | 1755 WebContents* contents = GetSelectedWebContents(); |
| 1751 if (!toolbar_model_.ShouldDisplayURL()) | 1756 if (!toolbar_model_.ShouldDisplayURL()) |
| 1752 return; | 1757 return; |
| 1753 | 1758 |
| 1754 chrome_browser_net::WriteURLToClipboard( | 1759 chrome_browser_net::WriteURLToClipboard( |
| 1755 contents->GetURL(), | 1760 contents->GetURL(), |
| 1756 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), | 1761 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), |
| 1757 g_browser_process->clipboard()); | 1762 g_browser_process->clipboard()); |
| 1758 } | 1763 } |
| 1759 | 1764 |
| 1760 void Browser::ConvertPopupToTabbedBrowser() { | 1765 void Browser::ConvertPopupToTabbedBrowser() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1784 if (window_->IsFullscreen()) { | 1789 if (window_->IsFullscreen()) { |
| 1785 ToggleFullscreenMode(false); | 1790 ToggleFullscreenMode(false); |
| 1786 // ToggleFullscreenMode is asynchronous, so we don't have omnibox | 1791 // ToggleFullscreenMode is asynchronous, so we don't have omnibox |
| 1787 // visible at this point. Wait for next event cycle which toggles | 1792 // visible at this point. Wait for next event cycle which toggles |
| 1788 // the visibility of omnibox before creating new tab. | 1793 // the visibility of omnibox before creating new tab. |
| 1789 MessageLoop::current()->PostTask( | 1794 MessageLoop::current()->PostTask( |
| 1790 FROM_HERE, base::Bind(&Browser::Search, weak_factory_.GetWeakPtr())); | 1795 FROM_HERE, base::Bind(&Browser::Search, weak_factory_.GetWeakPtr())); |
| 1791 return; | 1796 return; |
| 1792 } | 1797 } |
| 1793 | 1798 |
| 1794 const GURL& url = GetSelectedTabContents()->GetURL(); | 1799 const GURL& url = GetSelectedWebContents()->GetURL(); |
| 1795 if (url.SchemeIs(chrome::kChromeUIScheme) && | 1800 if (url.SchemeIs(chrome::kChromeUIScheme) && |
| 1796 url.host() == chrome::kChromeUINewTabHost) { | 1801 url.host() == chrome::kChromeUINewTabHost) { |
| 1797 // If the NTP is showing, focus the omnibox. | 1802 // If the NTP is showing, focus the omnibox. |
| 1798 window_->SetFocusToLocationBar(true); | 1803 window_->SetFocusToLocationBar(true); |
| 1799 } else { | 1804 } else { |
| 1800 // Otherwise, open the NTP. | 1805 // Otherwise, open the NTP. |
| 1801 NewTab(); | 1806 NewTab(); |
| 1802 } | 1807 } |
| 1803 } | 1808 } |
| 1804 | 1809 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1834 // bookmark isn't created if the url is invalid. | 1839 // bookmark isn't created if the url is invalid. |
| 1835 if (window_->IsActive() && model->IsBookmarked(url)) { | 1840 if (window_->IsActive() && model->IsBookmarked(url)) { |
| 1836 // Only show the bubble if the window is active, otherwise we may get into | 1841 // Only show the bubble if the window is active, otherwise we may get into |
| 1837 // weird situations were the bubble is deleted as soon as it is shown. | 1842 // weird situations were the bubble is deleted as soon as it is shown. |
| 1838 window_->ShowBookmarkBubble(url, was_bookmarked); | 1843 window_->ShowBookmarkBubble(url, was_bookmarked); |
| 1839 } | 1844 } |
| 1840 } | 1845 } |
| 1841 | 1846 |
| 1842 void Browser::SavePage() { | 1847 void Browser::SavePage() { |
| 1843 content::RecordAction(UserMetricsAction("SavePage")); | 1848 content::RecordAction(UserMetricsAction("SavePage")); |
| 1844 TabContents* current_tab = GetSelectedTabContents(); | 1849 WebContents* current_tab = GetSelectedWebContents(); |
| 1845 if (current_tab && current_tab->GetContentsMimeType() == "application/pdf") | 1850 if (current_tab && current_tab->GetContentsMimeType() == "application/pdf") |
| 1846 content::RecordAction(UserMetricsAction("PDF.SavePage")); | 1851 content::RecordAction(UserMetricsAction("PDF.SavePage")); |
| 1847 GetSelectedTabContents()->OnSavePage(); | 1852 GetSelectedWebContents()->OnSavePage(); |
| 1848 } | 1853 } |
| 1849 | 1854 |
| 1850 void Browser::ViewSelectedSource() { | 1855 void Browser::ViewSelectedSource() { |
| 1851 ViewSource(GetSelectedTabContentsWrapper()); | 1856 ViewSource(GetSelectedTabContentsWrapper()); |
| 1852 } | 1857 } |
| 1853 | 1858 |
| 1854 void Browser::ShowFindBar() { | 1859 void Browser::ShowFindBar() { |
| 1855 GetFindBarController()->Show(); | 1860 GetFindBarController()->Show(); |
| 1856 } | 1861 } |
| 1857 | 1862 |
| 1858 bool Browser::SupportsWindowFeature(WindowFeature feature) const { | 1863 bool Browser::SupportsWindowFeature(WindowFeature feature) const { |
| 1859 return SupportsWindowFeatureImpl(feature, true); | 1864 return SupportsWindowFeatureImpl(feature, true); |
| 1860 } | 1865 } |
| 1861 | 1866 |
| 1862 bool Browser::CanSupportWindowFeature(WindowFeature feature) const { | 1867 bool Browser::CanSupportWindowFeature(WindowFeature feature) const { |
| 1863 return SupportsWindowFeatureImpl(feature, false); | 1868 return SupportsWindowFeatureImpl(feature, false); |
| 1864 } | 1869 } |
| 1865 | 1870 |
| 1866 void Browser::EmailPageLocation() { | 1871 void Browser::EmailPageLocation() { |
| 1867 content::RecordAction(UserMetricsAction("EmailPageLocation")); | 1872 content::RecordAction(UserMetricsAction("EmailPageLocation")); |
| 1868 TabContents* tc = GetSelectedTabContents(); | 1873 WebContents* wc = GetSelectedWebContents(); |
| 1869 DCHECK(tc); | 1874 DCHECK(wc); |
| 1870 | 1875 |
| 1871 std::string title = net::EscapeQueryParamValue( | 1876 std::string title = net::EscapeQueryParamValue( |
| 1872 UTF16ToUTF8(tc->GetTitle()), false); | 1877 UTF16ToUTF8(wc->GetTitle()), false); |
| 1873 std::string page_url = net::EscapeQueryParamValue(tc->GetURL().spec(), false); | 1878 std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false); |
| 1874 std::string mailto = std::string("mailto:?subject=Fwd:%20") + | 1879 std::string mailto = std::string("mailto:?subject=Fwd:%20") + |
| 1875 title + "&body=%0A%0A" + page_url; | 1880 title + "&body=%0A%0A" + page_url; |
| 1876 platform_util::OpenExternal(GURL(mailto)); | 1881 platform_util::OpenExternal(GURL(mailto)); |
| 1877 } | 1882 } |
| 1878 | 1883 |
| 1879 void Browser::Print() { | 1884 void Browser::Print() { |
| 1880 if (switches::IsPrintPreviewEnabled()) | 1885 if (switches::IsPrintPreviewEnabled()) |
| 1881 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow(); | 1886 GetSelectedTabContentsWrapper()->print_view_manager()->PrintPreviewNow(); |
| 1882 else | 1887 else |
| 1883 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow(); | 1888 GetSelectedTabContentsWrapper()->print_view_manager()->PrintNow(); |
| 1884 } | 1889 } |
| 1885 | 1890 |
| 1886 void Browser::AdvancedPrint() { | 1891 void Browser::AdvancedPrint() { |
| 1887 GetSelectedTabContentsWrapper()->print_view_manager()->AdvancedPrintNow(); | 1892 GetSelectedTabContentsWrapper()->print_view_manager()->AdvancedPrintNow(); |
| 1888 } | 1893 } |
| 1889 | 1894 |
| 1890 void Browser::ToggleEncodingAutoDetect() { | 1895 void Browser::ToggleEncodingAutoDetect() { |
| 1891 content::RecordAction(UserMetricsAction("AutoDetectChange")); | 1896 content::RecordAction(UserMetricsAction("AutoDetectChange")); |
| 1892 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); | 1897 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); |
| 1893 // If "auto detect" is turned on, then any current override encoding | 1898 // If "auto detect" is turned on, then any current override encoding |
| 1894 // is cleared. This also implicitly performs a reload. | 1899 // is cleared. This also implicitly performs a reload. |
| 1895 // OTOH, if "auto detect" is turned off, we don't change the currently | 1900 // OTOH, if "auto detect" is turned off, we don't change the currently |
| 1896 // active encoding. | 1901 // active encoding. |
| 1897 if (encoding_auto_detect_.GetValue()) { | 1902 if (encoding_auto_detect_.GetValue()) { |
| 1898 TabContents* contents = GetSelectedTabContents(); | 1903 WebContents* contents = GetSelectedWebContents(); |
| 1899 if (contents) | 1904 if (contents) |
| 1900 contents->ResetOverrideEncoding(); | 1905 contents->ResetOverrideEncoding(); |
| 1901 } | 1906 } |
| 1902 } | 1907 } |
| 1903 | 1908 |
| 1904 void Browser::OverrideEncoding(int encoding_id) { | 1909 void Browser::OverrideEncoding(int encoding_id) { |
| 1905 content::RecordAction(UserMetricsAction("OverrideEncoding")); | 1910 content::RecordAction(UserMetricsAction("OverrideEncoding")); |
| 1906 const std::string selected_encoding = | 1911 const std::string selected_encoding = |
| 1907 CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); | 1912 CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); |
| 1908 TabContents* contents = GetSelectedTabContents(); | 1913 WebContents* contents = GetSelectedWebContents(); |
| 1909 if (!selected_encoding.empty() && contents) | 1914 if (!selected_encoding.empty() && contents) |
| 1910 contents->SetOverrideEncoding(selected_encoding); | 1915 contents->SetOverrideEncoding(selected_encoding); |
| 1911 // Update the list of recently selected encodings. | 1916 // Update the list of recently selected encodings. |
| 1912 std::string new_selected_encoding_list; | 1917 std::string new_selected_encoding_list; |
| 1913 if (CharacterEncoding::UpdateRecentlySelectedEncoding( | 1918 if (CharacterEncoding::UpdateRecentlySelectedEncoding( |
| 1914 profile_->GetPrefs()->GetString(prefs::kRecentlySelectedEncoding), | 1919 profile_->GetPrefs()->GetString(prefs::kRecentlySelectedEncoding), |
| 1915 encoding_id, | 1920 encoding_id, |
| 1916 &new_selected_encoding_list)) { | 1921 &new_selected_encoding_list)) { |
| 1917 profile_->GetPrefs()->SetString(prefs::kRecentlySelectedEncoding, | 1922 profile_->GetPrefs()->SetString(prefs::kRecentlySelectedEncoding, |
| 1918 new_selected_encoding_list); | 1923 new_selected_encoding_list); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 return; | 1959 return; |
| 1955 | 1960 |
| 1956 RenderViewHost* host = | 1961 RenderViewHost* host = |
| 1957 GetSelectedTabContentsWrapper()->tab_contents()->GetRenderViewHost(); | 1962 GetSelectedTabContentsWrapper()->tab_contents()->GetRenderViewHost(); |
| 1958 if (zoom == content::PAGE_ZOOM_RESET) { | 1963 if (zoom == content::PAGE_ZOOM_RESET) { |
| 1959 host->SetZoomLevel(0); | 1964 host->SetZoomLevel(0); |
| 1960 content::RecordAction(UserMetricsAction("ZoomNormal")); | 1965 content::RecordAction(UserMetricsAction("ZoomNormal")); |
| 1961 return; | 1966 return; |
| 1962 } | 1967 } |
| 1963 | 1968 |
| 1964 double current_zoom_level = GetSelectedTabContents()->GetZoomLevel(); | 1969 double current_zoom_level = GetSelectedWebContents()->GetZoomLevel(); |
| 1965 double default_zoom_level = | 1970 double default_zoom_level = |
| 1966 profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel); | 1971 profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel); |
| 1967 | 1972 |
| 1968 // Generate a vector of zoom levels from an array of known presets along with | 1973 // Generate a vector of zoom levels from an array of known presets along with |
| 1969 // the default level added if necessary. | 1974 // the default level added if necessary. |
| 1970 std::vector<double> zoom_levels = | 1975 std::vector<double> zoom_levels = |
| 1971 chrome_page_zoom::PresetZoomLevels(default_zoom_level); | 1976 chrome_page_zoom::PresetZoomLevels(default_zoom_level); |
| 1972 | 1977 |
| 1973 if (zoom == content::PAGE_ZOOM_OUT) { | 1978 if (zoom == content::PAGE_ZOOM_OUT) { |
| 1974 // Iterate through the zoom levels in reverse order to find the next | 1979 // Iterate through the zoom levels in reverse order to find the next |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2049 if (!select_file_dialog_.get()) | 2054 if (!select_file_dialog_.get()) |
| 2050 select_file_dialog_ = SelectFileDialog::Create(this); | 2055 select_file_dialog_ = SelectFileDialog::Create(this); |
| 2051 | 2056 |
| 2052 const FilePath directory = profile_->last_selected_directory(); | 2057 const FilePath directory = profile_->last_selected_directory(); |
| 2053 | 2058 |
| 2054 // TODO(beng): figure out how to juggle this. | 2059 // TODO(beng): figure out how to juggle this. |
| 2055 gfx::NativeWindow parent_window = window_->GetNativeHandle(); | 2060 gfx::NativeWindow parent_window = window_->GetNativeHandle(); |
| 2056 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, | 2061 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, |
| 2057 string16(), directory, | 2062 string16(), directory, |
| 2058 NULL, 0, FILE_PATH_LITERAL(""), | 2063 NULL, 0, FILE_PATH_LITERAL(""), |
| 2059 GetSelectedTabContents(), | 2064 GetSelectedWebContents(), |
| 2060 parent_window, NULL); | 2065 parent_window, NULL); |
| 2061 } | 2066 } |
| 2062 | 2067 |
| 2063 void Browser::OpenCreateShortcutsDialog() { | 2068 void Browser::OpenCreateShortcutsDialog() { |
| 2064 content::RecordAction(UserMetricsAction("CreateShortcut")); | 2069 content::RecordAction(UserMetricsAction("CreateShortcut")); |
| 2065 #if !defined(OS_MACOSX) | 2070 #if !defined(OS_MACOSX) |
| 2066 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); | 2071 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); |
| 2067 DCHECK(current_tab && | 2072 DCHECK(current_tab && |
| 2068 web_app::IsValidUrl(current_tab->tab_contents()->GetURL())) << | 2073 web_app::IsValidUrl(current_tab->tab_contents()->GetURL())) << |
| 2069 "Menu item should be disabled."; | 2074 "Menu item should be disabled."; |
| (...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3528 | 3533 |
| 3529 void Browser::DeactivateContents(WebContents* contents) { | 3534 void Browser::DeactivateContents(WebContents* contents) { |
| 3530 window_->Deactivate(); | 3535 window_->Deactivate(); |
| 3531 } | 3536 } |
| 3532 | 3537 |
| 3533 void Browser::LoadingStateChanged(WebContents* source) { | 3538 void Browser::LoadingStateChanged(WebContents* source) { |
| 3534 window_->UpdateLoadingAnimations( | 3539 window_->UpdateLoadingAnimations( |
| 3535 tab_handler_->GetTabStripModel()->TabsAreLoading()); | 3540 tab_handler_->GetTabStripModel()->TabsAreLoading()); |
| 3536 window_->UpdateTitleBar(); | 3541 window_->UpdateTitleBar(); |
| 3537 | 3542 |
| 3538 WebContents* selected_contents = GetSelectedTabContents(); | 3543 WebContents* selected_contents = GetSelectedWebContents(); |
| 3539 if (source == selected_contents) { | 3544 if (source == selected_contents) { |
| 3540 bool is_loading = source->IsLoading(); | 3545 bool is_loading = source->IsLoading(); |
| 3541 UpdateReloadStopState(is_loading, false); | 3546 UpdateReloadStopState(is_loading, false); |
| 3542 if (GetStatusBubble()) { | 3547 if (GetStatusBubble()) { |
| 3543 GetStatusBubble()->SetStatus( | 3548 GetStatusBubble()->SetStatus( |
| 3544 GetSelectedTabContentsWrapper()->core_tab_helper()->GetStatusText()); | 3549 GetSelectedTabContentsWrapper()->core_tab_helper()->GetStatusText()); |
| 3545 } | 3550 } |
| 3546 | 3551 |
| 3547 if (!is_loading && pending_web_app_action_ == UPDATE_SHORTCUT) { | 3552 if (!is_loading && pending_web_app_action_ == UPDATE_SHORTCUT) { |
| 3548 // Schedule a shortcut update when web application info is available if | 3553 // Schedule a shortcut update when web application info is available if |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3597 bool Browser::IsPopupOrPanel(const WebContents* source) const { | 3602 bool Browser::IsPopupOrPanel(const WebContents* source) const { |
| 3598 // A non-tabbed BROWSER is an unconstrained popup. | 3603 // A non-tabbed BROWSER is an unconstrained popup. |
| 3599 return is_type_popup() || is_type_panel(); | 3604 return is_type_popup() || is_type_panel(); |
| 3600 } | 3605 } |
| 3601 | 3606 |
| 3602 void Browser::ContentsMouseEvent( | 3607 void Browser::ContentsMouseEvent( |
| 3603 WebContents* source, const gfx::Point& location, bool motion) { | 3608 WebContents* source, const gfx::Point& location, bool motion) { |
| 3604 if (!GetStatusBubble()) | 3609 if (!GetStatusBubble()) |
| 3605 return; | 3610 return; |
| 3606 | 3611 |
| 3607 if (source == GetSelectedTabContents()) { | 3612 if (source == GetSelectedWebContents()) { |
| 3608 GetStatusBubble()->MouseMoved(location, !motion); | 3613 GetStatusBubble()->MouseMoved(location, !motion); |
| 3609 if (!motion) | 3614 if (!motion) |
| 3610 GetStatusBubble()->SetURL(GURL(), std::string()); | 3615 GetStatusBubble()->SetURL(GURL(), std::string()); |
| 3611 } | 3616 } |
| 3612 } | 3617 } |
| 3613 | 3618 |
| 3614 void Browser::UpdateTargetURL(WebContents* source, int32 page_id, | 3619 void Browser::UpdateTargetURL(WebContents* source, int32 page_id, |
| 3615 const GURL& url) { | 3620 const GURL& url) { |
| 3616 Browser::UpdateTargetURLHelper(source, page_id, url); | 3621 Browser::UpdateTargetURLHelper(source, page_id, url); |
| 3617 | 3622 |
| 3618 if (!GetStatusBubble()) | 3623 if (!GetStatusBubble()) |
| 3619 return; | 3624 return; |
| 3620 | 3625 |
| 3621 if (source == GetSelectedTabContents()) { | 3626 if (source == GetSelectedWebContents()) { |
| 3622 PrefService* prefs = profile_->GetPrefs(); | 3627 PrefService* prefs = profile_->GetPrefs(); |
| 3623 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); | 3628 GetStatusBubble()->SetURL(url, prefs->GetString(prefs::kAcceptLanguages)); |
| 3624 } | 3629 } |
| 3625 } | 3630 } |
| 3626 | 3631 |
| 3627 void Browser::UpdateDownloadShelfVisibility(bool visible) { | 3632 void Browser::UpdateDownloadShelfVisibility(bool visible) { |
| 3628 if (GetStatusBubble()) | 3633 if (GetStatusBubble()) |
| 3629 GetStatusBubble()->UpdateDownloadShelfVisibility(visible); | 3634 GetStatusBubble()->UpdateDownloadShelfVisibility(visible); |
| 3630 } | 3635 } |
| 3631 | 3636 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3875 TabContentsWrapper::GetCurrentWrapperForContents(source); | 3880 TabContentsWrapper::GetCurrentWrapperForContents(source); |
| 3876 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); | 3881 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); |
| 3877 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( | 3882 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( |
| 3878 infobar_helper, | 3883 infobar_helper, |
| 3879 NULL, | 3884 NULL, |
| 3880 l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), | 3885 l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), |
| 3881 true)); | 3886 true)); |
| 3882 } | 3887 } |
| 3883 | 3888 |
| 3884 void Browser::DidNavigateMainFramePostCommit(WebContents* tab) { | 3889 void Browser::DidNavigateMainFramePostCommit(WebContents* tab) { |
| 3885 if (tab == GetSelectedTabContents()) | 3890 if (tab == GetSelectedWebContents()) |
| 3886 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 3891 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
| 3887 } | 3892 } |
| 3888 | 3893 |
| 3889 void Browser::DidNavigateToPendingEntry(WebContents* tab) { | 3894 void Browser::DidNavigateToPendingEntry(WebContents* tab) { |
| 3890 if (tab == GetSelectedTabContents()) | 3895 if (tab == GetSelectedWebContents()) |
| 3891 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 3896 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
| 3892 } | 3897 } |
| 3893 | 3898 |
| 3894 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { | 3899 content::JavaScriptDialogCreator* Browser::GetJavaScriptDialogCreator() { |
| 3895 return GetJavaScriptDialogCreatorInstance(); | 3900 return GetJavaScriptDialogCreatorInstance(); |
| 3896 } | 3901 } |
| 3897 | 3902 |
| 3898 void Browser::RunFileChooser(WebContents* tab, | 3903 void Browser::RunFileChooser(WebContents* tab, |
| 3899 const content::FileChooserParams& params) { | 3904 const content::FileChooserParams& params) { |
| 3900 RunFileChooserHelper(tab, params); | 3905 RunFileChooserHelper(tab, params); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4102 } | 4107 } |
| 4103 break; | 4108 break; |
| 4104 | 4109 |
| 4105 case content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED: | 4110 case content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED: |
| 4106 // When the current tab's SSL state changes, we need to update the URL | 4111 // When the current tab's SSL state changes, we need to update the URL |
| 4107 // bar to reflect the new state. Note that it's possible for the selected | 4112 // bar to reflect the new state. Note that it's possible for the selected |
| 4108 // tab contents to be NULL. This is because we listen for all sources | 4113 // tab contents to be NULL. This is because we listen for all sources |
| 4109 // (NavigationControllers) for convenience, so the notification could | 4114 // (NavigationControllers) for convenience, so the notification could |
| 4110 // actually be for a different window while we're doing asynchronous | 4115 // actually be for a different window while we're doing asynchronous |
| 4111 // closing of this one. | 4116 // closing of this one. |
| 4112 if (GetSelectedTabContents() && | 4117 if (GetSelectedWebContents() && |
| 4113 &GetSelectedTabContents()->GetController() == | 4118 &GetSelectedWebContents()->GetController() == |
| 4114 content::Source<NavigationController>(source).ptr()) | 4119 content::Source<NavigationController>(source).ptr()) |
| 4115 UpdateToolbar(false); | 4120 UpdateToolbar(false); |
| 4116 break; | 4121 break; |
| 4117 | 4122 |
| 4118 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: { | 4123 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: { |
| 4119 // Show the UI if the extension was disabled for escalated permissions. | 4124 // Show the UI if the extension was disabled for escalated permissions. |
| 4120 Profile* profile = content::Source<Profile>(source).ptr(); | 4125 Profile* profile = content::Source<Profile>(source).ptr(); |
| 4121 if (profile_->IsSameProfile(profile)) { | 4126 if (profile_->IsSameProfile(profile)) { |
| 4122 ExtensionService* service = profile->GetExtensionService(); | 4127 ExtensionService* service = profile->GetExtensionService(); |
| 4123 DCHECK(service); | 4128 DCHECK(service); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4215 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); | 4220 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); |
| 4216 UpdateOpenFileState(); | 4221 UpdateOpenFileState(); |
| 4217 } else { | 4222 } else { |
| 4218 NOTREACHED(); | 4223 NOTREACHED(); |
| 4219 } | 4224 } |
| 4220 break; | 4225 break; |
| 4221 } | 4226 } |
| 4222 | 4227 |
| 4223 case chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED: { | 4228 case chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED: { |
| 4224 WebContents* web_contents = content::Source<WebContents>(source).ptr(); | 4229 WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
| 4225 if (web_contents == GetSelectedTabContents()) { | 4230 if (web_contents == GetSelectedWebContents()) { |
| 4226 LocationBar* location_bar = window()->GetLocationBar(); | 4231 LocationBar* location_bar = window()->GetLocationBar(); |
| 4227 if (location_bar) | 4232 if (location_bar) |
| 4228 location_bar->UpdateContentSettingsIcons(); | 4233 location_bar->UpdateContentSettingsIcons(); |
| 4229 } | 4234 } |
| 4230 break; | 4235 break; |
| 4231 } | 4236 } |
| 4232 | 4237 |
| 4233 case content::NOTIFICATION_INTERSTITIAL_ATTACHED: | 4238 case content::NOTIFICATION_INTERSTITIAL_ATTACHED: |
| 4234 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 4239 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
| 4235 UpdateCommandsForTabState(); | 4240 UpdateCommandsForTabState(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4256 show_main_ui && profile_->GetOriginalProfile()->IsSyncAccessible()); | 4261 show_main_ui && profile_->GetOriginalProfile()->IsSyncAccessible()); |
| 4257 } | 4262 } |
| 4258 | 4263 |
| 4259 /////////////////////////////////////////////////////////////////////////////// | 4264 /////////////////////////////////////////////////////////////////////////////// |
| 4260 // Browser, InstantDelegate implementation: | 4265 // Browser, InstantDelegate implementation: |
| 4261 | 4266 |
| 4262 void Browser::ShowInstant(TabContentsWrapper* preview_contents) { | 4267 void Browser::ShowInstant(TabContentsWrapper* preview_contents) { |
| 4263 DCHECK(instant_->tab_contents() == GetSelectedTabContentsWrapper()); | 4268 DCHECK(instant_->tab_contents() == GetSelectedTabContentsWrapper()); |
| 4264 window_->ShowInstant(preview_contents); | 4269 window_->ShowInstant(preview_contents); |
| 4265 | 4270 |
| 4266 GetSelectedTabContents()->HideContents(); | 4271 GetSelectedWebContents()->HideContents(); |
| 4267 preview_contents->tab_contents()->ShowContents(); | 4272 preview_contents->web_contents()->ShowContents(); |
| 4268 } | 4273 } |
| 4269 | 4274 |
| 4270 void Browser::HideInstant() { | 4275 void Browser::HideInstant() { |
| 4271 window_->HideInstant(); | 4276 window_->HideInstant(); |
| 4272 if (GetSelectedTabContents()) | 4277 if (GetSelectedWebContents()) |
| 4273 GetSelectedTabContents()->ShowContents(); | 4278 GetSelectedWebContents()->ShowContents(); |
| 4274 if (instant_->GetPreviewContents()) | 4279 if (instant_->GetPreviewContents()) |
| 4275 instant_->GetPreviewContents()->tab_contents()->HideContents(); | 4280 instant_->GetPreviewContents()->web_contents()->HideContents(); |
| 4276 } | 4281 } |
| 4277 | 4282 |
| 4278 void Browser::CommitInstant(TabContentsWrapper* preview_contents) { | 4283 void Browser::CommitInstant(TabContentsWrapper* preview_contents) { |
| 4279 TabContentsWrapper* tab_contents = instant_->tab_contents(); | 4284 TabContentsWrapper* tab_contents = instant_->tab_contents(); |
| 4280 int index = | 4285 int index = |
| 4281 tab_handler_->GetTabStripModel()->GetIndexOfTabContents(tab_contents); | 4286 tab_handler_->GetTabStripModel()->GetIndexOfTabContents(tab_contents); |
| 4282 DCHECK_NE(TabStripModel::kNoTab, index); | 4287 DCHECK_NE(TabStripModel::kNoTab, index); |
| 4283 // TabStripModel takes ownership of preview_contents. | 4288 // TabStripModel takes ownership of preview_contents. |
| 4284 tab_handler_->GetTabStripModel()->ReplaceTabContentsAt( | 4289 tab_handler_->GetTabStripModel()->ReplaceTabContentsAt( |
| 4285 index, preview_contents); | 4290 index, preview_contents); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4585 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, | 4590 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, |
| 4586 show_main_ui && !profile()->IsOffTheRecord()); | 4591 show_main_ui && !profile()->IsOffTheRecord()); |
| 4587 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC) | 4592 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC) |
| 4588 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); | 4593 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); |
| 4589 #endif | 4594 #endif |
| 4590 | 4595 |
| 4591 UpdateCommandsForBookmarkBar(); | 4596 UpdateCommandsForBookmarkBar(); |
| 4592 } | 4597 } |
| 4593 | 4598 |
| 4594 void Browser::UpdateCommandsForTabState() { | 4599 void Browser::UpdateCommandsForTabState() { |
| 4595 TabContents* current_tab = GetSelectedTabContents(); | 4600 WebContents* current_tab = GetSelectedWebContents(); |
| 4596 TabContentsWrapper* current_tab_wrapper = GetSelectedTabContentsWrapper(); | 4601 TabContentsWrapper* current_tab_wrapper = GetSelectedTabContentsWrapper(); |
| 4597 if (!current_tab || !current_tab_wrapper) // May be NULL during tab restore. | 4602 if (!current_tab || !current_tab_wrapper) // May be NULL during tab restore. |
| 4598 return; | 4603 return; |
| 4599 | 4604 |
| 4600 // Navigation commands | 4605 // Navigation commands |
| 4601 NavigationController& nc = current_tab->GetController(); | 4606 NavigationController& nc = current_tab->GetController(); |
| 4602 command_updater_.UpdateCommandEnabled(IDC_BACK, nc.CanGoBack()); | 4607 command_updater_.UpdateCommandEnabled(IDC_BACK, nc.CanGoBack()); |
| 4603 command_updater_.UpdateCommandEnabled(IDC_FORWARD, nc.CanGoForward()); | 4608 command_updater_.UpdateCommandEnabled(IDC_FORWARD, nc.CanGoForward()); |
| 4604 command_updater_.UpdateCommandEnabled(IDC_RELOAD, | 4609 command_updater_.UpdateCommandEnabled(IDC_RELOAD, |
| 4605 CanReloadContents(current_tab)); | 4610 CanReloadContents(current_tab)); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4749 window_->UpdateToolbar(GetSelectedTabContentsWrapper(), should_restore_state); | 4754 window_->UpdateToolbar(GetSelectedTabContentsWrapper(), should_restore_state); |
| 4750 } | 4755 } |
| 4751 | 4756 |
| 4752 void Browser::ScheduleUIUpdate(const WebContents* source, | 4757 void Browser::ScheduleUIUpdate(const WebContents* source, |
| 4753 unsigned changed_flags) { | 4758 unsigned changed_flags) { |
| 4754 if (!source) | 4759 if (!source) |
| 4755 return; | 4760 return; |
| 4756 | 4761 |
| 4757 // Do some synchronous updates. | 4762 // Do some synchronous updates. |
| 4758 if (changed_flags & TabContents::INVALIDATE_URL && | 4763 if (changed_flags & TabContents::INVALIDATE_URL && |
| 4759 source == GetSelectedTabContents()) { | 4764 source == GetSelectedWebContents()) { |
| 4760 // Only update the URL for the current tab. Note that we do not update | 4765 // Only update the URL for the current tab. Note that we do not update |
| 4761 // the navigation commands since those would have already been updated | 4766 // the navigation commands since those would have already been updated |
| 4762 // synchronously by NavigationStateChanged. | 4767 // synchronously by NavigationStateChanged. |
| 4763 UpdateToolbar(false); | 4768 UpdateToolbar(false); |
| 4764 changed_flags &= ~TabContents::INVALIDATE_URL; | 4769 changed_flags &= ~TabContents::INVALIDATE_URL; |
| 4765 } | 4770 } |
| 4766 if (changed_flags & TabContents::INVALIDATE_LOAD) { | 4771 if (changed_flags & TabContents::INVALIDATE_LOAD) { |
| 4767 // Update the loading state synchronously. This is so the throbber will | 4772 // Update the loading state synchronously. This is so the throbber will |
| 4768 // immediately start/stop, which gives a more snappy feel. We want to do | 4773 // immediately start/stop, which gives a more snappy feel. We want to do |
| 4769 // this for any tab so they start & stop quickly. | 4774 // this for any tab so they start & stop quickly. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4823 #endif | 4828 #endif |
| 4824 | 4829 |
| 4825 chrome_updater_factory_.InvalidateWeakPtrs(); | 4830 chrome_updater_factory_.InvalidateWeakPtrs(); |
| 4826 | 4831 |
| 4827 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); | 4832 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); |
| 4828 i != scheduled_updates_.end(); ++i) { | 4833 i != scheduled_updates_.end(); ++i) { |
| 4829 // Do not dereference |contents|, it may be out-of-date! | 4834 // Do not dereference |contents|, it may be out-of-date! |
| 4830 const WebContents* contents = i->first; | 4835 const WebContents* contents = i->first; |
| 4831 unsigned flags = i->second; | 4836 unsigned flags = i->second; |
| 4832 | 4837 |
| 4833 if (contents == GetSelectedTabContents()) { | 4838 if (contents == GetSelectedWebContents()) { |
| 4834 // Updates that only matter when the tab is selected go here. | 4839 // Updates that only matter when the tab is selected go here. |
| 4835 | 4840 |
| 4836 if (flags & TabContents::INVALIDATE_PAGE_ACTIONS) { | 4841 if (flags & TabContents::INVALIDATE_PAGE_ACTIONS) { |
| 4837 LocationBar* location_bar = window()->GetLocationBar(); | 4842 LocationBar* location_bar = window()->GetLocationBar(); |
| 4838 if (location_bar) | 4843 if (location_bar) |
| 4839 location_bar->UpdatePageActions(); | 4844 location_bar->UpdatePageActions(); |
| 4840 } | 4845 } |
| 4841 // Updating the URL happens synchronously in ScheduleUIUpdate. | 4846 // Updating the URL happens synchronously in ScheduleUIUpdate. |
| 4842 if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) { | 4847 if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) { |
| 4843 GetStatusBubble()->SetStatus( | 4848 GetStatusBubble()->SetStatus( |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5283 } | 5288 } |
| 5284 | 5289 |
| 5285 SessionService* session_service = | 5290 SessionService* session_service = |
| 5286 SessionServiceFactory::GetForProfileIfExisting(profile_); | 5291 SessionServiceFactory::GetForProfileIfExisting(profile_); |
| 5287 if (session_service) | 5292 if (session_service) |
| 5288 session_service->TabRestored(view_source_contents, false); | 5293 session_service->TabRestored(view_source_contents, false); |
| 5289 } | 5294 } |
| 5290 | 5295 |
| 5291 int Browser::GetContentRestrictionsForSelectedTab() { | 5296 int Browser::GetContentRestrictionsForSelectedTab() { |
| 5292 int content_restrictions = 0; | 5297 int content_restrictions = 0; |
| 5293 TabContents* current_tab = GetSelectedTabContents(); | 5298 WebContents* current_tab = GetSelectedWebContents(); |
| 5294 if (current_tab) { | 5299 if (current_tab) { |
| 5295 content_restrictions = current_tab->GetContentRestrictions(); | 5300 content_restrictions = current_tab->GetContentRestrictions(); |
| 5296 NavigationEntry* active_entry = | 5301 NavigationEntry* active_entry = |
| 5297 current_tab->GetController().GetActiveEntry(); | 5302 current_tab->GetController().GetActiveEntry(); |
| 5298 // See comment in UpdateCommandsForTabState about why we call url(). | 5303 // See comment in UpdateCommandsForTabState about why we call url(). |
| 5299 if (!SavePackage::IsSavableURL( | 5304 if (!SavePackage::IsSavableURL( |
| 5300 active_entry ? active_entry->GetURL() : GURL()) | 5305 active_entry ? active_entry->GetURL() : GURL()) |
| 5301 || current_tab->ShowingInterstitialPage()) | 5306 || current_tab->ShowingInterstitialPage()) |
| 5302 content_restrictions |= content::CONTENT_RESTRICTION_SAVE; | 5307 content_restrictions |= content::CONTENT_RESTRICTION_SAVE; |
| 5303 if (current_tab->ShowingInterstitialPage()) | 5308 if (current_tab->ShowingInterstitialPage()) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5359 void Browser::OnWindowDidShow() { | 5364 void Browser::OnWindowDidShow() { |
| 5360 if (window_has_shown_) | 5365 if (window_has_shown_) |
| 5361 return; | 5366 return; |
| 5362 window_has_shown_ = true; | 5367 window_has_shown_ = true; |
| 5363 | 5368 |
| 5364 // Nothing to do for non-tabbed windows. | 5369 // Nothing to do for non-tabbed windows. |
| 5365 if (!is_type_tabbed()) | 5370 if (!is_type_tabbed()) |
| 5366 return; | 5371 return; |
| 5367 | 5372 |
| 5368 // Suppress the first run bubble if we're showing the sync promo. | 5373 // Suppress the first run bubble if we're showing the sync promo. |
| 5369 TabContents* contents = GetSelectedTabContents(); | 5374 WebContents* contents = GetSelectedWebContents(); |
| 5370 bool is_showing_promo = contents && | 5375 bool is_showing_promo = contents && |
| 5371 contents->GetURL().SchemeIs(chrome::kChromeUIScheme) && | 5376 contents->GetURL().SchemeIs(chrome::kChromeUIScheme) && |
| 5372 contents->GetURL().host() == chrome::kChromeUISyncPromoHost; | 5377 contents->GetURL().host() == chrome::kChromeUISyncPromoHost; |
| 5373 | 5378 |
| 5374 // Show the First Run information bubble if we've been told to. | 5379 // Show the First Run information bubble if we've been told to. |
| 5375 PrefService* local_state = g_browser_process->local_state(); | 5380 PrefService* local_state = g_browser_process->local_state(); |
| 5376 if (!is_showing_promo && local_state && | 5381 if (!is_showing_promo && local_state && |
| 5377 local_state->GetBoolean(prefs::kShouldShowFirstRunBubble)) { | 5382 local_state->GetBoolean(prefs::kShouldShowFirstRunBubble)) { |
| 5378 FirstRun::BubbleType bubble_type = FirstRun::MINIMAL_BUBBLE; | 5383 FirstRun::BubbleType bubble_type = FirstRun::MINIMAL_BUBBLE; |
| 5379 if (local_state-> | 5384 if (local_state-> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5391 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5396 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
| 5392 } else { | 5397 } else { |
| 5393 GlobalErrorService* service = | 5398 GlobalErrorService* service = |
| 5394 GlobalErrorServiceFactory::GetForProfile(profile()); | 5399 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 5395 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5400 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
| 5396 if (error) { | 5401 if (error) { |
| 5397 error->ShowBubbleView(this); | 5402 error->ShowBubbleView(this); |
| 5398 } | 5403 } |
| 5399 } | 5404 } |
| 5400 } | 5405 } |
| OLD | NEW |