| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // OS_WIN | 10 #endif // OS_WIN |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 // Update commands to reflect current state. | 1098 // Update commands to reflect current state. |
| 1099 command_controller_->TabStateChanged(); | 1099 command_controller_->TabStateChanged(); |
| 1100 | 1100 |
| 1101 // Reset the status bubble. | 1101 // Reset the status bubble. |
| 1102 StatusBubble* status_bubble = GetStatusBubble(); | 1102 StatusBubble* status_bubble = GetStatusBubble(); |
| 1103 if (status_bubble) { | 1103 if (status_bubble) { |
| 1104 status_bubble->Hide(); | 1104 status_bubble->Hide(); |
| 1105 | 1105 |
| 1106 // Show the loading state (if any). | 1106 // Show the loading state (if any). |
| 1107 status_bubble->SetStatus( | 1107 status_bubble->SetStatus( |
| 1108 chrome::GetActiveTabContents(this)->core_tab_helper()->GetStatusText()); | 1108 CoreTabHelper::FromWebContents(chrome::GetActiveWebContents(this))-> |
| 1109 GetStatusText()); |
| 1109 } | 1110 } |
| 1110 | 1111 |
| 1111 if (HasFindBarController()) { | 1112 if (HasFindBarController()) { |
| 1112 find_bar_controller_->ChangeTabContents(new_contents); | 1113 find_bar_controller_->ChangeTabContents(new_contents); |
| 1113 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); | 1114 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); |
| 1114 } | 1115 } |
| 1115 | 1116 |
| 1116 // Update sessions. Don't force creation of sessions. If sessions doesn't | 1117 // Update sessions. Don't force creation of sessions. If sessions doesn't |
| 1117 // exist, the change will be picked up by sessions when created. | 1118 // exist, the change will be picked up by sessions when created. |
| 1118 SessionService* session_service = | 1119 SessionService* session_service = |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 void Browser::LoadingStateChanged(WebContents* source) { | 1314 void Browser::LoadingStateChanged(WebContents* source) { |
| 1314 window_->UpdateLoadingAnimations(tab_strip_model_->TabsAreLoading()); | 1315 window_->UpdateLoadingAnimations(tab_strip_model_->TabsAreLoading()); |
| 1315 window_->UpdateTitleBar(); | 1316 window_->UpdateTitleBar(); |
| 1316 | 1317 |
| 1317 WebContents* selected_contents = chrome::GetActiveWebContents(this); | 1318 WebContents* selected_contents = chrome::GetActiveWebContents(this); |
| 1318 if (source == selected_contents) { | 1319 if (source == selected_contents) { |
| 1319 bool is_loading = source->IsLoading(); | 1320 bool is_loading = source->IsLoading(); |
| 1320 command_controller_->LoadingStateChanged(is_loading, false); | 1321 command_controller_->LoadingStateChanged(is_loading, false); |
| 1321 if (GetStatusBubble()) { | 1322 if (GetStatusBubble()) { |
| 1322 GetStatusBubble()->SetStatus( | 1323 GetStatusBubble()->SetStatus( |
| 1323 chrome::GetActiveTabContents(this)->core_tab_helper()-> | 1324 CoreTabHelper::FromWebContents(chrome::GetActiveWebContents(this))-> |
| 1324 GetStatusText()); | 1325 GetStatusText()); |
| 1325 } | 1326 } |
| 1326 } | 1327 } |
| 1327 } | 1328 } |
| 1328 | 1329 |
| 1329 void Browser::CloseContents(WebContents* source) { | 1330 void Browser::CloseContents(WebContents* source) { |
| 1330 if (unload_controller_->CanCloseContents(source)) | 1331 if (unload_controller_->CanCloseContents(source)) |
| 1331 chrome::CloseWebContents(this, source); | 1332 chrome::CloseWebContents(this, source); |
| 1332 } | 1333 } |
| 1333 | 1334 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 void Browser::RequestMediaAccessPermission( | 1695 void Browser::RequestMediaAccessPermission( |
| 1695 content::WebContents* web_contents, | 1696 content::WebContents* web_contents, |
| 1696 const content::MediaStreamRequest* request, | 1697 const content::MediaStreamRequest* request, |
| 1697 const content::MediaResponseCallback& callback) { | 1698 const content::MediaResponseCallback& callback) { |
| 1698 RequestMediaAccessPermissionHelper(web_contents, request, callback); | 1699 RequestMediaAccessPermissionHelper(web_contents, request, callback); |
| 1699 } | 1700 } |
| 1700 | 1701 |
| 1701 /////////////////////////////////////////////////////////////////////////////// | 1702 /////////////////////////////////////////////////////////////////////////////// |
| 1702 // Browser, CoreTabHelperDelegate implementation: | 1703 // Browser, CoreTabHelperDelegate implementation: |
| 1703 | 1704 |
| 1704 void Browser::SwapTabContents(TabContents* old_tab_contents, | 1705 void Browser::SwapTabContents(content::WebContents* old_contents, |
| 1705 TabContents* new_tab_contents) { | 1706 content::WebContents* new_contents) { |
| 1706 int index = tab_strip_model_->GetIndexOfTabContents(old_tab_contents); | 1707 int index = tab_strip_model_->GetIndexOfWebContents(old_contents); |
| 1707 DCHECK_NE(TabStripModel::kNoTab, index); | 1708 DCHECK_NE(TabStripModel::kNoTab, index); |
| 1709 TabContents* new_tab_contents = TabContents::FromWebContents(new_contents); |
| 1708 tab_strip_model_->ReplaceTabContentsAt(index, new_tab_contents); | 1710 tab_strip_model_->ReplaceTabContentsAt(index, new_tab_contents); |
| 1709 } | 1711 } |
| 1710 | 1712 |
| 1711 bool Browser::CanReloadContents(TabContents* source) const { | 1713 bool Browser::CanReloadContents(content::WebContents* web_contents) const { |
| 1712 return chrome::CanReload(this); | 1714 return chrome::CanReload(this); |
| 1713 } | 1715 } |
| 1714 | 1716 |
| 1715 bool Browser::CanSaveContents(TabContents* source) const { | 1717 bool Browser::CanSaveContents(content::WebContents* web_contents) const { |
| 1716 return chrome::CanSavePage(this); | 1718 return chrome::CanSavePage(this); |
| 1717 } | 1719 } |
| 1718 | 1720 |
| 1719 /////////////////////////////////////////////////////////////////////////////// | 1721 /////////////////////////////////////////////////////////////////////////////// |
| 1720 // Browser, SearchEngineTabHelperDelegate implementation: | 1722 // Browser, SearchEngineTabHelperDelegate implementation: |
| 1721 | 1723 |
| 1722 void Browser::ConfirmAddSearchProvider(TemplateURL* template_url, | 1724 void Browser::ConfirmAddSearchProvider(TemplateURL* template_url, |
| 1723 Profile* profile) { | 1725 Profile* profile) { |
| 1724 window()->ConfirmAddSearchProvider(template_url, profile); | 1726 window()->ConfirmAddSearchProvider(template_url, profile); |
| 1725 } | 1727 } |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1999 if (contents == chrome::GetActiveWebContents(this)) { | 2001 if (contents == chrome::GetActiveWebContents(this)) { |
| 2000 // Updates that only matter when the tab is selected go here. | 2002 // Updates that only matter when the tab is selected go here. |
| 2001 | 2003 |
| 2002 if (flags & content::INVALIDATE_TYPE_PAGE_ACTIONS) { | 2004 if (flags & content::INVALIDATE_TYPE_PAGE_ACTIONS) { |
| 2003 LocationBar* location_bar = window()->GetLocationBar(); | 2005 LocationBar* location_bar = window()->GetLocationBar(); |
| 2004 if (location_bar) | 2006 if (location_bar) |
| 2005 location_bar->UpdatePageActions(); | 2007 location_bar->UpdatePageActions(); |
| 2006 } | 2008 } |
| 2007 // Updating the URL happens synchronously in ScheduleUIUpdate. | 2009 // Updating the URL happens synchronously in ScheduleUIUpdate. |
| 2008 if (flags & content::INVALIDATE_TYPE_LOAD && GetStatusBubble()) { | 2010 if (flags & content::INVALIDATE_TYPE_LOAD && GetStatusBubble()) { |
| 2009 GetStatusBubble()->SetStatus(chrome::GetActiveTabContents(this)-> | 2011 GetStatusBubble()->SetStatus( |
| 2010 core_tab_helper()->GetStatusText()); | 2012 CoreTabHelper::FromWebContents(chrome::GetActiveWebContents(this))-> |
| 2013 GetStatusText()); |
| 2011 } | 2014 } |
| 2012 | 2015 |
| 2013 if (flags & (content::INVALIDATE_TYPE_TAB | | 2016 if (flags & (content::INVALIDATE_TYPE_TAB | |
| 2014 content::INVALIDATE_TYPE_TITLE)) { | 2017 content::INVALIDATE_TYPE_TITLE)) { |
| 2015 window_->UpdateTitleBar(); | 2018 window_->UpdateTitleBar(); |
| 2016 } | 2019 } |
| 2017 } | 2020 } |
| 2018 | 2021 |
| 2019 // Updates that don't depend upon the selected state go here. | 2022 // Updates that don't depend upon the selected state go here. |
| 2020 if (flags & | 2023 if (flags & |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2284 if (contents && !allow_js_access) { | 2287 if (contents && !allow_js_access) { |
| 2285 contents->web_contents()->GetController().LoadURL( | 2288 contents->web_contents()->GetController().LoadURL( |
| 2286 target_url, | 2289 target_url, |
| 2287 content::Referrer(), | 2290 content::Referrer(), |
| 2288 content::PAGE_TRANSITION_LINK, | 2291 content::PAGE_TRANSITION_LINK, |
| 2289 std::string()); // No extra headers. | 2292 std::string()); // No extra headers. |
| 2290 } | 2293 } |
| 2291 | 2294 |
| 2292 return contents != NULL; | 2295 return contents != NULL; |
| 2293 } | 2296 } |
| OLD | NEW |