OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension_window_list.h" | 5 #include "chrome/browser/extensions/window_controller_list.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
10 #include "chrome/browser/sessions/session_id.h" | 10 #include "chrome/browser/sessions/session_id.h" |
11 #include "chrome/browser/ui/base_window.h" | 11 #include "chrome/browser/ui/base_window.h" |
12 | 12 |
| 13 namespace extensions { |
| 14 |
13 /////////////////////////////////////////////////////////////////////////////// | 15 /////////////////////////////////////////////////////////////////////////////// |
14 // ExtensionWindowList | 16 // WindowControllerList |
15 | 17 |
16 // static | 18 // static |
17 ExtensionWindowList* ExtensionWindowList::GetInstance() { | 19 WindowControllerList* WindowControllerList::GetInstance() { |
18 return Singleton<ExtensionWindowList>::get(); | 20 return Singleton<WindowControllerList>::get(); |
19 } | 21 } |
20 | 22 |
21 ExtensionWindowList::ExtensionWindowList() { | 23 WindowControllerList::WindowControllerList() { |
22 } | 24 } |
23 | 25 |
24 ExtensionWindowList::~ExtensionWindowList() { | 26 WindowControllerList::~WindowControllerList() { |
25 } | 27 } |
26 | 28 |
27 void ExtensionWindowList::AddExtensionWindow( | 29 void WindowControllerList::AddExtensionWindow(WindowController* window) { |
28 ExtensionWindowController* window) { | |
29 windows_.push_back(window); | 30 windows_.push_back(window); |
30 } | 31 } |
31 | 32 |
32 void ExtensionWindowList::RemoveExtensionWindow( | 33 void WindowControllerList::RemoveExtensionWindow(WindowController* window) { |
33 ExtensionWindowController* window) { | 34 ControllerList::iterator iter = std::find( |
34 WindowList::iterator iter = std::find( | |
35 windows_.begin(), windows_.end(), window); | 35 windows_.begin(), windows_.end(), window); |
36 if (iter != windows_.end()) | 36 if (iter != windows_.end()) |
37 windows_.erase(iter); | 37 windows_.erase(iter); |
38 } | 38 } |
39 | 39 |
40 ExtensionWindowController* ExtensionWindowList::FindWindowForFunctionById( | 40 WindowController* WindowControllerList::FindWindowForFunctionById( |
41 const UIThreadExtensionFunction* function, | 41 const UIThreadExtensionFunction* function, |
42 int id) const { | 42 int id) const { |
43 for (WindowList::const_iterator iter = windows().begin(); | 43 for (ControllerList::const_iterator iter = windows().begin(); |
44 iter != windows().end(); ++iter) { | 44 iter != windows().end(); ++iter) { |
45 if (function->CanOperateOnWindow(*iter) && (*iter)->GetWindowId() == id) | 45 if (function->CanOperateOnWindow(*iter) && (*iter)->GetWindowId() == id) |
46 return *iter; | 46 return *iter; |
47 } | 47 } |
48 return NULL; | 48 return NULL; |
49 } | 49 } |
50 | 50 |
51 ExtensionWindowController* ExtensionWindowList::CurrentWindowForFunction( | 51 WindowController* WindowControllerList::CurrentWindowForFunction( |
52 const UIThreadExtensionFunction* function) const { | 52 const UIThreadExtensionFunction* function) const { |
53 ExtensionWindowController* result = NULL; | 53 WindowController* result = NULL; |
54 // Returns either the focused window (if any), or the last window in the list. | 54 // Returns either the focused window (if any), or the last window in the list. |
55 for (WindowList::const_iterator iter = windows().begin(); | 55 for (ControllerList::const_iterator iter = windows().begin(); |
56 iter != windows().end(); ++iter) { | 56 iter != windows().end(); ++iter) { |
57 if (function->CanOperateOnWindow(*iter)) { | 57 if (function->CanOperateOnWindow(*iter)) { |
58 result = *iter; | 58 result = *iter; |
59 if (result->window()->IsActive()) | 59 if (result->window()->IsActive()) |
60 break; // use focused window | 60 break; // use focused window |
61 } | 61 } |
62 } | 62 } |
63 return result; | 63 return result; |
64 } | 64 } |
| 65 |
| 66 } // namespace extensions |
OLD | NEW |