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

Side by Side Diff: chrome/browser/extensions/api/tabs/windows_util.cc

Issue 543873002: Add ChromeExtensionFunctionDetails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
OLDNEW
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/chrome_extension_function_details.h"
10 #include "chrome/browser/extensions/window_controller.h" 11 #include "chrome/browser/extensions/window_controller.h"
11 #include "chrome/browser/extensions/window_controller_list.h" 12 #include "chrome/browser/extensions/window_controller_list.h"
12 #include "extensions/browser/extension_function_dispatcher.h" 13 #include "extensions/browser/extension_function_dispatcher.h"
13 #include "extensions/common/constants.h" 14 #include "extensions/common/constants.h"
14 #include "extensions/common/error_utils.h" 15 #include "extensions/common/error_utils.h"
15 16
16 namespace windows_util { 17 namespace windows_util {
17 18
18 bool GetWindowFromWindowID(ChromeUIThreadExtensionFunction* function, 19 bool GetWindowFromWindowID(ChromeUIThreadExtensionFunction* function,
19 int window_id, 20 int window_id,
20 extensions::WindowController** controller) { 21 extensions::WindowController** controller) {
22 ChromeExtensionFunctionDetails function_details(function);
21 if (window_id == extension_misc::kCurrentWindowId) { 23 if (window_id == extension_misc::kCurrentWindowId) {
22 extensions::WindowController* extension_window_controller = 24 extensions::WindowController* extension_window_controller =
23 function->dispatcher()->delegate()->GetExtensionWindowController(); 25 function->dispatcher()->delegate()->GetExtensionWindowController();
24 // If there is a window controller associated with this extension, use that. 26 // If there is a window controller associated with this extension, use that.
25 if (extension_window_controller) { 27 if (extension_window_controller) {
26 *controller = extension_window_controller; 28 *controller = extension_window_controller;
27 } else { 29 } else {
28 // Otherwise get the focused or most recently added window. 30 // Otherwise get the focused or most recently added window.
29 *controller = extensions::WindowControllerList::GetInstance()-> 31 *controller = extensions::WindowControllerList::GetInstance()
30 CurrentWindowForFunction(function); 32 ->CurrentWindowForFunction(function_details);
31 } 33 }
32 if (!(*controller)) { 34 if (!(*controller)) {
33 function->SetError(extensions::tabs_constants::kNoCurrentWindowError); 35 function->SetError(extensions::tabs_constants::kNoCurrentWindowError);
34 return false; 36 return false;
35 } 37 }
36 } else { 38 } else {
37 *controller = extensions::WindowControllerList::GetInstance()-> 39 *controller = extensions::WindowControllerList::GetInstance()
38 FindWindowForFunctionById(function, window_id); 40 ->FindWindowForFunctionById(function_details, window_id);
39 if (!(*controller)) { 41 if (!(*controller)) {
40 function->SetError(extensions::ErrorUtils::FormatErrorMessage( 42 function->SetError(extensions::ErrorUtils::FormatErrorMessage(
41 extensions::tabs_constants::kWindowNotFoundError, 43 extensions::tabs_constants::kWindowNotFoundError,
42 base::IntToString(window_id))); 44 base::IntToString(window_id)));
43 return false; 45 return false;
44 } 46 }
45 } 47 }
46 return true; 48 return true;
47 } 49 }
48 50
49 } // namespace windows_util 51 } // namespace windows_util
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_api.cc ('k') | chrome/browser/extensions/chrome_extension_function.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698