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

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: nit Created 5 years, 4 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
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_test.cc ('k') | chrome/browser/extensions/api/tabs/windows_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6b2eb10cdfb3fcbc3511e855d133ba2954728052..76eeda852ada1dc8998d8cd91f286ec3b2c95546 100644
--- a/chrome/browser/extensions/api/tabs/windows_event_router.cc
+++ b/chrome/browser/extensions/api/tabs/windows_event_router.cc
@@ -138,12 +138,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.
@@ -185,9 +189,12 @@ 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.
+ event->filter_info.SetWindowType(window_controller
+ ? window_controller->GetWindowTypeText()
+ : keys::kWindowTypeValueNormal);
EventRouter::Get(profile_)->BroadcastEvent(event.Pass());
}
@@ -197,6 +204,7 @@ 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();
+ event->filter_info.SetWindowType(window_controller->GetWindowTypeText());
EventRouter::Get(profile_)->BroadcastEvent(event.Pass());
}
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_test.cc ('k') | chrome/browser/extensions/api/tabs/windows_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698