From a825767bbf3a17832b5272fcb784ff270628edbc Mon Sep 17 00:00:00 2001 From: Roger Wang Date: Wed, 22 Jan 2020 01:48:25 -0700 Subject: [PATCH] nw2: fix blur event -- switching to other windows #7327 Fix nwjs/nw.js#7327 --- chrome/browser/extensions/api/tabs/tabs_event_router.cc | 7 +++++++ chrome/browser/extensions/api/tabs/tabs_event_router.h | 1 + chrome/browser/ui/browser_tab_strip_tracker.cc | 5 +++++ chrome/browser/ui/browser_tab_strip_tracker.h | 1 + 4 files changed, 14 insertions(+) diff --git a/chrome/browser/extensions/api/tabs/tabs_event_router.cc b/chrome/browser/extensions/api/tabs/tabs_event_router.cc index b573e57686b5..c6df6f1a6120 100644 --- a/chrome/browser/extensions/api/tabs/tabs_event_router.cc +++ b/chrome/browser/extensions/api/tabs/tabs_event_router.cc @@ -196,6 +196,13 @@ void TabsEventRouter::OnBrowserSetLastActive(Browser* browser) { } } +void TabsEventRouter::OnBrowserNoLongerActive(Browser* browser) { + TabsWindowsAPI* tabs_window_api = TabsWindowsAPI::Get(profile_); + if (tabs_window_api) { + tabs_window_api->windows_event_router()->OnActiveWindowChanged(NULL); + } +} + void TabsEventRouter::OnTabStripModelChanged( TabStripModel* tab_strip_model, const TabStripModelChange& change, diff --git a/chrome/browser/extensions/api/tabs/tabs_event_router.h b/chrome/browser/extensions/api/tabs/tabs_event_router.h index c79779ed5f76..7d3df764810f 100644 --- a/chrome/browser/extensions/api/tabs/tabs_event_router.h +++ b/chrome/browser/extensions/api/tabs/tabs_event_router.h @@ -51,6 +51,7 @@ class TabsEventRouter : public TabStripModelObserver, // BrowserListObserver: void OnBrowserSetLastActive(Browser* browser) override; + void OnBrowserNoLongerActive(Browser* browser) override; // TabStripModelObserver: void OnTabStripModelChanged( diff --git a/chrome/browser/ui/browser_tab_strip_tracker.cc b/chrome/browser/ui/browser_tab_strip_tracker.cc index 77cb3815bca3..e555ca271b23 100644 --- a/chrome/browser/ui/browser_tab_strip_tracker.cc +++ b/chrome/browser/ui/browser_tab_strip_tracker.cc @@ -100,3 +100,8 @@ void BrowserTabStripTracker::OnBrowserSetLastActive(Browser* browser) { if (browser_list_observer_) browser_list_observer_->OnBrowserSetLastActive(browser); } + +void BrowserTabStripTracker::OnBrowserNoLongerActive(Browser* browser) { + if (browser_list_observer_) + browser_list_observer_->OnBrowserNoLongerActive(browser); +} diff --git a/chrome/browser/ui/browser_tab_strip_tracker.h b/chrome/browser/ui/browser_tab_strip_tracker.h index 05d703e892e9..aee59541e006 100644 --- a/chrome/browser/ui/browser_tab_strip_tracker.h +++ b/chrome/browser/ui/browser_tab_strip_tracker.h @@ -68,6 +68,7 @@ class BrowserTabStripTracker : public BrowserListObserver { void OnBrowserAdded(Browser* browser) override; void OnBrowserRemoved(Browser* browser) override; void OnBrowserSetLastActive(Browser* browser) override; + void OnBrowserNoLongerActive(Browser* browser) override; TabStripModelObserver* tab_strip_model_observer_; BrowserTabStripTrackerDelegate* delegate_;