|
|
Chromium Code Reviews|
Created:
4 years ago by zmin Modified:
3 years, 12 months ago Reviewers:
Peter Kasting CC:
chromium-reviews Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionDisable --load-and-launch-app, --load-apps and --cloud-print-file if last_used_profile is not available.
When last profile is locked, --load-and-launch-app or --load-apps will cause Chrome crash while --cloud-print-file will quit Chrome quietly.
Disable these three options so that the UserManager can be shown and user can unlock the profile.
BUG=642059
Committed: https://crrev.com/71e0cb4481bac77367c53ea9c2a8b324c410c5dc
Cr-Commit-Position: refs/heads/master@{#440485}
Patch Set 1 #
Total comments: 12
Patch Set 2 : pkasting's comments #
Total comments: 5
Patch Set 3 : refactor #
Total comments: 12
Patch Set 4 : bug fix #Patch Set 5 : refactor and nit #Messages
Total messages: 38 (26 generated)
The CQ bit was checked by zmin@chromium.org to run a CQ dry run
zmin@chromium.org changed reviewers: + pkasting@chromium.org
Hi pkasting@ Can you review this CL please? Owen
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... File chrome/browser/ui/startup/startup_browser_creator.cc (left): https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:273: #else It's not obvious to me from the new callers whether it was correct to move this #ifdef out of this function. Maybe this is really a question for each of those new callsites: why is it important to depend on this function in each of those spots? https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... File chrome/browser/ui/startup/startup_browser_creator.cc (right): https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:265: // Return true if the last used profile must sign in or the last used profile Nit: Return -> returns https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:266: // was the guest or system profile. Otherwise, return false. Nit: Remove last sentence, it's implied. This comment is a bit more "what" than "why". Maybe state the "why" a little more instead, e.g. Returns true if we should show the user manager on startup instead of the last used profile. (The "what" can be done as comments within the function.) https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:274: if (!has_entry || !entry->IsSigninRequired()) { Nit: This equivalent implementation is shorter and, for me, was easier to understand. Note the rename of the function parameter, which avoids as much line-wrapping. bool ShouldShowUserManagerOnStartup(Profile* last_profile) { // Avoid reopening profiles that require signin. ProfileAttributesEntry* entry = nullptr; auto& storage = g_browser_process->profile_manager()->GetProfileAttributesStorage(); if (storage.GetProfileAttributesWithPath(last_profile->GetPath(), &entry) && entry->IsSigninRequired()) return true; // Avoid reopening guest or system profiles, unless a separate process already // has a window open for the profile. return ((last_profile->IsGuestSession() || last_profile->IsSystemProfile()) && !chrome::GetBrowserCount(last_profile->GetOffTheRecordProfile())); } https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:291: // Returns true if the User Manager was shown, false otherwise. Nit: Or just "Returns whether the User Manager was shown." https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:299: if (!ShouldShowUserManagerOnStartup(last_used_profile)) { Nit: {} unnecessary (and inconsistent with other places in this file, e.g. line 596)
The CQ bit was checked by zmin@chromium.org to run a CQ dry run
https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... File chrome/browser/ui/startup/startup_browser_creator.cc (left): https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:273: #else On 2016/12/20 01:43:49, Peter Kasting wrote: > It's not obvious to me from the new callers whether it was correct to move this > #ifdef out of this function. Maybe this is really a question for each of those > new callsites: why is it important to depend on this function in each of those > spots? I have moved the #ifdef to ShouldShowUserManagerOnStartup() from ShowUserManagerOnStartupIfNeeded(). ShouldShowUserManagerOnStartup() will check whether the last_used_profile is available. If not we will show UserManager(what we had already) and disable --load-and-launch-app, --load-apps and --cloud-print-file(in this CL). However, based on my understanding, user have to choose and login a profile before using Chrome on ChromeOS. So there is no last_used_profile unavailable issue on ChromeOS. So I think it makes sense to let ShouldShowUserManagerOnStartup() always returns false on ChromeOS. https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... File chrome/browser/ui/startup/startup_browser_creator.cc (right): https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:265: // Return true if the last used profile must sign in or the last used profile On 2016/12/20 01:43:49, Peter Kasting wrote: > Nit: Return -> returns Done. https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:266: // was the guest or system profile. Otherwise, return false. On 2016/12/20 01:43:49, Peter Kasting wrote: > Nit: Remove last sentence, it's implied. > > This comment is a bit more "what" than "why". Maybe state the "why" a little > more instead, e.g. > > Returns true if we should show the user manager on startup instead of the last > used profile. > > (The "what" can be done as comments within the function.) Done. https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:274: if (!has_entry || !entry->IsSigninRequired()) { On 2016/12/20 01:43:49, Peter Kasting wrote: > Nit: This equivalent implementation is shorter and, for me, was easier to > understand. > > Note the rename of the function parameter, which avoids as much line-wrapping. > > bool ShouldShowUserManagerOnStartup(Profile* last_profile) { > // Avoid reopening profiles that require signin. > ProfileAttributesEntry* entry = nullptr; > auto& storage = > g_browser_process->profile_manager()->GetProfileAttributesStorage(); > if (storage.GetProfileAttributesWithPath(last_profile->GetPath(), &entry) && > entry->IsSigninRequired()) > return true; > > // Avoid reopening guest or system profiles, unless a separate process already > // has a window open for the profile. > return ((last_profile->IsGuestSession() || last_profile->IsSystemProfile()) && > !chrome::GetBrowserCount(last_profile->GetOffTheRecordProfile())); > } Done. But I have changed it little bit: * Put "g_browser_process->profile_manager()->GetProfileAttributesStorage()" into the if condition. Because storage is only used in one place and I prefer this way. * Use == 0 instead of ! in the return value. Because the function name is GetBrowserCount. * Remove () pair for the return value to keep it in two lines. https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:291: // Returns true if the User Manager was shown, false otherwise. On 2016/12/20 01:43:49, Peter Kasting wrote: > Nit: Or just "Returns whether the User Manager was shown." Done. https://codereview.chromium.org/2582123002/diff/1/chrome/browser/ui/startup/s... chrome/browser/ui/startup/startup_browser_creator.cc:299: if (!ShouldShowUserManagerOnStartup(last_used_profile)) { On 2016/12/20 01:43:49, Peter Kasting wrote: > Nit: {} unnecessary (and inconsistent with other places in this file, e.g. line > 596) Done.
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2582123002/diff/20001/chrome/browser/ui/start... File chrome/browser/ui/startup/startup_browser_creator.cc (right): https://codereview.chromium.org/2582123002/diff/20001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:271: // Avoid reopen profile that requires sign in. Nit: You changed my suggested comments, which is fine, but your changes introduced grammar/mechanics/spelling errors. Here, for example, you'd want to say "...reopening a profile...". The comment below has at least three different issues. Please fix these carefully, or else use the comment suggestions I provided. https://codereview.chromium.org/2582123002/diff/20001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:596: !should_show_user_manager && Should this code have previously been checking !ShouldLaunchIncognito(...) like the other two spots you've modified do? If so, then we could factor the combined check out into some single temp which would express "safe to use a previous profile", which would in turn make it easier to be clear about why these options need this. My concern with the existing patch is that it's still not immediately clear as a reader why these lines actually want to check this variable -- that a particular feature needs to use some profile data, so it needs to be able to get at the profile data, so we need to check this flag to make sure that data can be obtained. We could add comments at each site noting some of this, but this would be easier to do if each spot did the exact same checks, as then all the constraints could be expressed in one place on the construction of that temp.
https://codereview.chromium.org/2582123002/diff/20001/chrome/browser/ui/start... File chrome/browser/ui/startup/startup_browser_creator.cc (right): https://codereview.chromium.org/2582123002/diff/20001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:271: // Avoid reopen profile that requires sign in. On 2016/12/20 23:21:09, Peter Kasting wrote: > Nit: You changed my suggested comments, which is fine, but your changes > introduced grammar/mechanics/spelling errors. Here, for example, you'd want to > say "...reopening a profile...". The comment below has at least three different > issues. Please fix these carefully, or else use the comment suggestions I > provided. Done. https://codereview.chromium.org/2582123002/diff/20001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:596: !should_show_user_manager && On 2016/12/20 23:21:09, Peter Kasting wrote: > Should this code have previously been checking !ShouldLaunchIncognito(...) like > the other two spots you've modified do? I just did a quick test,--cloud-print-file will ignore --incognito option and launch chrome in the normal mode. However, if incognito mode is enabled by IncognitoModeAvailability policy, Chrome will just do silent launch. In the other word, incognito mode doesn't compatible with cloud print. However, the priority is incognito mode policy > cloud-print cmd option > incognito cmd option. Checking !ShouldLaunchIncognito(...) here means change the priority to incognito mode policy > incognito cmd option > cloud-print cmd option So I'm not sure if you're ok with that. > If so, then we could factor the combined check out into some single temp which > would express "safe to use a previous profile", which would in turn make it > easier to be clear about why these options need this. Another issue is UserManager will be displayed if the last_used_profile is locked or guest session. In the mean time, I don't think UserManager cares about the incognito mode. However, just as you said below, I think it's still a good idea to put them into one function like: IsLastUsedProfileAvailable(Profile* last_used_profile, bool allow_incognito); With that, the caller can choose to care about incognito mode or not. > My concern with the existing patch is that it's still not immediately clear as a > reader why these lines actually want to check this variable -- that a particular > feature needs to use some profile data, so it needs to be able to get at the > profile data, so we need to check this flag to make sure that data can be > obtained. We could add comments at each site noting some of this, but this > would be easier to do if each spot did the exact same checks, as then all the > constraints could be expressed in one place on the construction of that temp.
https://codereview.chromium.org/2582123002/diff/20001/chrome/browser/ui/start... File chrome/browser/ui/startup/startup_browser_creator.cc (right): https://codereview.chromium.org/2582123002/diff/20001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:596: !should_show_user_manager && On 2016/12/21 00:09:50, zmin wrote: > On 2016/12/20 23:21:09, Peter Kasting wrote: > > Should this code have previously been checking !ShouldLaunchIncognito(...) > like > > the other two spots you've modified do? > I just did a quick test,--cloud-print-file will ignore --incognito option and > launch chrome in the normal mode. > However, if incognito mode is enabled by IncognitoModeAvailability policy, > Chrome will just do silent launch. > In the other word, incognito mode doesn't compatible with cloud print. However, > the priority is > incognito mode policy > cloud-print cmd option > incognito cmd option. > > Checking !ShouldLaunchIncognito(...) here means change the priority to > incognito mode policy > incognito cmd option > cloud-print cmd option > So I'm not sure if you're ok with that. At first glance, that sounds more consistent with how the other options work, and thus preferable.
The CQ bit was checked by zmin@chromium.org to run a CQ dry run
On 2016/12/21 00:21:25, Peter Kasting wrote: > https://codereview.chromium.org/2582123002/diff/20001/chrome/browser/ui/start... > File chrome/browser/ui/startup/startup_browser_creator.cc (right): > > https://codereview.chromium.org/2582123002/diff/20001/chrome/browser/ui/start... > chrome/browser/ui/startup/startup_browser_creator.cc:596: > !should_show_user_manager && > On 2016/12/21 00:09:50, zmin wrote: > > On 2016/12/20 23:21:09, Peter Kasting wrote: > > > Should this code have previously been checking !ShouldLaunchIncognito(...) > > like > > > the other two spots you've modified do? > > I just did a quick test,--cloud-print-file will ignore --incognito option and > > launch chrome in the normal mode. > > However, if incognito mode is enabled by IncognitoModeAvailability policy, > > Chrome will just do silent launch. > > In the other word, incognito mode doesn't compatible with cloud print. > However, > > the priority is > > incognito mode policy > cloud-print cmd option > incognito cmd option. > > > > Checking !ShouldLaunchIncognito(...) here means change the priority to > > incognito mode policy > incognito cmd option > cloud-print cmd option > > So I'm not sure if you're ok with that. > > At first glance, that sounds more consistent with how the other options work, > and thus preferable. Sounds good, I have changed the code.
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_x64_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
The CQ bit was checked by zmin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
LGTM https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... File chrome/browser/ui/startup/startup_browser_creator.cc (right): https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:265: // Returns true if we should show the user manager on startup. This comment is inaccurate. How about: // Returns whether |profile| can be opened during Chrome startup without // explicit user action. bool ProfileCanBeAutoOpened(...) { This also renames the function, since "available" feels like a bit of a misnomer when certain profiles are available after you take an explicit action (e.g. signing in). https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:270: // mode with command line options that do not compatible with incognito mode. Nit: do -> are https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:274: } Nit: I don't think you should put this conditional in this function. I think you should do it in the caller at the site where you compute |is_profile_available|. Fundamentally, the incognito profile is "available", and can be auto-opened, it's just that it's not suitable for certain command-line options. So it seems like a minor layering violation to put this here. Hoisting it also allows the code in ShowUserManagerOnStartupIfNeeded() to not worry about this. https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:276: // User will always choose and login profile before using Chrome on ChromeOS. Nit: Grammar; how about: "On ChromeOS, the user has already chosen and logged into the profile before Chrome starts up." https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:289: // already has a window open for the profile, Nit: , -> . https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:597: bool is_profile_available = Nit: Maybe call this |can_use_last_profile|, which better accommodates the "can be auto opened + is not an incompatible profile" concepts from above.
The CQ bit was checked by zmin@chromium.org to run a CQ dry run
https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... File chrome/browser/ui/startup/startup_browser_creator.cc (right): https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:265: // Returns true if we should show the user manager on startup. On 2016/12/22 00:26:33, Peter Kasting wrote: > This comment is inaccurate. How about: > > // Returns whether |profile| can be opened during Chrome startup without > // explicit user action. > bool ProfileCanBeAutoOpened(...) { > > This also renames the function, since "available" feels like a bit of a misnomer > when certain profiles are available after you take an explicit action (e.g. > signing in). Done. https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:270: // mode with command line options that do not compatible with incognito mode. On 2016/12/22 00:26:33, Peter Kasting wrote: > Nit: do -> are Done. https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:274: } On 2016/12/22 00:26:33, Peter Kasting wrote: > Nit: I don't think you should put this conditional in this function. I think > you should do it in the caller at the site where you compute > |is_profile_available|. > > Fundamentally, the incognito profile is "available", and can be auto-opened, > it's just that it's not suitable for certain command-line options. So it seems > like a minor layering violation to put this here. > > Hoisting it also allows the code in ShowUserManagerOnStartupIfNeeded() to not > worry about this. Done. https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:276: // User will always choose and login profile before using Chrome on ChromeOS. On 2016/12/22 00:26:33, Peter Kasting wrote: > Nit: Grammar; how about: "On ChromeOS, the user has already chosen and logged > into the profile before Chrome starts up." Done. https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:289: // already has a window open for the profile, On 2016/12/22 00:26:33, Peter Kasting wrote: > Nit: , -> . Done. https://codereview.chromium.org/2582123002/diff/40001/chrome/browser/ui/start... chrome/browser/ui/startup/startup_browser_creator.cc:597: bool is_profile_available = On 2016/12/22 00:26:33, Peter Kasting wrote: > Nit: Maybe call this |can_use_last_profile|, which better accommodates the "can > be auto opened + is not an incompatible profile" concepts from above. Done.
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by zmin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from pkasting@chromium.org Link to the patchset: https://codereview.chromium.org/2582123002/#ps80001 (title: "refactor and nit")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 80001, "attempt_start_ts": 1482437272128630,
"parent_rev": "eec90f1577fa8df095d54372284437316005764f", "commit_rev":
"2b265553faff933940ec4cf7fa5f1b4aabd67760"}
Message was sent while issue was closed.
Description was changed from ========== Disable --load-and-launch-app, --load-apps and --cloud-print-file if last_used_profile is not available. When last profile is locked, --load-and-launch-app or --load-apps will cause Chrome crash while --cloud-print-file will quit Chrome quietly. Disable these three options so that the UserManager can be shown and user can unlock the profile. BUG=642059 ========== to ========== Disable --load-and-launch-app, --load-apps and --cloud-print-file if last_used_profile is not available. When last profile is locked, --load-and-launch-app or --load-apps will cause Chrome crash while --cloud-print-file will quit Chrome quietly. Disable these three options so that the UserManager can be shown and user can unlock the profile. BUG=642059 Review-Url: https://codereview.chromium.org/2582123002 ==========
Message was sent while issue was closed.
Committed patchset #5 (id:80001)
Message was sent while issue was closed.
Description was changed from ========== Disable --load-and-launch-app, --load-apps and --cloud-print-file if last_used_profile is not available. When last profile is locked, --load-and-launch-app or --load-apps will cause Chrome crash while --cloud-print-file will quit Chrome quietly. Disable these three options so that the UserManager can be shown and user can unlock the profile. BUG=642059 Review-Url: https://codereview.chromium.org/2582123002 ========== to ========== Disable --load-and-launch-app, --load-apps and --cloud-print-file if last_used_profile is not available. When last profile is locked, --load-and-launch-app or --load-apps will cause Chrome crash while --cloud-print-file will quit Chrome quietly. Disable these three options so that the UserManager can be shown and user can unlock the profile. BUG=642059 Committed: https://crrev.com/71e0cb4481bac77367c53ea9c2a8b324c410c5dc Cr-Commit-Position: refs/heads/master@{#440485} ==========
Message was sent while issue was closed.
Patchset 5 (id:??) landed as https://crrev.com/71e0cb4481bac77367c53ea9c2a8b324c410c5dc Cr-Commit-Position: refs/heads/master@{#440485} |
