summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-10 14:56:05 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-10 14:56:05 +0000
commit2ec35998d46588cc18fb551f0cd859835345ed60 (patch)
tree31c09afd8a8b92ab7fd2f2a7effc087bd0645876
parent5f8b07e04e7dcae82fb378b703911d8127c699b6 (diff)
downloadchromium_src-2ec35998d46588cc18fb551f0cd859835345ed60.zip
chromium_src-2ec35998d46588cc18fb551f0cd859835345ed60.tar.gz
chromium_src-2ec35998d46588cc18fb551f0cd859835345ed60.tar.bz2
Speculative revert to see if this change introduced a performance regression on Mac intl perf bots.
If this change was responsible for this regression, it may also have been responsible for http://crbug.com/133762 http://crbug.com/138260 TEST=mac intl perf bot drops: http://build.chromium.org/f/chromium/perf/mac-release-10.5/intl1/report.html?history=150&rev=-1 Review URL: https://chromiumcodereview.appspot.com/10837192 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151036 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autofill/autofill_feedback_infobar_delegate.cc3
-rw-r--r--chrome/browser/automation/automation_provider.cc9
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc7
-rw-r--r--chrome/browser/sessions/session_restore.cc10
-rw-r--r--chrome/browser/sessions/tab_restore_service.cc6
-rw-r--r--chrome/browser/sessions/tab_restore_service.h5
-rw-r--r--chrome/browser/sessions/tab_restore_service_browsertest.cc30
-rw-r--r--chrome/browser/sessions/tab_restore_service_delegate.h7
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc7
-rw-r--r--chrome/browser/tab_contents/web_drag_bookmark_handler_aura.cc4
-rw-r--r--chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc4
-rw-r--r--chrome/browser/tab_contents/web_drag_bookmark_handler_mac.mm4
-rw-r--r--chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc4
-rw-r--r--chrome/browser/ui/android/tab_restore_service_delegate_android.cc6
-rw-r--r--chrome/browser/ui/browser_finder.cc17
-rw-r--r--chrome/browser/ui/browser_finder.h8
-rw-r--r--chrome/browser/ui/browser_tab_restore_service_delegate.cc18
-rw-r--r--chrome/browser/ui/browser_tab_strip_model_delegate.cc3
-rw-r--r--chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm2
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_controller.cc11
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc3
-rw-r--r--chrome/browser/ui/views/sad_tab_view.cc3
-rw-r--r--chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.cc4
23 files changed, 103 insertions, 72 deletions
diff --git a/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc b/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc
index 4adf84f..f152166 100644
--- a/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc
+++ b/chrome/browser/autofill/autofill_feedback_infobar_delegate.cc
@@ -46,7 +46,8 @@ string16 AutofillFeedbackInfoBarDelegate::GetLinkText() const {
bool AutofillFeedbackInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
chrome::ShowFeedbackPage(
- browser::FindBrowserWithWebContents(owner()->web_contents()),
+ browser::FindBrowserForController(
+ &owner()->web_contents()->GetController(), NULL),
feedback_message_,
std::string(kCategoryTagAutofill));
return true;
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 78f5740..31acc47 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -468,10 +468,11 @@ bool AutomationProvider::Send(IPC::Message* msg) {
Browser* AutomationProvider::FindAndActivateTab(
NavigationController* controller) {
- content::WebContentsDelegate* d = controller->GetWebContents()->GetDelegate();
- if (d)
- d->ActivateContents(controller->GetWebContents());
- return browser::FindBrowserWithWebContents(controller->GetWebContents());
+ int tab_index;
+ Browser* browser = browser::FindBrowserForController(controller, &tab_index);
+ if (browser)
+ chrome::ActivateTabAt(browser, tab_index, true);
+ return browser;
}
void AutomationProvider::HandleFindRequest(
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index e35bf73..4114001 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -541,8 +541,8 @@ void TestingAutomationProvider::CloseTab(int tab_handle,
IPC::Message* reply_message) {
if (tab_tracker_->ContainsHandle(tab_handle)) {
NavigationController* controller = tab_tracker_->GetResource(tab_handle);
- Browser* browser = browser::FindBrowserWithWebContents(
- controller->GetWebContents());
+ int index;
+ Browser* browser = browser::FindBrowserForController(controller, &index);
DCHECK(browser);
new TabClosedNotificationObserver(this, wait_until_closed, reply_message,
false);
@@ -1060,8 +1060,7 @@ void TestingAutomationProvider::GetTabIndex(int handle, int* tabstrip_index) {
if (tab_tracker_->ContainsHandle(handle)) {
NavigationController* tab = tab_tracker_->GetResource(handle);
- Browser* browser = browser::FindBrowserWithWebContents(
- tab->GetWebContents());
+ Browser* browser = browser::FindBrowserForController(tab, NULL);
*tabstrip_index = chrome::GetIndexOfTab(browser, tab->GetWebContents());
}
}
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index 2906eec..c1264ff 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -267,10 +267,10 @@ void TabLoader::LoadNextTab() {
max_parallel_tab_loads_ = tabs_loading_.size();
tabs_to_load_.pop_front();
tab->LoadIfNecessary();
- content::WebContents* contents = tab->GetWebContents();
- if (contents) {
- Browser* browser = browser::FindBrowserWithWebContents(contents);
- if (browser && chrome::GetActiveWebContents(browser) != contents) {
+ if (tab->GetWebContents()) {
+ int tab_index;
+ Browser* browser = browser::FindBrowserForController(tab, &tab_index);
+ if (browser && browser->active_index() != tab_index) {
// By default tabs are marked as visible. As only the active tab is
// visible we need to explicitly tell non-active tabs they are hidden.
// Without this call non-active tabs are not marked as backgrounded.
@@ -278,7 +278,7 @@ void TabLoader::LoadNextTab() {
// NOTE: We need to do this here rather than when the tab is added to
// the Browser as at that time not everything has been created, so that
// the call would do nothing.
- contents->WasHidden();
+ tab->GetWebContents()->WasHidden();
}
}
}
diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc
index 76d97bd..66e9e15 100644
--- a/chrome/browser/sessions/tab_restore_service.cc
+++ b/chrome/browser/sessions/tab_restore_service.cc
@@ -219,18 +219,18 @@ void TabRestoreService::RemoveObserver(TabRestoreServiceObserver* observer) {
observer_list_.RemoveObserver(observer);
}
-void TabRestoreService::CreateHistoricalTab(content::WebContents* contents,
+void TabRestoreService::CreateHistoricalTab(NavigationController* tab,
int index) {
if (restoring_)
return;
TabRestoreServiceDelegate* delegate =
- TabRestoreServiceDelegate::FindDelegateForWebContents(contents);
+ TabRestoreServiceDelegate::FindDelegateForController(tab, NULL);
if (closing_delegates_.find(delegate) != closing_delegates_.end())
return;
scoped_ptr<Tab> local_tab(new Tab());
- PopulateTab(local_tab.get(), index, delegate, &contents->GetController());
+ PopulateTab(local_tab.get(), index, delegate, tab);
if (local_tab->navigations.empty())
return;
diff --git a/chrome/browser/sessions/tab_restore_service.h b/chrome/browser/sessions/tab_restore_service.h
index 3fea7fb..12b6bda 100644
--- a/chrome/browser/sessions/tab_restore_service.h
+++ b/chrome/browser/sessions/tab_restore_service.h
@@ -26,7 +26,6 @@ struct SessionWindow;
namespace content {
class NavigationController;
class SessionStorageNamespace;
-class WebContents;
}
// TabRestoreService is responsible for maintaining the most recently closed
@@ -138,9 +137,9 @@ class TabRestoreService : public BaseSessionService {
void AddObserver(TabRestoreServiceObserver* observer);
void RemoveObserver(TabRestoreServiceObserver* observer);
- // Creates a Tab to represent |contents| and notifies observers the list of
+ // Creates a Tab to represent |tab| and notifies observers the list of
// entries has changed.
- void CreateHistoricalTab(content::WebContents* contents, int index);
+ void CreateHistoricalTab(content::NavigationController* tab, int index);
// Invoked when a browser is closing. If |delegate| is a tabbed browser with
// at least one tab, a Window is created, added to entries and observers are
diff --git a/chrome/browser/sessions/tab_restore_service_browsertest.cc b/chrome/browser/sessions/tab_restore_service_browsertest.cc
index b97c854..9aa06c8 100644
--- a/chrome/browser/sessions/tab_restore_service_browsertest.cc
+++ b/chrome/browser/sessions/tab_restore_service_browsertest.cc
@@ -16,13 +16,11 @@
#include "chrome/test/base/chrome_render_view_test.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/test/render_view_test.h"
-#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_utils.h"
#include "content/public/test/web_contents_tester.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -52,8 +50,7 @@ class TabRestoreTimeFactory : public TabRestoreService::TimeFactory {
class TabRestoreServiceTest : public ChromeRenderViewHostTestHarness {
public:
- TabRestoreServiceTest()
- : ui_thread_(content::BrowserThread::UI, &message_loop_) {
+ TabRestoreServiceTest() {
url1_ = GURL("http://1");
url2_ = GURL("http://2");
url3_ = GURL("http://3");
@@ -143,14 +140,13 @@ class TabRestoreServiceTest : public ChromeRenderViewHostTestHarness {
TabRestoreTimeFactory* time_factory_;
content::RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox
webkit_platform_support_;
- content::TestBrowserThread ui_thread_;
};
TEST_F(TabRestoreServiceTest, Basic) {
AddThreeNavigations();
// Have the service record the tab.
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
// Make sure an entry was created.
ASSERT_EQ(1U, service_->entries().size());
@@ -172,7 +168,7 @@ TEST_F(TabRestoreServiceTest, Basic) {
NavigateToIndex(1);
// And check again.
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
// There should be two entries now.
ASSERT_EQ(2U, service_->entries().size());
@@ -194,7 +190,7 @@ TEST_F(TabRestoreServiceTest, Basic) {
// Make sure TabRestoreService doesn't create an entry for a tab with no
// navigations.
TEST_F(TabRestoreServiceTest, DontCreateEmptyTab) {
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
EXPECT_TRUE(service_->entries().empty());
}
@@ -203,7 +199,7 @@ TEST_F(TabRestoreServiceTest, Restore) {
AddThreeNavigations();
// Have the service record the tab.
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
// Recreate the service and have it load the tabs.
RecreateService();
@@ -230,7 +226,7 @@ TEST_F(TabRestoreServiceTest, RestorePinnedAndApp) {
AddThreeNavigations();
// Have the service record the tab.
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
// One entry should be created.
ASSERT_EQ(1U, service_->entries().size());
@@ -300,7 +296,7 @@ TEST_F(TabRestoreServiceTest, DontPersistPostData) {
controller().GetEntryAtIndex(2)->SetHasPostData(true);
// Have the service record the tab.
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
ASSERT_EQ(1U, service_->entries().size());
// Recreate the service and have it load the tabs.
@@ -327,7 +323,7 @@ TEST_F(TabRestoreServiceTest, DontLoadTwice) {
AddThreeNavigations();
// Have the service record the tab.
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
ASSERT_EQ(1U, service_->entries().size());
// Recreate the service and have it load the tabs.
@@ -400,7 +396,7 @@ TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabs) {
AddThreeNavigations();
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
RecreateService();
@@ -443,7 +439,7 @@ TEST_F(TabRestoreServiceTest, LoadPreviousSessionAndTabsPinned) {
AddThreeNavigations();
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
RecreateService();
@@ -487,7 +483,7 @@ TEST_F(TabRestoreServiceTest, ManyWindowsInSessionService) {
AddThreeNavigations();
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
RecreateService();
@@ -516,7 +512,7 @@ TEST_F(TabRestoreServiceTest, TimestampSurvivesRestore) {
AddThreeNavigations();
// Have the service record the tab.
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
// Make sure an entry was created.
ASSERT_EQ(1U, service_->entries().size());
@@ -644,7 +640,7 @@ TEST_F(TabRestoreServiceTest, PruneIsCalled) {
const size_t max_entries = TabRestoreService::kMaxEntries;
for (size_t i = 0; i < max_entries + 5; i++) {
NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i))));
- service_->CreateHistoricalTab(contents(), -1);
+ service_->CreateHistoricalTab(&controller(), -1);
}
EXPECT_EQ(max_entries, service_->entries_.size());
diff --git a/chrome/browser/sessions/tab_restore_service_delegate.h b/chrome/browser/sessions/tab_restore_service_delegate.h
index f2d9074..b46c05f 100644
--- a/chrome/browser/sessions/tab_restore_service_delegate.h
+++ b/chrome/browser/sessions/tab_restore_service_delegate.h
@@ -64,9 +64,10 @@ class TabRestoreServiceDelegate {
static TabRestoreServiceDelegate* Create(Profile* profile,
const std::string& app_name);
- // see browser::FindBrowserForWebContents
- static TabRestoreServiceDelegate* FindDelegateForWebContents(
- const content::WebContents* contents);
+ // see browser::FindBrowserForController
+ static TabRestoreServiceDelegate* FindDelegateForController(
+ const content::NavigationController* controller,
+ int* index);
// see browser::FindBrowserWithID
static TabRestoreServiceDelegate* FindDelegateWithID(
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index d668e7a..35f8806 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -1720,8 +1720,7 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: {
NavigationController* controller = &source_web_contents_->GetController();
NavigationEntry* nav_entry = controller->GetActiveEntry();
- Browser* browser =
- browser::FindBrowserWithWebContents(source_web_contents_);
+ Browser* browser = browser::FindBrowserForController(controller, NULL);
chrome::ShowPageInfo(browser, source_web_contents_, nav_entry->GetURL(),
nav_entry->GetSSL(), true);
break;
@@ -1762,8 +1761,8 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
break;
case IDC_CONTENT_CONTEXT_VIEWFRAMEINFO: {
- Browser* browser = browser::FindBrowserWithWebContents(
- source_web_contents_);
+ Browser* browser = browser::FindBrowserForController(
+ &source_web_contents_->GetController(), NULL);
chrome::ShowPageInfo(browser, source_web_contents_, params_.frame_url,
params_.security_info, false);
break;
diff --git a/chrome/browser/tab_contents/web_drag_bookmark_handler_aura.cc b/chrome/browser/tab_contents/web_drag_bookmark_handler_aura.cc
index 90c4665..2c72c63 100644
--- a/chrome/browser/tab_contents/web_drag_bookmark_handler_aura.cc
+++ b/chrome/browser/tab_contents/web_drag_bookmark_handler_aura.cc
@@ -69,8 +69,8 @@ void WebDragBookmarkHandlerAura::OnDrop() {
}
// Focus the target browser.
- Browser* browser = browser::FindBrowserWithWebContents(
- tab_->web_contents());
+ Browser* browser = browser::FindBrowserForController(
+ &tab_->web_contents()->GetController(), NULL);
if (browser)
browser->window()->Show();
}
diff --git a/chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc b/chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc
index 83ab25e..1f80169 100644
--- a/chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc
+++ b/chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc
@@ -84,8 +84,8 @@ void WebDragBookmarkHandlerGtk::OnDrop() {
}
// Focus the target browser.
- Browser* browser = browser::FindBrowserWithWebContents(
- tab_->web_contents());
+ Browser* browser = browser::FindBrowserForController(
+ &tab_->web_contents()->GetController(), NULL);
if (browser)
browser->window()->Show();
}
diff --git a/chrome/browser/tab_contents/web_drag_bookmark_handler_mac.mm b/chrome/browser/tab_contents/web_drag_bookmark_handler_mac.mm
index bf2bc5a..dd35065 100644
--- a/chrome/browser/tab_contents/web_drag_bookmark_handler_mac.mm
+++ b/chrome/browser/tab_contents/web_drag_bookmark_handler_mac.mm
@@ -51,8 +51,8 @@ void WebDragBookmarkHandlerMac::OnDrop() {
}
// Focus the target browser.
- Browser* browser = browser::FindBrowserWithWebContents(
- tab_->web_contents());
+ Browser* browser = browser::FindBrowserForController(
+ &tab_->web_contents()->GetController(), NULL);
if (browser)
browser->window()->Show();
}
diff --git a/chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc b/chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc
index 277d25a..6e0fcbb 100644
--- a/chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc
+++ b/chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc
@@ -75,8 +75,8 @@ void WebDragBookmarkHandlerWin::OnDrop(IDataObject* data_object) {
}
// Focus the target browser.
- Browser* browser = browser::FindBrowserWithWebContents(
- tab_->web_contents());
+ Browser* browser = browser::FindBrowserForController(
+ &tab_->web_contents()->GetController(), NULL);
if (browser)
browser->window()->Show();
}
diff --git a/chrome/browser/ui/android/tab_restore_service_delegate_android.cc b/chrome/browser/ui/android/tab_restore_service_delegate_android.cc
index a220719..c2f5ccd 100644
--- a/chrome/browser/ui/android/tab_restore_service_delegate_android.cc
+++ b/chrome/browser/ui/android/tab_restore_service_delegate_android.cc
@@ -7,9 +7,9 @@
#include "content/public/browser/navigation_controller.h"
// static
-TabRestoreServiceDelegate*
- TabRestoreServiceDelegate::FindDelegateForWebContents(
- const content::WebContents* contents) {
+TabRestoreServiceDelegate* TabRestoreServiceDelegate::FindDelegateForController(
+ const content::NavigationController* controller,
+ int* index) {
// We don't restore tabs using TabRestoreService yet.
return NULL;
}
diff --git a/chrome/browser/ui/browser_finder.cc b/chrome/browser/ui/browser_finder.cc
index 7877afd..a363c39 100644
--- a/chrome/browser/ui/browser_finder.cc
+++ b/chrome/browser/ui/browser_finder.cc
@@ -153,6 +153,23 @@ Browser* FindBrowserWithWebContents(const WebContents* web_contents) {
return NULL;
}
+Browser* FindBrowserForController(
+ const content::NavigationController* controller,
+ int* index_result) {
+ for (BrowserList::const_iterator it = BrowserList::begin();
+ it != BrowserList::end(); ++it) {
+ int index = (*it)->tab_strip_model()->GetIndexOfWebContents(
+ controller->GetWebContents());
+ if (index != TabStripModel::kNoTab) {
+ if (index_result)
+ *index_result = index;
+ return *it;
+ }
+ }
+ return NULL;
+}
+
+
Browser* FindLastActiveWithProfile(Profile* profile) {
// We are only interested in last active browsers, so we don't fall back to
// all browsers like FindBrowserWith* do.
diff --git a/chrome/browser/ui/browser_finder.h b/chrome/browser/ui/browser_finder.h
index 76b49c3..731806c 100644
--- a/chrome/browser/ui/browser_finder.h
+++ b/chrome/browser/ui/browser_finder.h
@@ -52,6 +52,14 @@ Browser* FindBrowserWithWindow(gfx::NativeWindow window);
// |web_contents| must not be NULL.
Browser* FindBrowserWithWebContents(const content::WebContents* web_contents);
+// Returns the Browser which contains the tab with the given
+// NavigationController, also filling in |index| (if valid) with the tab's index
+// in the tab strip. Returns NULL if not found. This call is O(N) in the
+// number of tabs.
+Browser* FindBrowserForController(
+ const content::NavigationController* controller,
+ int* index);
+
// Identical in behavior to BrowserList::GetLastActive(), except that the most
// recently open browser owned by |profile| is returned. If none exist, returns
// NULL. WARNING: see warnings in BrowserList::GetLastActive().
diff --git a/chrome/browser/ui/browser_tab_restore_service_delegate.cc b/chrome/browser/ui/browser_tab_restore_service_delegate.cc
index 2e9ad7f..f94441c 100644
--- a/chrome/browser/ui/browser_tab_restore_service_delegate.cc
+++ b/chrome/browser/ui/browser_tab_restore_service_delegate.cc
@@ -100,16 +100,22 @@ TabRestoreServiceDelegate* TabRestoreServiceDelegate::Create(
}
// static
-TabRestoreServiceDelegate*
- TabRestoreServiceDelegate::FindDelegateForWebContents(
- const WebContents* contents) {
- Browser* browser = browser::FindBrowserWithWebContents(contents);
- return browser ? browser->tab_restore_service_delegate() : NULL;
+TabRestoreServiceDelegate* TabRestoreServiceDelegate::FindDelegateForController(
+ const NavigationController* controller,
+ int* index) {
+ Browser* browser = browser::FindBrowserForController(controller, index);
+ if (browser)
+ return browser->tab_restore_service_delegate();
+ else
+ return NULL;
}
// static
TabRestoreServiceDelegate* TabRestoreServiceDelegate::FindDelegateWithID(
SessionID::id_type desired_id) {
Browser* browser = browser::FindBrowserWithID(desired_id);
- return browser ? browser->tab_restore_service_delegate() : NULL;
+ if (browser)
+ return browser->tab_restore_service_delegate();
+ else
+ return NULL;
}
diff --git a/chrome/browser/ui/browser_tab_strip_model_delegate.cc b/chrome/browser/ui/browser_tab_strip_model_delegate.cc
index e60fca9..d543b4f 100644
--- a/chrome/browser/ui/browser_tab_strip_model_delegate.cc
+++ b/chrome/browser/ui/browser_tab_strip_model_delegate.cc
@@ -131,7 +131,8 @@ void BrowserTabStripModelDelegate::CreateHistoricalTab(TabContents* contents) {
// We only create historical tab entries for tabbed browser windows.
if (service && browser_->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP)) {
- service->CreateHistoricalTab(contents->web_contents(),
+ service->CreateHistoricalTab(
+ &contents->web_contents()->GetController(),
browser_->tab_strip_model()->GetIndexOfTabContents(contents));
}
}
diff --git a/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm b/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm
index 61c8fc1..6eb11f4 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm
@@ -106,7 +106,7 @@ bool LocationIconDecoration::OnMousePressed(NSRect frame) {
NOTREACHED();
return true;
}
- Browser* browser = browser::FindBrowserWithWebContents(tab);
+ Browser* browser = browser::FindBrowserForController(&controller, NULL);
chrome::ShowPageInfo(browser, tab, nav_entry->GetURL(), nav_entry->GetSSL(),
true);
return true;
diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.cc b/chrome/browser/ui/intents/web_intent_picker_controller.cc
index af08309..ee97269 100644
--- a/chrome/browser/ui/intents/web_intent_picker_controller.cc
+++ b/chrome/browser/ui/intents/web_intent_picker_controller.cc
@@ -305,8 +305,9 @@ void WebIntentPickerController::OnServiceChosen(const GURL& url,
break;
case WebIntentPickerModel::DISPOSITION_WINDOW: {
- Browser* browser = browser::FindBrowserWithWebContents(
- tab_contents_->web_contents());
+ int index = TabStripModel::kNoTab;
+ Browser* browser = browser::FindBrowserForController(
+ &tab_contents_->web_contents()->GetController(), &index);
TabContents* contents = chrome::TabContentsFactory(
tab_contents_->profile(),
tab_util::GetSiteInstanceForNewTab(
@@ -467,10 +468,10 @@ void WebIntentPickerController::OnSendReturnMessage(
if (service_tab_ &&
reply_type != webkit_glue::WEB_INTENT_SERVICE_CONTENTS_CLOSED) {
- Browser* browser = browser::FindBrowserWithWebContents(service_tab_);
+ int index = TabStripModel::kNoTab;
+ Browser* browser = browser::FindBrowserForController(
+ &service_tab_->GetController(), &index);
if (browser) {
- int index = browser->tab_strip_model()->GetIndexOfWebContents(
- service_tab_);
browser->tab_strip_model()->CloseTabContentsAt(
index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 77f8772..803b2ac 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -1148,7 +1148,8 @@ void LocationBarView::RefreshPageActionViews() {
WebContents* contents = GetWebContentsFromDelegate(delegate_);
if (!page_action_views_.empty() && contents) {
- Browser* browser = browser::FindBrowserWithWebContents(contents);
+ Browser* browser =
+ browser::FindBrowserForController(&contents->GetController(), NULL);
GURL url = chrome::GetActiveWebContents(browser)->GetURL();
for (PageActionViews::const_iterator i(page_action_views_.begin());
diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc
index 8ce3459..5c61ac5 100644
--- a/chrome/browser/ui/views/sad_tab_view.cc
+++ b/chrome/browser/ui/views/sad_tab_view.cc
@@ -122,7 +122,8 @@ void SadTabView::LinkClicked(views::Link* source, int event_flags) {
web_contents_->OpenURL(params);
} else if (source == feedback_link_) {
chrome::ShowFeedbackPage(
- browser::FindBrowserWithWebContents(web_contents_),
+ browser::FindBrowserForController(&web_contents_->GetController(),
+ NULL),
l10n_util::GetStringUTF8(IDS_KILLED_TAB_FEEDBACK_MESSAGE),
std::string(kCategoryTagCrash));
}
diff --git a/chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.cc b/chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.cc
index e308f85..38ce0df 100644
--- a/chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.cc
+++ b/chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.cc
@@ -96,8 +96,8 @@ void RecentlyClosedTabsHandler::HandleReopenTab(const ListValue* args) {
session_tab, NEW_FOREGROUND_TAB);
#else
TabRestoreServiceDelegate* delegate =
- TabRestoreServiceDelegate::FindDelegateForWebContents(
- web_ui()->GetWebContents());
+ TabRestoreServiceDelegate::FindDelegateForController(
+ &web_ui()->GetWebContents()->GetController(), NULL);
if (!delegate)
return;
WindowOpenDisposition disposition =