OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/chrome_extension_function_details.h" | 5 #include "chrome/browser/extensions/chrome_extension_function_details.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_tab_util.h" | 7 #include "chrome/browser/extensions/extension_tab_util.h" |
8 #include "chrome/browser/extensions/window_controller.h" | 8 #include "chrome/browser/extensions/window_controller.h" |
9 #include "chrome/browser/extensions/window_controller_list.h" | 9 #include "chrome/browser/extensions/window_controller_list.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // Otherwise, try to default to a reasonable browser. If |include_incognito_| | 52 // Otherwise, try to default to a reasonable browser. If |include_incognito_| |
53 // is true, we will also search browsers in the incognito version of this | 53 // is true, we will also search browsers in the incognito version of this |
54 // profile. Note that the profile may already be incognito, in which case | 54 // profile. Note that the profile may already be incognito, in which case |
55 // we will search the incognito version only, regardless of the value of | 55 // we will search the incognito version only, regardless of the value of |
56 // |include_incognito|. Look only for browsers on the active desktop as it is | 56 // |include_incognito|. Look only for browsers on the active desktop as it is |
57 // preferable to pretend no browser is open then to return a browser on | 57 // preferable to pretend no browser is open then to return a browser on |
58 // another desktop. | 58 // another desktop. |
59 if (function_->render_frame_host()) { | 59 if (function_->render_frame_host()) { |
60 Profile* profile = Profile::FromBrowserContext( | 60 Profile* profile = Profile::FromBrowserContext( |
61 function_->render_frame_host()->GetProcess()->GetBrowserContext()); | 61 function_->render_frame_host()->GetProcess()->GetBrowserContext()); |
62 Browser* browser = chrome::FindAnyBrowser( | 62 Browser* browser = |
63 profile, function_->include_incognito(), chrome::GetActiveDesktop()); | 63 chrome::FindAnyBrowser(profile, function_->include_incognito()); |
64 if (browser) | 64 if (browser) |
65 return browser; | 65 return browser; |
66 } | 66 } |
67 | 67 |
68 // NOTE(rafaelw): This can return NULL in some circumstances. In particular, | 68 // NOTE(rafaelw): This can return NULL in some circumstances. In particular, |
69 // a background_page onload chrome.tabs api call can make it into here | 69 // a background_page onload chrome.tabs api call can make it into here |
70 // before the browser is sufficiently initialized to return here, or | 70 // before the browser is sufficiently initialized to return here, or |
71 // all of this profile's browser windows may have been closed. | 71 // all of this profile's browser windows may have been closed. |
72 // A similar situation may arise during shutdown. | 72 // A similar situation may arise during shutdown. |
73 // TODO(rafaelw): Delay creation of background_page until the browser | 73 // TODO(rafaelw): Delay creation of background_page until the browser |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 extensions::WindowControllerList::GetInstance()->CurrentWindowForFunction( | 148 extensions::WindowControllerList::GetInstance()->CurrentWindowForFunction( |
149 function_); | 149 function_); |
150 if (controller) | 150 if (controller) |
151 return controller->window()->GetNativeWindow(); | 151 return controller->window()->GetNativeWindow(); |
152 | 152 |
153 // CurrentWindowForFunction() can't find app's window. | 153 // CurrentWindowForFunction() can't find app's window. |
154 WebContents* contents = GetOriginWebContents(); | 154 WebContents* contents = GetOriginWebContents(); |
155 if (contents) | 155 if (contents) |
156 return contents->GetTopLevelNativeWindow(); | 156 return contents->GetTopLevelNativeWindow(); |
157 | 157 |
158 Browser* browser = | 158 Browser* browser = chrome::FindBrowserWithProfile(GetProfile()); |
159 chrome::FindBrowserWithProfile(GetProfile(), chrome::GetActiveDesktop()); | |
160 return browser->window()->GetNativeWindow(); | 159 return browser->window()->GetNativeWindow(); |
161 } | 160 } |
OLD | NEW |