Commit 90636139 authored by yilkal's avatar yilkal Committed by Commit Bot

Handle repeated calls to OnAppActive with same window.

This CL ensures that AppActivityRegistry::OnAppActive
returns early if the application is already active.

Bug: 1034551
Change-Id: I5133e8b799e4231130f2ae5518469eaf29158dd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037967
Commit-Queue: Yilkal Abe <yilkal@chromium.org>
Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738656}
parent c9e36f7d
...@@ -136,6 +136,9 @@ void AppActivityRegistry::OnAppActive(const AppId& app_id, ...@@ -136,6 +136,9 @@ void AppActivityRegistry::OnAppActive(const AppId& app_id,
std::set<aura::Window*>& active_windows = app_details.active_windows; std::set<aura::Window*>& active_windows = app_details.active_windows;
if (base::Contains(active_windows, window))
return;
active_windows.insert(window); active_windows.insert(window);
// No need to set app as active if there were already active windows for the // No need to set app as active if there were already active windows for the
...@@ -523,6 +526,7 @@ void AppActivityRegistry::CheckTimeLimitForApp(const AppId& app_id) { ...@@ -523,6 +526,7 @@ void AppActivityRegistry::CheckTimeLimitForApp(const AppId& app_id) {
WebTimeLimitReached(base::Time::Now()); WebTimeLimitReached(base::Time::Now());
} else { } else {
// Set app activity state as time limit reached. // Set app activity state as time limit reached.
details.active_windows.clear();
details.activity.SetAppInactive(base::Time::Now()); details.activity.SetAppInactive(base::Time::Now());
details.activity.SetAppState(AppState::kLimitReached); details.activity.SetAppState(AppState::kLimitReached);
} }
...@@ -563,8 +567,10 @@ void AppActivityRegistry::WebTimeLimitReached(base::Time timestamp) { ...@@ -563,8 +567,10 @@ void AppActivityRegistry::WebTimeLimitReached(base::Time timestamp) {
if (details.activity.app_state() == AppState::kLimitReached) if (details.activity.app_state() == AppState::kLimitReached)
return; return;
if (details.activity.is_active()) if (details.activity.is_active()) {
details.active_windows.clear();
details.activity.SetAppInactive(timestamp); details.activity.SetAppInactive(timestamp);
}
details.activity.SetAppState(AppState::kLimitReached); details.activity.SetAppState(AppState::kLimitReached);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment