| Index: chrome/browser/extensions/chrome_extension_function.cc
|
| diff --git a/chrome/browser/extensions/chrome_extension_function.cc b/chrome/browser/extensions/chrome_extension_function.cc
|
| index 07c3006d98fb9fc4ef3dbebc71d3783fb0ab1e5a..395a2b3dec5ddb1fed0a17eb5fc9fea7716d4cbd 100644
|
| --- a/chrome/browser/extensions/chrome_extension_function.cc
|
| +++ b/chrome/browser/extensions/chrome_extension_function.cc
|
| @@ -20,8 +20,8 @@
|
| using content::RenderViewHost;
|
| using content::WebContents;
|
|
|
| -ChromeUIThreadExtensionFunction::ChromeUIThreadExtensionFunction() {
|
| -}
|
| +ChromeUIThreadExtensionFunction::ChromeUIThreadExtensionFunction()
|
| + : chrome_details_(this) {}
|
|
|
| Profile* ChromeUIThreadExtensionFunction::GetProfile() const {
|
| return Profile::FromBrowserContext(context_);
|
| @@ -29,66 +29,17 @@ Profile* ChromeUIThreadExtensionFunction::GetProfile() const {
|
|
|
| // TODO(stevenjb): Replace this with GetExtensionWindowController().
|
| Browser* ChromeUIThreadExtensionFunction::GetCurrentBrowser() {
|
| - // If the delegate has an associated browser, return it.
|
| - if (dispatcher()) {
|
| - extensions::WindowController* window_controller =
|
| - dispatcher()->GetExtensionWindowController();
|
| - if (window_controller) {
|
| - Browser* browser = window_controller->GetBrowser();
|
| - if (browser)
|
| - return browser;
|
| - }
|
| - }
|
| -
|
| - // Otherwise, try to default to a reasonable browser. If |include_incognito_|
|
| - // is true, we will also search browsers in the incognito version of this
|
| - // profile. Note that the profile may already be incognito, in which case
|
| - // we will search the incognito version only, regardless of the value of
|
| - // |include_incognito|. Look only for browsers on the active desktop as it is
|
| - // preferable to pretend no browser is open then to return a browser on
|
| - // another desktop.
|
| - content::WebContents* web_contents = GetSenderWebContents();
|
| - Profile* profile = Profile::FromBrowserContext(
|
| - web_contents ? web_contents->GetBrowserContext() : browser_context());
|
| - Browser* browser = chrome::FindAnyBrowser(profile, include_incognito_);
|
| - if (browser)
|
| - return browser;
|
| -
|
| - // NOTE(rafaelw): This can return NULL in some circumstances. In particular,
|
| - // a background_page onload chrome.tabs api call can make it into here
|
| - // before the browser is sufficiently initialized to return here, or
|
| - // all of this profile's browser windows may have been closed.
|
| - // A similar situation may arise during shutdown.
|
| - // TODO(rafaelw): Delay creation of background_page until the browser
|
| - // is available. http://code.google.com/p/chromium/issues/detail?id=13284
|
| - return NULL;
|
| + return chrome_details_.GetCurrentBrowser();
|
| }
|
|
|
| extensions::WindowController*
|
| ChromeUIThreadExtensionFunction::GetExtensionWindowController() {
|
| - // If the delegate has an associated window controller, return it.
|
| - if (dispatcher()) {
|
| - extensions::WindowController* window_controller =
|
| - dispatcher()->GetExtensionWindowController();
|
| - if (window_controller)
|
| - return window_controller;
|
| - }
|
| -
|
| - return extensions::WindowControllerList::GetInstance()
|
| - ->CurrentWindowForFunction(this);
|
| + return chrome_details_.GetExtensionWindowController();
|
| }
|
|
|
| content::WebContents*
|
| ChromeUIThreadExtensionFunction::GetAssociatedWebContents() {
|
| - content::WebContents* web_contents =
|
| - UIThreadExtensionFunction::GetAssociatedWebContents();
|
| - if (web_contents)
|
| - return web_contents;
|
| -
|
| - Browser* browser = GetCurrentBrowser();
|
| - if (!browser)
|
| - return NULL;
|
| - return browser->tab_strip_model()->GetActiveWebContents();
|
| + return chrome_details_.GetAssociatedWebContents();
|
| }
|
|
|
| ChromeUIThreadExtensionFunction::~ChromeUIThreadExtensionFunction() {
|
|
|