Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1787)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 10905301: Switch CoreTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 // Update commands to reflect current state. 1099 // Update commands to reflect current state.
1100 command_controller_->TabStateChanged(); 1100 command_controller_->TabStateChanged();
1101 1101
1102 // Reset the status bubble. 1102 // Reset the status bubble.
1103 StatusBubble* status_bubble = GetStatusBubble(); 1103 StatusBubble* status_bubble = GetStatusBubble();
1104 if (status_bubble) { 1104 if (status_bubble) {
1105 status_bubble->Hide(); 1105 status_bubble->Hide();
1106 1106
1107 // Show the loading state (if any). 1107 // Show the loading state (if any).
1108 status_bubble->SetStatus( 1108 status_bubble->SetStatus(
1109 chrome::GetActiveTabContents(this)->core_tab_helper()->GetStatusText()); 1109 CoreTabHelper::FromWebContents(chrome::GetActiveWebContents(this))->
1110 GetStatusText());
1110 } 1111 }
1111 1112
1112 if (HasFindBarController()) { 1113 if (HasFindBarController()) {
1113 find_bar_controller_->ChangeTabContents(new_contents); 1114 find_bar_controller_->ChangeTabContents(new_contents);
1114 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true); 1115 find_bar_controller_->find_bar()->MoveWindowIfNecessary(gfx::Rect(), true);
1115 } 1116 }
1116 1117
1117 // Update sessions. Don't force creation of sessions. If sessions doesn't 1118 // Update sessions. Don't force creation of sessions. If sessions doesn't
1118 // exist, the change will be picked up by sessions when created. 1119 // exist, the change will be picked up by sessions when created.
1119 SessionService* session_service = 1120 SessionService* session_service =
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 void Browser::LoadingStateChanged(WebContents* source) { 1315 void Browser::LoadingStateChanged(WebContents* source) {
1315 window_->UpdateLoadingAnimations(tab_strip_model_->TabsAreLoading()); 1316 window_->UpdateLoadingAnimations(tab_strip_model_->TabsAreLoading());
1316 window_->UpdateTitleBar(); 1317 window_->UpdateTitleBar();
1317 1318
1318 WebContents* selected_contents = chrome::GetActiveWebContents(this); 1319 WebContents* selected_contents = chrome::GetActiveWebContents(this);
1319 if (source == selected_contents) { 1320 if (source == selected_contents) {
1320 bool is_loading = source->IsLoading(); 1321 bool is_loading = source->IsLoading();
1321 command_controller_->LoadingStateChanged(is_loading, false); 1322 command_controller_->LoadingStateChanged(is_loading, false);
1322 if (GetStatusBubble()) { 1323 if (GetStatusBubble()) {
1323 GetStatusBubble()->SetStatus( 1324 GetStatusBubble()->SetStatus(
1324 chrome::GetActiveTabContents(this)->core_tab_helper()-> 1325 CoreTabHelper::FromWebContents(chrome::GetActiveWebContents(this))->
1325 GetStatusText()); 1326 GetStatusText());
1326 } 1327 }
1327 } 1328 }
1328 } 1329 }
1329 1330
1330 void Browser::CloseContents(WebContents* source) { 1331 void Browser::CloseContents(WebContents* source) {
1331 if (unload_controller_->CanCloseContents(source)) 1332 if (unload_controller_->CanCloseContents(source))
1332 chrome::CloseWebContents(this, source); 1333 chrome::CloseWebContents(this, source);
1333 } 1334 }
1334 1335
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 void Browser::RequestMediaAccessPermission( 1696 void Browser::RequestMediaAccessPermission(
1696 content::WebContents* web_contents, 1697 content::WebContents* web_contents,
1697 const content::MediaStreamRequest* request, 1698 const content::MediaStreamRequest* request,
1698 const content::MediaResponseCallback& callback) { 1699 const content::MediaResponseCallback& callback) {
1699 RequestMediaAccessPermissionHelper(web_contents, request, callback); 1700 RequestMediaAccessPermissionHelper(web_contents, request, callback);
1700 } 1701 }
1701 1702
1702 /////////////////////////////////////////////////////////////////////////////// 1703 ///////////////////////////////////////////////////////////////////////////////
1703 // Browser, CoreTabHelperDelegate implementation: 1704 // Browser, CoreTabHelperDelegate implementation:
1704 1705
1705 void Browser::SwapTabContents(TabContents* old_tab_contents, 1706 void Browser::SwapTabContents(content::WebContents* old_contents,
1706 TabContents* new_tab_contents) { 1707 content::WebContents* new_contents) {
1707 int index = tab_strip_model_->GetIndexOfTabContents(old_tab_contents); 1708 int index = tab_strip_model_->GetIndexOfWebContents(old_contents);
1708 DCHECK_NE(TabStripModel::kNoTab, index); 1709 DCHECK_NE(TabStripModel::kNoTab, index);
1710 TabContents* new_tab_contents = TabContents::FromWebContents(new_contents);
1709 tab_strip_model_->ReplaceTabContentsAt(index, new_tab_contents); 1711 tab_strip_model_->ReplaceTabContentsAt(index, new_tab_contents);
1710 } 1712 }
1711 1713
1712 bool Browser::CanReloadContents(TabContents* source) const { 1714 bool Browser::CanReloadContents(content::WebContents* web_contents) const {
1713 return chrome::CanReload(this); 1715 return chrome::CanReload(this);
1714 } 1716 }
1715 1717
1716 bool Browser::CanSaveContents(TabContents* source) const { 1718 bool Browser::CanSaveContents(content::WebContents* web_contents) const {
1717 return chrome::CanSavePage(this); 1719 return chrome::CanSavePage(this);
1718 } 1720 }
1719 1721
1720 /////////////////////////////////////////////////////////////////////////////// 1722 ///////////////////////////////////////////////////////////////////////////////
1721 // Browser, SearchEngineTabHelperDelegate implementation: 1723 // Browser, SearchEngineTabHelperDelegate implementation:
1722 1724
1723 void Browser::ConfirmAddSearchProvider(TemplateURL* template_url, 1725 void Browser::ConfirmAddSearchProvider(TemplateURL* template_url,
1724 Profile* profile) { 1726 Profile* profile) {
1725 window()->ConfirmAddSearchProvider(template_url, profile); 1727 window()->ConfirmAddSearchProvider(template_url, profile);
1726 } 1728 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 if (contents && !allow_js_access) { 2285 if (contents && !allow_js_access) {
2283 contents->web_contents()->GetController().LoadURL( 2286 contents->web_contents()->GetController().LoadURL(
2284 target_url, 2287 target_url,
2285 content::Referrer(), 2288 content::Referrer(),
2286 content::PAGE_TRANSITION_LINK, 2289 content::PAGE_TRANSITION_LINK,
2287 std::string()); // No extra headers. 2290 std::string()); // No extra headers.
2288 } 2291 }
2289 2292
2290 return contents != NULL; 2293 return contents != NULL;
2291 } 2294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698