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

Side by Side Diff: chrome/browser/extensions/extension_window_list.cc

Issue 10735061: Move ExtensionWindowController and related into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq Created 8 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extension_window_list.h"
6
7 #include <algorithm>
8
9 #include "chrome/browser/extensions/extension_function.h"
10 #include "chrome/browser/sessions/session_id.h"
11 #include "chrome/browser/ui/base_window.h"
12
13 ///////////////////////////////////////////////////////////////////////////////
14 // ExtensionWindowList
15
16 // static
17 ExtensionWindowList* ExtensionWindowList::GetInstance() {
18 return Singleton<ExtensionWindowList>::get();
19 }
20
21 ExtensionWindowList::ExtensionWindowList() {
22 }
23
24 ExtensionWindowList::~ExtensionWindowList() {
25 }
26
27 void ExtensionWindowList::AddExtensionWindow(
28 ExtensionWindowController* window) {
29 windows_.push_back(window);
30 }
31
32 void ExtensionWindowList::RemoveExtensionWindow(
33 ExtensionWindowController* window) {
34 WindowList::iterator iter = std::find(
35 windows_.begin(), windows_.end(), window);
36 if (iter != windows_.end())
37 windows_.erase(iter);
38 }
39
40 ExtensionWindowController* ExtensionWindowList::FindWindowForFunctionById(
41 const UIThreadExtensionFunction* function,
42 int id) const {
43 for (WindowList::const_iterator iter = windows().begin();
44 iter != windows().end(); ++iter) {
45 if (function->CanOperateOnWindow(*iter) && (*iter)->GetWindowId() == id)
46 return *iter;
47 }
48 return NULL;
49 }
50
51 ExtensionWindowController* ExtensionWindowList::CurrentWindowForFunction(
52 const UIThreadExtensionFunction* function) const {
53 ExtensionWindowController* result = NULL;
54 // Returns either the focused window (if any), or the last window in the list.
55 for (WindowList::const_iterator iter = windows().begin();
56 iter != windows().end(); ++iter) {
57 if (function->CanOperateOnWindow(*iter)) {
58 result = *iter;
59 if (result->window()->IsActive())
60 break; // use focused window
61 }
62 }
63 return result;
64 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_window_list.h ('k') | chrome/browser/extensions/tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698