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() { ...@@ -30,11 +30,6 @@ Browser* ChromeAsyncExtensionFunction::GetCurrentBrowser() {
return chrome_details_.GetCurrentBrowser(); return chrome_details_.GetCurrentBrowser();
} }
extensions::WindowController*
ChromeAsyncExtensionFunction::GetExtensionWindowController() {
return chrome_details_.GetExtensionWindowController();
}
void ChromeAsyncExtensionFunction::SetError(const std::string& error) { void ChromeAsyncExtensionFunction::SetError(const std::string& error) {
error_ = error; error_ = error;
} }
......
...@@ -16,10 +16,6 @@ namespace content { ...@@ -16,10 +16,6 @@ namespace content {
class WebContents; class WebContents;
} }
namespace extensions {
class WindowController;
}
// A chrome specific analog to AsyncExtensionFunction. This has access to a // A chrome specific analog to AsyncExtensionFunction. This has access to a
// chrome Profile. // chrome Profile.
// //
...@@ -49,12 +45,11 @@ class ChromeAsyncExtensionFunction : public UIThreadExtensionFunction { ...@@ -49,12 +45,11 @@ class ChromeAsyncExtensionFunction : public UIThreadExtensionFunction {
// happen if only incognito windows are open, or early in startup or shutdown // happen if only incognito windows are open, or early in startup or shutdown
// shutdown when there are no active windows. // 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(); Browser* GetCurrentBrowser();
// Same as above but uses WindowControllerList instead of BrowserList.
extensions::WindowController* GetExtensionWindowController();
void SetError(const std::string& error); void SetError(const std::string& error);
// ExtensionFunction: // ExtensionFunction:
......
...@@ -32,7 +32,6 @@ Profile* ChromeExtensionFunctionDetails::GetProfile() const { ...@@ -32,7 +32,6 @@ Profile* ChromeExtensionFunctionDetails::GetProfile() const {
return Profile::FromBrowserContext(function_->browser_context()); return Profile::FromBrowserContext(function_->browser_context());
} }
// TODO(stevenjb): Replace this with GetExtensionWindowController().
Browser* ChromeExtensionFunctionDetails::GetCurrentBrowser() const { Browser* ChromeExtensionFunctionDetails::GetCurrentBrowser() const {
// If the delegate has an associated browser, return it. // If the delegate has an associated browser, return it.
if (function_->dispatcher()) { if (function_->dispatcher()) {
...@@ -71,20 +70,6 @@ Browser* ChromeExtensionFunctionDetails::GetCurrentBrowser() const { ...@@ -71,20 +70,6 @@ Browser* ChromeExtensionFunctionDetails::GetCurrentBrowser() const {
return NULL; 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* content::WebContents*
ChromeExtensionFunctionDetails::GetAssociatedWebContents() { ChromeExtensionFunctionDetails::GetAssociatedWebContents() {
if (function_->dispatcher()) { if (function_->dispatcher()) {
......
...@@ -16,10 +16,6 @@ namespace content { ...@@ -16,10 +16,6 @@ namespace content {
class WebContents; class WebContents;
} }
namespace extensions {
class WindowController;
} // namespace extensions
// Provides Chrome-specific details to UIThreadExtensionFunction // Provides Chrome-specific details to UIThreadExtensionFunction
// implementations. // implementations.
class ChromeExtensionFunctionDetails { class ChromeExtensionFunctionDetails {
...@@ -49,12 +45,11 @@ class ChromeExtensionFunctionDetails { ...@@ -49,12 +45,11 @@ class ChromeExtensionFunctionDetails {
// happen if only incognito windows are open, or early in startup or shutdown // happen if only incognito windows are open, or early in startup or shutdown
// shutdown when there are no active windows. // 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; 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 // Gets the "current" web contents if any. If there is no associated web
// contents then defaults to the foremost one. // contents then defaults to the foremost one.
content::WebContents* GetAssociatedWebContents(); 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