OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.h" | 5 #include "chrome/browser/extensions/chrome_extension_function.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "chrome/browser/extensions/chrome_extension_function_details.h" | 9 #include "chrome/browser/extensions/chrome_extension_function_details.h" |
10 #include "chrome/browser/extensions/window_controller.h" | 10 #include "chrome/browser/extensions/window_controller.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // is true, we will also search browsers in the incognito version of this | 44 // is true, we will also search browsers in the incognito version of this |
45 // profile. Note that the profile may already be incognito, in which case | 45 // profile. Note that the profile may already be incognito, in which case |
46 // we will search the incognito version only, regardless of the value of | 46 // we will search the incognito version only, regardless of the value of |
47 // |include_incognito|. Look only for browsers on the active desktop as it is | 47 // |include_incognito|. Look only for browsers on the active desktop as it is |
48 // preferable to pretend no browser is open then to return a browser on | 48 // preferable to pretend no browser is open then to return a browser on |
49 // another desktop. | 49 // another desktop. |
50 content::WebContents* web_contents = GetSenderWebContents(); | 50 content::WebContents* web_contents = GetSenderWebContents(); |
51 if (web_contents) { | 51 if (web_contents) { |
52 Profile* profile = | 52 Profile* profile = |
53 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 53 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
54 Browser* browser = chrome::FindAnyBrowser( | 54 Browser* browser = chrome::FindAnyBrowser(profile, include_incognito_); |
55 profile, include_incognito_, chrome::GetActiveDesktop()); | |
56 if (browser) | 55 if (browser) |
57 return browser; | 56 return browser; |
58 } | 57 } |
59 | 58 |
60 // NOTE(rafaelw): This can return NULL in some circumstances. In particular, | 59 // NOTE(rafaelw): This can return NULL in some circumstances. In particular, |
61 // a background_page onload chrome.tabs api call can make it into here | 60 // a background_page onload chrome.tabs api call can make it into here |
62 // before the browser is sufficiently initialized to return here, or | 61 // before the browser is sufficiently initialized to return here, or |
63 // all of this profile's browser windows may have been closed. | 62 // all of this profile's browser windows may have been closed. |
64 // A similar situation may arise during shutdown. | 63 // A similar situation may arise during shutdown. |
65 // TODO(rafaelw): Delay creation of background_page until the browser | 64 // TODO(rafaelw): Delay creation of background_page until the browser |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 ExtensionFunction::ResponseAction ChromeSyncExtensionFunction::Run() { | 119 ExtensionFunction::ResponseAction ChromeSyncExtensionFunction::Run() { |
121 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) | 120 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) |
122 : Error(error_)); | 121 : Error(error_)); |
123 } | 122 } |
124 | 123 |
125 // static | 124 // static |
126 bool ChromeSyncExtensionFunction::ValidationFailure( | 125 bool ChromeSyncExtensionFunction::ValidationFailure( |
127 ChromeSyncExtensionFunction* function) { | 126 ChromeSyncExtensionFunction* function) { |
128 return false; | 127 return false; |
129 } | 128 } |
OLD | NEW |