Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: chrome/browser/extensions/chrome_extension_function_details.cc

Issue 2296603005: [Extensions] Reuse ChromeExtensionFunctionDetails (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/chrome_extension_function_details.cc
diff --git a/chrome/browser/extensions/chrome_extension_function_details.cc b/chrome/browser/extensions/chrome_extension_function_details.cc
index 7ebed1459019678b580b8ee41d466de02298070c..daccbc4ca456bf42829f67db4270990fe1cb1d41 100644
--- a/chrome/browser/extensions/chrome_extension_function_details.cc
+++ b/chrome/browser/extensions/chrome_extension_function_details.cc
@@ -56,14 +56,14 @@ Browser* ChromeExtensionFunctionDetails::GetCurrentBrowser() const {
// |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.
- if (function_->render_frame_host()) {
- Profile* profile = Profile::FromBrowserContext(
- function_->render_frame_host()->GetProcess()->GetBrowserContext());
- Browser* browser =
- chrome::FindAnyBrowser(profile, function_->include_incognito());
- if (browser)
- return browser;
- }
+ content::WebContents* web_contents = function_->GetSenderWebContents();
+ Profile* profile = Profile::FromBrowserContext(
+ web_contents ? web_contents->GetBrowserContext()
+ : function_->browser_context());
+ Browser* browser =
+ chrome::FindAnyBrowser(profile, function_->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
@@ -91,9 +91,12 @@ ChromeExtensionFunctionDetails::GetExtensionWindowController() const {
content::WebContents*
ChromeExtensionFunctionDetails::GetAssociatedWebContents() {
- content::WebContents* web_contents = function_->GetAssociatedWebContents();
- if (web_contents)
- return web_contents;
+ if (function_->dispatcher()) {
lazyboy 2016/08/31 20:48:24 Feels a bit odd that function::GetAssocWC goes fro
Devlin 2016/08/31 20:56:39 Agreed - but it seems better than having 100% dupl
lazyboy 2016/08/31 21:21:42 Acknowledged.
+ content::WebContents* web_contents =
+ function_->dispatcher()->GetAssociatedWebContents();
+ if (web_contents)
+ return web_contents;
+ }
Browser* browser = GetCurrentBrowser();
if (!browser)

Powered by Google App Engine
This is Rietveld 408576698