OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.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 // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 profile_pref_registrar_.Add( | 406 profile_pref_registrar_.Add( |
407 bookmarks::prefs::kShowBookmarkBar, | 407 bookmarks::prefs::kShowBookmarkBar, |
408 base::Bind(&Browser::UpdateBookmarkBarState, base::Unretained(this), | 408 base::Bind(&Browser::UpdateBookmarkBarState, base::Unretained(this), |
409 BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE)); | 409 BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE)); |
410 | 410 |
411 // NOTE: These prefs all need to be explicitly destroyed in the destructor | 411 // NOTE: These prefs all need to be explicitly destroyed in the destructor |
412 // or you'll get a nasty surprise when you run the incognito tests. | 412 // or you'll get a nasty surprise when you run the incognito tests. |
413 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, | 413 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, |
414 profile_->GetPrefs()); | 414 profile_->GetPrefs()); |
415 | 415 |
416 if (chrome::IsInstantExtendedAPIEnabled() && is_type_tabbed()) | 416 if (search::IsInstantExtendedAPIEnabled() && is_type_tabbed()) |
417 instant_controller_.reset(new BrowserInstantController(this)); | 417 instant_controller_.reset(new BrowserInstantController(this)); |
418 | 418 |
419 if (extensions::HostedAppBrowserController::IsForHostedApp(this)) { | 419 if (extensions::HostedAppBrowserController::IsForHostedApp(this)) { |
420 hosted_app_controller_.reset( | 420 hosted_app_controller_.reset( |
421 new extensions::HostedAppBrowserController(this)); | 421 new extensions::HostedAppBrowserController(this)); |
422 } | 422 } |
423 | 423 |
424 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT); | 424 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT); |
425 | 425 |
426 ProfileMetrics::LogProfileLaunch(profile_); | 426 ProfileMetrics::LogProfileLaunch(profile_); |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 chrome::Reload(this, CURRENT_TAB); | 1030 chrome::Reload(this, CURRENT_TAB); |
1031 } | 1031 } |
1032 | 1032 |
1033 // If we have any update pending, do it now. | 1033 // If we have any update pending, do it now. |
1034 if (chrome_updater_factory_.HasWeakPtrs() && old_contents) | 1034 if (chrome_updater_factory_.HasWeakPtrs() && old_contents) |
1035 ProcessPendingUIUpdates(); | 1035 ProcessPendingUIUpdates(); |
1036 | 1036 |
1037 // Propagate the profile to the location bar. | 1037 // Propagate the profile to the location bar. |
1038 UpdateToolbar((reason & CHANGE_REASON_REPLACED) == 0); | 1038 UpdateToolbar((reason & CHANGE_REASON_REPLACED) == 0); |
1039 | 1039 |
1040 if (chrome::IsInstantExtendedAPIEnabled()) | 1040 if (search::IsInstantExtendedAPIEnabled()) |
1041 search_delegate_->OnTabActivated(new_contents); | 1041 search_delegate_->OnTabActivated(new_contents); |
1042 | 1042 |
1043 // Update reload/stop state. | 1043 // Update reload/stop state. |
1044 command_controller_->LoadingStateChanged(new_contents->IsLoading(), true); | 1044 command_controller_->LoadingStateChanged(new_contents->IsLoading(), true); |
1045 | 1045 |
1046 // Update commands to reflect current state. | 1046 // Update commands to reflect current state. |
1047 command_controller_->TabStateChanged(); | 1047 command_controller_->TabStateChanged(); |
1048 | 1048 |
1049 // Reset the status bubble. | 1049 // Reset the status bubble. |
1050 StatusBubble* status_bubble = GetStatusBubble(); | 1050 StatusBubble* status_bubble = GetStatusBubble(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 return true; | 1186 return true; |
1187 } | 1187 } |
1188 | 1188 |
1189 bool Browser::ShouldPreserveAbortedURLs(WebContents* source) { | 1189 bool Browser::ShouldPreserveAbortedURLs(WebContents* source) { |
1190 // Allow failed URLs to stick around in the omnibox on the NTP, but not when | 1190 // Allow failed URLs to stick around in the omnibox on the NTP, but not when |
1191 // other pages have committed. | 1191 // other pages have committed. |
1192 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext()); | 1192 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext()); |
1193 if (!profile || !source->GetController().GetLastCommittedEntry()) | 1193 if (!profile || !source->GetController().GetLastCommittedEntry()) |
1194 return false; | 1194 return false; |
1195 GURL committed_url(source->GetController().GetLastCommittedEntry()->GetURL()); | 1195 GURL committed_url(source->GetController().GetLastCommittedEntry()->GetURL()); |
1196 return chrome::IsNTPURL(committed_url, profile); | 1196 return search::IsNTPURL(committed_url, profile); |
1197 } | 1197 } |
1198 | 1198 |
1199 void Browser::SetFocusToLocationBar(bool select_all) { | 1199 void Browser::SetFocusToLocationBar(bool select_all) { |
1200 // Two differences between this and FocusLocationBar(): | 1200 // Two differences between this and FocusLocationBar(): |
1201 // (1) This doesn't get recorded in user metrics, since it's called | 1201 // (1) This doesn't get recorded in user metrics, since it's called |
1202 // internally. | 1202 // internally. |
1203 // (2) This checks whether the location bar can be focused, and if not, clears | 1203 // (2) This checks whether the location bar can be focused, and if not, clears |
1204 // the focus. FocusLocationBar() is only reached when the location bar is | 1204 // the focus. FocusLocationBar() is only reached when the location bar is |
1205 // focusable, but this may be reached at other times, e.g. while in | 1205 // focusable, but this may be reached at other times, e.g. while in |
1206 // fullscreen mode, where we need to leave focus in a consistent state. | 1206 // fullscreen mode, where we need to leave focus in a consistent state. |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 GURL url = entry->GetURL(); | 1584 GURL url = entry->GetURL(); |
1585 GURL virtual_url = entry->GetVirtualURL(); | 1585 GURL virtual_url = entry->GetVirtualURL(); |
1586 if ((url.SchemeIs(content::kChromeUIScheme) && | 1586 if ((url.SchemeIs(content::kChromeUIScheme) && |
1587 url.host() == chrome::kChromeUINewTabHost) || | 1587 url.host() == chrome::kChromeUINewTabHost) || |
1588 (virtual_url.SchemeIs(content::kChromeUIScheme) && | 1588 (virtual_url.SchemeIs(content::kChromeUIScheme) && |
1589 virtual_url.host() == chrome::kChromeUINewTabHost)) { | 1589 virtual_url.host() == chrome::kChromeUINewTabHost)) { |
1590 return true; | 1590 return true; |
1591 } | 1591 } |
1592 } | 1592 } |
1593 | 1593 |
1594 return chrome::NavEntryIsInstantNTP(source, entry); | 1594 return search::NavEntryIsInstantNTP(source, entry); |
1595 } | 1595 } |
1596 | 1596 |
1597 void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) { | 1597 void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) { |
1598 DCHECK(source); | 1598 DCHECK(source); |
1599 chrome::ViewSource(this, source); | 1599 chrome::ViewSource(this, source); |
1600 } | 1600 } |
1601 | 1601 |
1602 void Browser::ViewSourceForFrame(WebContents* source, | 1602 void Browser::ViewSourceForFrame(WebContents* source, |
1603 const GURL& frame_url, | 1603 const GURL& frame_url, |
1604 const content::PageState& frame_page_state) { | 1604 const content::PageState& frame_page_state) { |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 // would disappear on non-NTP pages, resulting in a bigger size for the new | 1852 // would disappear on non-NTP pages, resulting in a bigger size for the new |
1853 // render view. | 1853 // render view. |
1854 gfx::Size size = web_contents->GetContainerBounds().size(); | 1854 gfx::Size size = web_contents->GetContainerBounds().size(); |
1855 // Don't change render view size if bookmark bar is currently not detached, | 1855 // Don't change render view size if bookmark bar is currently not detached, |
1856 // or there's no pending entry, or navigating to a NTP page. | 1856 // or there's no pending entry, or navigating to a NTP page. |
1857 if (size.IsEmpty() || bookmark_bar_state_ != BookmarkBar::DETACHED) | 1857 if (size.IsEmpty() || bookmark_bar_state_ != BookmarkBar::DETACHED) |
1858 return size; | 1858 return size; |
1859 const NavigationEntry* pending_entry = | 1859 const NavigationEntry* pending_entry = |
1860 web_contents->GetController().GetPendingEntry(); | 1860 web_contents->GetController().GetPendingEntry(); |
1861 if (pending_entry && | 1861 if (pending_entry && |
1862 !chrome::IsNTPURL(pending_entry->GetVirtualURL(), profile_)) { | 1862 !search::IsNTPURL(pending_entry->GetVirtualURL(), profile_)) { |
1863 size.Enlarge( | 1863 size.Enlarge( |
1864 0, window()->GetRenderViewHeightInsetWithDetachedBookmarkBar()); | 1864 0, window()->GetRenderViewHeightInsetWithDetachedBookmarkBar()); |
1865 } | 1865 } |
1866 return size; | 1866 return size; |
1867 } | 1867 } |
1868 | 1868 |
1869 /////////////////////////////////////////////////////////////////////////////// | 1869 /////////////////////////////////////////////////////////////////////////////// |
1870 // Browser, CoreTabHelperDelegate implementation: | 1870 // Browser, CoreTabHelperDelegate implementation: |
1871 | 1871 |
1872 void Browser::SwapTabContents(content::WebContents* old_contents, | 1872 void Browser::SwapTabContents(content::WebContents* old_contents, |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 if (contents && !allow_js_access) { | 2626 if (contents && !allow_js_access) { |
2627 contents->web_contents()->GetController().LoadURL( | 2627 contents->web_contents()->GetController().LoadURL( |
2628 target_url, | 2628 target_url, |
2629 content::Referrer(), | 2629 content::Referrer(), |
2630 ui::PAGE_TRANSITION_LINK, | 2630 ui::PAGE_TRANSITION_LINK, |
2631 std::string()); // No extra headers. | 2631 std::string()); // No extra headers. |
2632 } | 2632 } |
2633 | 2633 |
2634 return contents != NULL; | 2634 return contents != NULL; |
2635 } | 2635 } |
OLD | NEW |