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

Unified Diff: chrome/browser/extensions/api/tabs/windows_event_router.cc

Issue 1099553002: extensions: windows: list all windows from the current profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: AppWindowController extracted Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/tabs/windows_event_router.cc
diff --git a/chrome/browser/extensions/api/tabs/windows_event_router.cc b/chrome/browser/extensions/api/tabs/windows_event_router.cc
index b9f8d1410e0705f9a28145cf757d30dcb99272a2..92db025cb2db8d867bde533d70868c527664df12 100644
--- a/chrome/browser/extensions/api/tabs/windows_event_router.cc
+++ b/chrome/browser/extensions/api/tabs/windows_event_router.cc
@@ -142,12 +142,16 @@ void WindowsEventRouter::Observe(
}
static bool WillDispatchWindowFocusedEvent(
- BrowserContext* new_active_context,
- int window_id,
+ WindowController* window_controller,
BrowserContext* context,
const Extension* extension,
base::ListValue* event_args,
const base::DictionaryValue* listener_filter) {
+ int window_id = window_controller ? window_controller->GetWindowId()
+ : extension_misc::kUnknownWindowId;
+ Profile* new_active_context =
+ window_controller ? window_controller->profile() : nullptr;
+
// When switching between windows in the default and incognito profiles,
// dispatch WINDOW_ID_NONE to extensions whose profile lost focus that
// can't see the new focused window across the incognito boundary.
@@ -189,9 +193,15 @@ void WindowsEventRouter::OnActiveWindowChanged(
windows::OnFocusChanged::kEventName,
make_scoped_ptr(new base::ListValue())));
event->will_dispatch_callback =
- base::Bind(&WillDispatchWindowFocusedEvent,
- static_cast<BrowserContext*>(window_profile),
- window_id);
+ base::Bind(&WillDispatchWindowFocusedEvent, window_controller);
+
+ // Set the window type to 'normal' if we don't have a window
+ // controller, so the event is not filtered.
+ EventFilteringInfo info;
+ info.SetWindowType(window_controller ? window_controller->GetWindowTypeText()
+ : keys::kWindowTypeValueNormal);
+ event->filter_info = info;
stevenjb 2015/07/30 19:00:37 nit: I think this can be just: event->filter_info.
llandwerlin-old 2015/07/31 13:58:32 Done.
+
EventRouter::Get(profile_)->BroadcastEvent(event.Pass());
}
@@ -201,6 +211,11 @@ void WindowsEventRouter::DispatchEvent(events::HistogramValue histogram_value,
scoped_ptr<base::ListValue> args) {
scoped_ptr<Event> event(new Event(histogram_value, event_name, args.Pass()));
event->restrict_to_browser_context = window_controller->profile();
+
+ EventFilteringInfo info;
+ info.SetWindowType(window_controller->GetWindowTypeText());
+ event->filter_info = info;
stevenjb 2015/07/30 19:00:37 Same here
llandwerlin-old 2015/07/31 13:58:32 Done.
+
EventRouter::Get(profile_)->BroadcastEvent(event.Pass());
}

Powered by Google App Engine
This is Rietveld 408576698