Commit 556f592e authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extension Functions] Remove GetExtensionWindowController

Remove ChromeAsyncExtensionFunction::GetExtensionWindowController() and
ChromeExtensionFunctionDetails::GetExtensionWindowController(). Each of
these were never used. Additionally, the behavior is very non-
deterministic, and could return any one of a number of different
windows. Instead, ExtensionFunctions should fetch the appropriate window
for the call (typically, through GetSenderWebContents()), rather than by
relying on getting any window the extension can access.

Bug: 809194

Change-Id: I00fc417cfbe4c9161f2475f50ab77fe843677faa
Reviewed-on: https://chromium-review.googlesource.com/902198Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534535}
parent 4180e560
......@@ -30,11 +30,6 @@ Browser* ChromeAsyncExtensionFunction::GetCurrentBrowser() {
return chrome_details_.GetCurrentBrowser();
}
extensions::WindowController*
ChromeAsyncExtensionFunction::GetExtensionWindowController() {
return chrome_details_.GetExtensionWindowController();
}
void ChromeAsyncExtensionFunction::SetError(const std::string& error) {
error_ = error;
}
......
......@@ -16,10 +16,6 @@ namespace content {
class WebContents;
}
namespace extensions {
class WindowController;
}
// A chrome specific analog to AsyncExtensionFunction. This has access to a
// chrome Profile.
//
......@@ -49,12 +45,11 @@ class ChromeAsyncExtensionFunction : public UIThreadExtensionFunction {
// happen if only incognito windows are open, or early in startup or shutdown
// shutdown when there are no active windows.
//
// TODO(stevenjb): Replace this with GetExtensionWindowController().
// TODO(devlin): This method is incredibly non-deterministic (sometimes just
// returning "any" browser), and almost never the right thing to use. Instead,
// use ExtensionFunction::GetSenderWebContents(). We should get rid of this.
Browser* GetCurrentBrowser();
// Same as above but uses WindowControllerList instead of BrowserList.
extensions::WindowController* GetExtensionWindowController();
void SetError(const std::string& error);
// ExtensionFunction:
......
......@@ -32,7 +32,6 @@ Profile* ChromeExtensionFunctionDetails::GetProfile() const {
return Profile::FromBrowserContext(function_->browser_context());
}
// TODO(stevenjb): Replace this with GetExtensionWindowController().
Browser* ChromeExtensionFunctionDetails::GetCurrentBrowser() const {
// If the delegate has an associated browser, return it.
if (function_->dispatcher()) {
......@@ -71,20 +70,6 @@ Browser* ChromeExtensionFunctionDetails::GetCurrentBrowser() const {
return NULL;
}
extensions::WindowController*
ChromeExtensionFunctionDetails::GetExtensionWindowController() const {
// If the delegate has an associated window controller, return it.
if (function_->dispatcher()) {
extensions::WindowController* window_controller =
function_->dispatcher()->GetExtensionWindowController();
if (window_controller)
return window_controller;
}
return extensions::WindowControllerList::GetInstance()
->CurrentWindowForFunction(function_);
}
content::WebContents*
ChromeExtensionFunctionDetails::GetAssociatedWebContents() {
if (function_->dispatcher()) {
......
......@@ -16,10 +16,6 @@ namespace content {
class WebContents;
}
namespace extensions {
class WindowController;
} // namespace extensions
// Provides Chrome-specific details to UIThreadExtensionFunction
// implementations.
class ChromeExtensionFunctionDetails {
......@@ -49,12 +45,11 @@ class ChromeExtensionFunctionDetails {
// happen if only incognito windows are open, or early in startup or shutdown
// shutdown when there are no active windows.
//
// TODO(stevenjb): Replace this with GetExtensionWindowController().
// TODO(devlin): This method is incredibly non-deterministic (sometimes just
// returning "any" browser), and almost never the right thing to use. Instead,
// use ExtensionFunction::GetSenderWebContents(). We should get rid of this.
Browser* GetCurrentBrowser() const;
// Same as above but uses WindowControllerList instead of BrowserList.
extensions::WindowController* GetExtensionWindowController() const;
// Gets the "current" web contents if any. If there is no associated web
// contents then defaults to the foremost one.
content::WebContents* GetAssociatedWebContents();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment