New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 670767 link

Starred by 2 users

Issue metadata

Status: Verified
Owner:
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug



Sign in to add a comment

MD Settings: Pass strings to cr_elements and eliminate use of loadTimeData and I18nBehavior

Project Member Reported by steve...@chromium.org, Dec 2 2016

Issue description

Currently there is some non trivial string lookup done in the cr_network_* elements.

The problem with this is that the sshared components make the assumption that certain strings exist in LoadTimeData, even though they are not directly associated with a particular page.

We need to develop a more robust mechanism for handling strings in shared network components. (Currently these components are shared by the Settings and OOBE UI).

 
I've been thinking about how to approach this and I'm still not sure what the best solution is.

We discussed adding some asserts in the short term, but there's actually a pretty long list of strings accessed by cr-network-list-item (at least 13). Also we already assert in loadTimeData.getString. So adding additional asserts in the item (of which there could be many) seems like it would just add extra work at load time.

Maybe we should set up a different directory for elements that are shared across web uis (e.g. settings and OOBE), but that are not "drop-in" elements, e.g. they make assumptions about available strings (or possibly handlers?).

Comment 3 by dbeam@chromium.org, Dec 8 2016

as long as you can guarantee these strings will exist for your code, it doesn't matter where.  you could create these strings in some other handler if you'd like.

re: assert -- yes, there's a runtime error when you attempt to access strings that don't exist via loadTimeData.  but that doesn't mean these strings are accessed super often.  that's the difference between assert() on startup vs assert() in random policy/extension-controlled cases.
I'm not sure I understand the first half of comment #3. We are providing the strings for Settings and OOBE (now). The concern would be about continued maintenance.

WRT when we assert, I agree that there is some risk in not checking all possible strings at load time, but I question whether it is worth the overhead, which would be incurred for every instance of the control (which, in the case of policy indicators, is rather frequent).

Comment 5 by dbeam@chromium.org, Dec 8 2016

stevenjb@: meaning, right now we add a bunch of strings in 2 different places (settings, OOBE).  what we could do instead is extract the strings needed from both places and make a new handler (or method of injecting these strings) that lives in ui/webui, closer to the shared UI components themselves.

does that make more sense?
Ah, yes, that makes sense. I am fine with moving the strings to a shared / separate handler. The code has already been structured to make it easy for OOBE to use the strings defined for Settings.

What priority would you place this cleanup? Pre or post shipping MD Settings?

Labels: M-58
Marking this for 58 unless we decide it is a priority.

Summary: MD Settings: Pass strings to cr_elements and eliminate use of loadTimeData and I18nBehavior (was: MD Settings: Pass strings to cr_network_* elements and eliminate I18nBehavior)
This also needs to be done fro cr_elements/policy.

Status: Started (was: Available)
Project Member

Comment 11 by bugdroid1@chromium.org, Jan 19 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/693b38c3882550aabf0ad1d706635e3c7810d855

commit 693b38c3882550aabf0ad1d706635e3c7810d855
Author: stevenjb <stevenjb@chromium.org>
Date: Thu Jan 19 17:36:43 2017

WebUI: Remove i18n from cr_elements/network

This includes changes in cr_onc_types.js to allow enums to be
used as @param types.

BUG= 670767 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2627023006
Cr-Commit-Position: refs/heads/master@{#444772}

[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/app/chromeos_strings.grdp
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/app/settings_strings.grdp
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/resources/chromeos/login/oobe_welcome.js
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/resources/chromeos/network_ui/network_ui.js
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/resources/settings/internet_page/internet_detail_page.js
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/resources/settings/settings_resources.grd
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/resources/settings/settings_ui/compiled_resources2.gyp
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/resources/settings/settings_ui/settings_ui.html
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/resources/settings/settings_ui/settings_ui.js
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/ui/BUILD.gn
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
[add] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc
[add] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/ui/webui/chromeos/network_ui.cc
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.h
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/ui/webui/resources/cr_elements/network/compiled_resources2.gyp
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/ui/webui/resources/cr_elements/network/cr_network_list_item.html
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/ui/webui/resources/cr_elements/network/cr_network_list_item.js
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/ui/webui/resources/cr_elements/network/cr_network_select.js
[modify] https://crrev.com/693b38c3882550aabf0ad1d706635e3c7810d855/ui/webui/resources/cr_elements/network/cr_onc_types.js

Labels: -M-58 M-57
Status: Fixed (was: Started)
Labels: code-change
Status: Verified (was: Fixed)

Sign in to add a comment