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/api/tabs/windows_util.h" | 5 #include "chrome/browser/extensions/api/tabs/windows_util.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 8 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
9 #include "chrome/browser/extensions/chrome_extension_function.h" | 9 #include "chrome/browser/extensions/chrome_extension_function.h" |
10 #include "chrome/browser/extensions/window_controller.h" | 10 #include "chrome/browser/extensions/window_controller.h" |
11 #include "chrome/browser/extensions/window_controller_list.h" | 11 #include "chrome/browser/extensions/window_controller_list.h" |
12 #include "extensions/browser/extension_function_dispatcher.h" | 12 #include "extensions/browser/extension_function_dispatcher.h" |
13 #include "extensions/common/constants.h" | 13 #include "extensions/common/constants.h" |
14 #include "extensions/common/error_utils.h" | 14 #include "extensions/common/error_utils.h" |
15 | 15 |
16 namespace windows_util { | 16 namespace windows_util { |
17 | 17 |
18 bool GetWindowFromWindowID(ChromeAsyncExtensionFunction* function, | 18 bool GetWindowFromWindowID(ChromeUIThreadExtensionFunction* function, |
19 int window_id, | 19 int window_id, |
20 extensions::WindowController** controller) { | 20 extensions::WindowController** controller) { |
21 if (window_id == extension_misc::kCurrentWindowId) { | 21 if (window_id == extension_misc::kCurrentWindowId) { |
22 extensions::WindowController* extension_window_controller = | 22 extensions::WindowController* extension_window_controller = |
23 function->dispatcher()->delegate()->GetExtensionWindowController(); | 23 function->dispatcher()->delegate()->GetExtensionWindowController(); |
24 // If there is a window controller associated with this extension, use that. | 24 // If there is a window controller associated with this extension, use that. |
25 if (extension_window_controller) { | 25 if (extension_window_controller) { |
26 *controller = extension_window_controller; | 26 *controller = extension_window_controller; |
27 } else { | 27 } else { |
28 // Otherwise get the focused or most recently added window. | 28 // Otherwise get the focused or most recently added window. |
(...skipping 11 matching lines...) Expand all Loading... |
40 function->SetError(extensions::ErrorUtils::FormatErrorMessage( | 40 function->SetError(extensions::ErrorUtils::FormatErrorMessage( |
41 extensions::tabs_constants::kWindowNotFoundError, | 41 extensions::tabs_constants::kWindowNotFoundError, |
42 base::IntToString(window_id))); | 42 base::IntToString(window_id))); |
43 return false; | 43 return false; |
44 } | 44 } |
45 } | 45 } |
46 return true; | 46 return true; |
47 } | 47 } |
48 | 48 |
49 } // namespace windows_util | 49 } // namespace windows_util |
OLD | NEW |