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

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

Issue 257333002: Drive extension functions from ExtensionFunction::Run. The (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
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/window_controller_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/chrome_extension_function.h" 9 #include "chrome/browser/extensions/chrome_extension_function.h"
10 #include "chrome/browser/extensions/window_controller_list_observer.h" 10 #include "chrome/browser/extensions/window_controller_list_observer.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 WindowController* WindowControllerList::FindWindowById(int id) const { 55 WindowController* WindowControllerList::FindWindowById(int id) const {
56 for (ControllerList::const_iterator iter = windows().begin(); 56 for (ControllerList::const_iterator iter = windows().begin();
57 iter != windows().end(); ++iter) { 57 iter != windows().end(); ++iter) {
58 if ((*iter)->GetWindowId() == id) 58 if ((*iter)->GetWindowId() == id)
59 return *iter; 59 return *iter;
60 } 60 }
61 return NULL; 61 return NULL;
62 } 62 }
63 63
64 WindowController* WindowControllerList::FindWindowForFunctionById( 64 WindowController* WindowControllerList::FindWindowForFunctionById(
65 const ChromeAsyncExtensionFunction* function, 65 const ChromeUIThreadExtensionFunction* function,
66 int id) const { 66 int id) const {
67 WindowController* controller = FindWindowById(id); 67 WindowController* controller = FindWindowById(id);
68 if (controller && function->CanOperateOnWindow(controller)) 68 if (controller && function->CanOperateOnWindow(controller))
69 return controller; 69 return controller;
70 return NULL; 70 return NULL;
71 } 71 }
72 72
73 WindowController* WindowControllerList::CurrentWindowForFunction( 73 WindowController* WindowControllerList::CurrentWindowForFunction(
74 const ChromeAsyncExtensionFunction* function) const { 74 const ChromeUIThreadExtensionFunction* function) const {
75 WindowController* result = NULL; 75 WindowController* result = NULL;
76 // Returns either the focused window (if any), or the last window in the list. 76 // Returns either the focused window (if any), or the last window in the list.
77 for (ControllerList::const_iterator iter = windows().begin(); 77 for (ControllerList::const_iterator iter = windows().begin();
78 iter != windows().end(); ++iter) { 78 iter != windows().end(); ++iter) {
79 if (function->CanOperateOnWindow(*iter)) { 79 if (function->CanOperateOnWindow(*iter)) {
80 result = *iter; 80 result = *iter;
81 if (result->window()->IsActive()) 81 if (result->window()->IsActive())
82 break; // use focused window 82 break; // use focused window
83 } 83 }
84 } 84 }
85 return result; 85 return result;
86 } 86 }
87 87
88 } // namespace extensions 88 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/window_controller_list.h ('k') | chrome/browser/speech/extension_api/tts_extension_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698