diff options
author | twiz@google.com <twiz@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 19:08:45 +0000 |
---|---|---|
committer | twiz@google.com <twiz@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 19:08:45 +0000 |
commit | 5ce33e50949ca20c6196207e66125101a829237f (patch) | |
tree | aadfa014a2a0f847662af488a65dcbba50ad10ae | |
parent | 19d7e56846082459aad5c54723882f4db3703281 (diff) | |
download | chromium_src-5ce33e50949ca20c6196207e66125101a829237f.zip chromium_src-5ce33e50949ca20c6196207e66125101a829237f.tar.gz chromium_src-5ce33e50949ca20c6196207e66125101a829237f.tar.bz2 |
CL correcting Extensions regression introduced by CL 2941001.
ExtensionDOMUI::GetBrowser must return the browser in which the exension resides, not any browser matching the same profile.
BUG=60795
TEST=ExtensionApiTest.*,
Review URL: http://codereview.chromium.org/5057001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66486 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/extension_dom_ui.cc | 11 | ||||
-rw-r--r-- | chrome/browser/instant/instant_loader.cc | 5 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_delegate.cc | 7 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_delegate.h | 7 | ||||
-rw-r--r-- | chrome/browser/ui/browser_list.h | 6 | ||||
-rw-r--r-- | chrome/test/data/extensions/api_test/tabs/basics/crud.html | 35 |
6 files changed, 30 insertions, 41 deletions
diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc index 6f16484..c0522f0 100644 --- a/chrome/browser/extensions/extension_dom_ui.cc +++ b/chrome/browser/extensions/extension_dom_ui.cc @@ -185,9 +185,14 @@ void ExtensionDOMUI::ProcessDOMUIMessage( } Browser* ExtensionDOMUI::GetBrowser() const { - // TODO(beng): This is an improper direct dependency on Browser. Route this - // through some sort of delegate. - return BrowserList::FindBrowserWithProfile(DOMUI::GetProfile()); + TabContents* contents = tab_contents(); + TabContentsIterator tab_iterator; + for (; !tab_iterator.done(); ++tab_iterator) { + if (contents == *tab_iterator) + return tab_iterator.browser(); + } + + return NULL; } TabContents* ExtensionDOMUI::associated_tab_contents() const { diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc index e0ce7ec..a74f26f 100644 --- a/chrome/browser/instant/instant_loader.cc +++ b/chrome/browser/instant/instant_loader.cc @@ -249,11 +249,6 @@ class InstantLoader::TabContentsDelegateImpl : public TabContentsDelegate { virtual void SetFocusToLocationBar(bool select_all) {} virtual bool ShouldFocusPageAfterCrash() { return false; } virtual void RenderWidgetShowing() {} - virtual ExtensionFunctionDispatcher* CreateExtensionFunctionDispatcher( - RenderViewHost* render_view_host, - const std::string& extension_id) { - return NULL; - } virtual bool TakeFocus(bool reverse) { return false; } virtual void LostCapture() { CommitFromMouseReleaseIfNecessary(); diff --git a/chrome/browser/tab_contents/tab_contents_delegate.cc b/chrome/browser/tab_contents/tab_contents_delegate.cc index ddbfa99..89eef5c 100644 --- a/chrome/browser/tab_contents/tab_contents_delegate.cc +++ b/chrome/browser/tab_contents/tab_contents_delegate.cc @@ -67,13 +67,6 @@ bool TabContentsDelegate::ShouldFocusPageAfterCrash() { void TabContentsDelegate::RenderWidgetShowing() {} -ExtensionFunctionDispatcher* -TabContentsDelegate::CreateExtensionFunctionDispatcher( - RenderViewHost* render_view_host, - const std::string& extension_id) { - return NULL; -} - bool TabContentsDelegate::TakeFocus(bool reverse) { return false; } diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h index 7dfafe6..5d9ee37 100644 --- a/chrome/browser/tab_contents/tab_contents_delegate.h +++ b/chrome/browser/tab_contents/tab_contents_delegate.h @@ -30,7 +30,6 @@ class HistoryAddPageArgs; struct ContextMenuParams; class DownloadItem; -class ExtensionFunctionDispatcher; class GURL; class HtmlDialogUIDelegate; struct NativeWebKeyboardEvent; @@ -185,12 +184,6 @@ class TabContentsDelegate : public AutomationResourceRoutingDelegate { // is opened within if necessary. virtual void RenderWidgetShowing(); - // This is used when the contents is an extension that needs to route - // api calls through to the Browser process. - virtual ExtensionFunctionDispatcher* CreateExtensionFunctionDispatcher( - RenderViewHost* render_view_host, - const std::string& extension_id); - // This is called when WebKit tells us that it is done tabbing through // controls on the page. Provides a way for TabContentsDelegates to handle // this. Returns true if the delegate successfully handled it. diff --git a/chrome/browser/ui/browser_list.h b/chrome/browser/ui/browser_list.h index 02661cb..b8420d7 100644 --- a/chrome/browser/ui/browser_list.h +++ b/chrome/browser/ui/browser_list.h @@ -195,6 +195,12 @@ class TabContentsIterator { return cur_ == NULL; } + // Returns the Browser instance associated with the current TabContents. + // Valid as long as !Done() + Browser* browser() const { + return *browser_iterator_; + } + // Returns the current TabContents, valid as long as !Done() TabContents* operator->() const { return cur_; diff --git a/chrome/test/data/extensions/api_test/tabs/basics/crud.html b/chrome/test/data/extensions/api_test/tabs/basics/crud.html index 8c7188e..b9ebeee 100644 --- a/chrome/test/data/extensions/api_test/tabs/basics/crud.html +++ b/chrome/test/data/extensions/api_test/tabs/basics/crud.html @@ -1,15 +1,16 @@ <script src="tabs_util.js"></script> <script> -var firstWindowId; -var secondWindowId; -var testTabId; +var firstWindowId;
+var secondWindowId;
+var thirdWindowId;
+var testTabId;
chrome.test.runTests([ function getSelected() { chrome.tabs.getSelected(null, pass(function(tab) { assertEq(location.href, tab.url); - assertEq(location.href, tab.title); + assertEq(location.href, tab.title);
firstWindowId = tab.windowId; })); }, @@ -72,22 +73,22 @@ chrome.test.runTests([ function setupTwoWindows() { createWindow(["about:blank", "chrome://newtab/", pageUrl("a")], {}, pass(function(winId, tabIds) { - firstWindowId = winId; + secondWindowId = winId; testTabId = tabIds[2]; createWindow(["chrome://newtab/", pageUrl("b")], {}, pass(function(winId, tabIds) { - secondWindowId = winId; + thirdWindowId = winId; })); })); }, function getAllInWindow() { - chrome.tabs.getAllInWindow(firstWindowId, + chrome.tabs.getAllInWindow(secondWindowId, pass(function(tabs) { assertEq(3, tabs.length); for (var i = 0; i < tabs.length; i++) { - assertEq(firstWindowId, tabs[i].windowId); + assertEq(secondWindowId, tabs[i].windowId); assertEq(i, tabs[i].index); // The first tab should be selected @@ -98,11 +99,11 @@ chrome.test.runTests([ assertEq(pageUrl("a"), tabs[2].url); })); - chrome.tabs.getAllInWindow(secondWindowId, + chrome.tabs.getAllInWindow(thirdWindowId, pass(function(tabs) { assertEq(2, tabs.length); for (var i = 0; i < tabs.length; i++) { - assertEq(secondWindowId, tabs[i].windowId); + assertEq(thirdWindowId, tabs[i].windowId); assertEq(i, tabs[i].index); } assertEq("chrome://newtab/", tabs[0].url); @@ -110,16 +111,12 @@ chrome.test.runTests([ })); }, - /* - :: sigh :: This test used to be disabled for unrelated reasons, but while it - was, the underlying functionality was broken. crbug.com/60795 function getAllInWindowNullArg() { chrome.tabs.getAllInWindow(null, pass(function(tabs) { - assertEq(2, tabs.length); - assertEq(secondWindowId, tabs[0].windowId); + assertEq(5, tabs.length); + assertEq(firstWindowId, tabs[0].windowId); })); }, - */ function update() { chrome.tabs.get(testTabId, pass(function(tab) { @@ -137,7 +134,7 @@ chrome.test.runTests([ }, function updateSelect() { - chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) { + chrome.tabs.getAllInWindow(secondWindowId, pass(function(tabs) { assertEq(true, tabs[0].selected); assertEq(false, tabs[1].selected); assertEq(false, tabs[2].selected); @@ -146,7 +143,7 @@ chrome.test.runTests([ pass(function(tab1){ // Check update of tab[1]. chrome.test.assertEq(true, tab1.selected); - chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) { + chrome.tabs.getAllInWindow(secondWindowId, pass(function(tabs) { assertEq(true, tabs[1].selected); assertEq(false, tabs[2].selected); // Select tab[2]. @@ -155,7 +152,7 @@ chrome.test.runTests([ pass(function(tab2){ // Check update of tab[2]. chrome.test.assertEq(true, tab2.selected); - chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) { + chrome.tabs.getAllInWindow(secondWindowId, pass(function(tabs) { assertEq(false, tabs[1].selected); assertEq(true, tabs[2].selected); })); |