Add policy for limiting the session length
If this policy is set, the user is logged out when the time since login
reaches the limit. The CL adds a SessionLengthLimiter that enforces the
limit. A separate CL will add the UI that shows a countdown timer to the
user.
BUG=chromium-os:26957
TEST=Manual
TBR=sky@chromium.org
(vor chrome_browser_chromeos.gypi)
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=173285
Hi everyone,
This is missing part of public accounts that we want to land for M25. A swift
review is very much appreciated :).
Nikita,
Could you look at c/b/chromeos/* and c/b/chromeos/login/*?
Mattias,
Could you look at the policy changes?
Sailesh,
Could you look at the profile_dependency_manager.cc changes?
bartfab (slow)
https://codereview.chromium.org/11499012/diff/1/chrome/browser/chromeos/login/user_manager.h File chrome/browser/chromeos/login/user_manager.h (right): https://codereview.chromium.org/11499012/diff/1/chrome/browser/chromeos/login/user_manager.h#newcode195 chrome/browser/chromeos/login/user_manager.h:195: virtual bool HasBrowserRestarted() const = 0; I am not ...
https://codereview.chromium.org/11499012/diff/1/chrome/browser/chromeos/login...
File chrome/browser/chromeos/login/user_manager.h (right):
https://codereview.chromium.org/11499012/diff/1/chrome/browser/chromeos/login...
chrome/browser/chromeos/login/user_manager.h:195: virtual bool
HasBrowserRestarted() const = 0;
I am not sure whether the UserManager is the best home for this method. However,
as the UserManager does keep track of the current login/session state, it was
the most reasonable place I could find.
Also, making this method available to the UserManager allows an exisiting ad-hoc
check in the UserManager code to be replaced with an explicit call to the
method.
https://codereview.chromium.org/11499012/diff/6001/chrome/app/policy/policy_templates.json File chrome/app/policy/policy_templates.json (right): https://codereview.chromium.org/11499012/diff/6001/chrome/app/policy/policy_templates.json#newcode3833 chrome/app/policy/policy_templates.json:3833: When this policy is set, it specifies the the ...
https://chromiumcodereview.appspot.com/11499012/diff/6001/chrome/app/policy/policy_templates.json File chrome/app/policy/policy_templates.json (right): https://chromiumcodereview.appspot.com/11499012/diff/6001/chrome/app/policy/policy_templates.json#newcode3833 chrome/app/policy/policy_templates.json:3833: When this policy is set, it specifies the the ...
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chromeos/login/user_manager_impl.cc File chrome/browser/chromeos/login/user_manager_impl.cc (right): https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chromeos/login/user_manager_impl.cc#newcode238 chrome/browser/chromeos/login/user_manager_impl.cc:238: session_length_limiter_.reset(new SessionLengthLimiter(NULL, Why do you need to create session ...
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
File chrome/browser/chromeos/login/user_manager_impl.cc (right):
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
chrome/browser/chromeos/login/user_manager_impl.cc:238:
session_length_limiter_.reset(new SessionLengthLimiter(NULL,
Why do you need to create session length limiter for every non-Guest/non-Retail
user?
Will that be a noop for consumer user when policy is not defined? Maybe makes
sense to not create this and only create if policy that limits session lenght is
either defined during login. If policy will update during user session, you
could also create session limiter instance if needed.
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
File chrome/browser/chromeos/login/user_manager_impl.cc (right):
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
chrome/browser/chromeos/login/user_manager_impl.cc:238:
session_length_limiter_.reset(new SessionLengthLimiter(NULL,
On 2012/12/14 11:56:10, Nikita Kostylev wrote:
> Why do you need to create session length limiter for every
non-Guest/non-Retail
> user?
>
> Will that be a noop for consumer user when policy is not defined? Maybe makes
> sense to not create this and only create if policy that limits session lenght
is
> either defined during login. If policy will update during user session, you
> could also create session limiter instance if needed.
Sure, I can create the limiter on demand. But that would mean moving the code
that listens for policy changes into the UserManager so that it can construct
and destruct the limiter on the fly. It seems much cleaner and maintainable to
me to encapsulate this in one place. If the policy is not enabled, the limiter
simply does nothing after all. It just waits for the policy to be enabled, just
like the UserManager would if I moved the code there.
And yes, I enabled this code for regular users as well. This is because the
policy is useful for regular users as well.
Nikita (slow)
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chromeos/login/user_manager_impl.cc File chrome/browser/chromeos/login/user_manager_impl.cc (right): https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chromeos/login/user_manager_impl.cc#newcode595 chrome/browser/chromeos/login/user_manager_impl.cc:595: return command_line->HasSwitch(switches::kLoginManager) && When browser will be restarted after ...
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
File chrome/browser/chromeos/login/user_manager_impl.cc (right):
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
chrome/browser/chromeos/login/user_manager_impl.cc:238:
session_length_limiter_.reset(new SessionLengthLimiter(NULL,
On 2012/12/14 11:59:28, bartfab wrote:
> On 2012/12/14 11:56:10, Nikita Kostylev wrote:
> > Why do you need to create session length limiter for every
> non-Guest/non-Retail
> > user?
> >
> > Will that be a noop for consumer user when policy is not defined? Maybe
makes
> > sense to not create this and only create if policy that limits session
lenght
> is
> > either defined during login. If policy will update during user session, you
> > could also create session limiter instance if needed.
>
> Sure, I can create the limiter on demand. But that would mean moving the code
> that listens for policy changes into the UserManager so that it can construct
> and destruct the limiter on the fly. It seems much cleaner and maintainable to
> me to encapsulate this in one place. If the policy is not enabled, the limiter
> simply does nothing after all. It just waits for the policy to be enabled,
just
> like the UserManager would if I moved the code there.
>
> And yes, I enabled this code for regular users as well. This is because the
> policy is useful for regular users as well.
Agree, discussed.
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
File chrome/browser/chromeos/power/session_length_limiter.cc (right):
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
chrome/browser/chromeos/power/session_length_limiter.cc:129: StartTimer();
As discussed, SessionLengthLimiter should do no actions at all when created for
the account that doesn't have a session limit policy.
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
File chrome/browser/chromeos/login/user_manager_impl.cc (right):
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
chrome/browser/chromeos/login/user_manager_impl.cc:595: return
command_line->HasSwitch(switches::kLoginManager) &&
On 2012/12/14 12:03:06, Nikita Kostylev wrote:
> When browser will be restarted after crash, --login-manager will *not* be
> passed.
> --login-user will be passed.
>
> You don't have to check for --login-password here. That's a debug switch only.
>
> Previous check also had base::chromeos::IsRunningOnChromeOS() which was not
> transfered here.
The wrong pref name was a typo. Sorry. What I meant to do is to replicate the
logic from chrome_browser_main_chromeos.cc. Citing from there (line 452 onward):
// There are two use cases for kLoginUser:
// 1) if passed in tandem with kLoginPassword, to drive a "StubLogin"
// 2) if passed alone, to signal that the indicated user has already
// logged in and we should behave accordingly.
The code here is meant to find out whether we are in case 2. Hence, it checks
whether a password was given or not.
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
File chrome/browser/chromeos/power/session_length_limiter.cc (right):
https://chromiumcodereview.appspot.com/11499012/diff/11001/chrome/browser/chr...
chrome/browser/chromeos/power/session_length_limiter.cc:129: StartTimer();
On 2012/12/14 12:14:08, Nikita Kostylev wrote:
> As discussed, SessionLengthLimiter should do no actions at all when created
for
> the account that doesn't have a session limit policy.
Done. What the limiter does when the limit is not set is (see constructor):
* Write the login time to prefs. This is necessary because a limit could appear
later and we would need to find out when it was that we actually logged in.
* Start listening for changes to the limit pref.
Note that the limiter *never* started the timer when no limit was set. This
method here would just return in line 121.
Nikita (slow)
>> SessionLengthLimiter is no longer a PKS Makes sense to update description.
Presubmit check for 11499012-12007 failed and returned exit status 1.
Running presubmit commit checks ...
Finished checking
/b/commit-queue/workdir/chromium/chrome/app/policy/policy_templates.json. 0
errors, 0 warnings.
** Presubmit ERRORS **
Missing LGTM from an OWNER for files in these directories:
chrome
Presubmit checks took 2.3s to calculate.
bartfab (slow)
TBR'd Scott for chrome_browser_chromeos.gypi and notification types.
Presubmit check for 11499012-19005 failed and returned exit status 1.
Running presubmit commit checks ...
Finished checking
/b/commit-queue/workdir/chromium/chrome/app/policy/policy_templates.json. 0
errors, 0 warnings.
** Presubmit ERRORS **
Missing LGTM from an OWNER for files in these directories:
chrome
Presubmit checks took 2.1s to calculate.
Was the presubmit check useful? Please send feedback & hate mail to
maruel@chromium.org!
bartfab (slow)
The UI that will show the remaining session time is here: https://chromiumcodereview.appspot.com/11568036/ During the review ...
The UI that will show the remaining session time is here:
https://chromiumcodereview.appspot.com/11568036/
During the review of that CL, it became apparent that sending periodic
notifications from the backend to the UI frontend is neither necessary nor
desirable. I therefore removed the periodic notifications. I did leave the
periodic timer, even if it does very little every second now. The periodic timer
was well-tested and I did not want to break the logic at the last second by
switching to a one-shot timer.
I will update the limiter in the future to use a one-shot timer.
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/bartfab@chromium.org/11499012/19005
Issue 11499012: Add policy for limiting the session length
(Closed)
Created 8 years ago by bartfab (slow)
Modified 8 years ago
Reviewers: Nikita (slow), Mattias Nissler (ping if slow), sail
Base URL: svn://svn.chromium.org/chrome/trunk/src
Comments: 38