Skip to content

Commit

Permalink
WebUI: Fix several violations of lowerCamelCase or UPPER_CASE naming.
Browse files Browse the repository at this point in the history
Per styleguide at [1] variables and parameter names should be using
lowerCamelCase and enum members UPPER_CASE. Fixing several violations
of these rules across WebUI, in an effort to possibly enable such checks
at PRESUBMIT time with ESLint, in the near future.

Violations are discovered by locally enabling ESLint's 'camelcase'
rule [2].

[1] https://google.github.io/styleguide/tsguide.html#identifiers
[2] https://eslint.org/docs/rules/camelcase

Bug: 720034
Change-Id: Ib1bfcf2387221d70f7f3cf93834a8c3cb8944666
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3562564
Reviewed-by: John Lee <johntlee@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/main@{#988663}
  • Loading branch information
freshp86 authored and Chromium LUCI CQ committed Apr 4, 2022
1 parent b99f6ee commit b721d28
Show file tree
Hide file tree
Showing 26 changed files with 181 additions and 194 deletions.
10 changes: 5 additions & 5 deletions chrome/browser/resources/discards/graph_doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ToolTip {
y: number;
node: GraphNode;
private div_: d3.Selection<HTMLDivElement, unknown, null, undefined>;
private description_json_: string = '';
private descriptionJson_: string = '';

constructor(div: Element, node: GraphNode) {
this.x = node.x;
Expand Down Expand Up @@ -105,8 +105,8 @@ class ToolTip {
/**
* Updates the description displayed.
*/
onDescription(description_json: string) {
if (this.description_json_ === description_json) {
onDescription(descriptionJson: string) {
if (this.descriptionJson_ === descriptionJson) {
return;
}

Expand Down Expand Up @@ -180,8 +180,8 @@ class ToolTip {
// flattened to an array. Each top-level dictionary entry is flattened to a
// 'heading' with [`the describer's name`, null], followed by some number of
// entries with a two-element list, each representing a key/value pair.
this.description_json_ = description_json;
const description = JSON.parse(description_json);
this.descriptionJson_ = descriptionJson;
const description = JSON.parse(descriptionJson);
const flattenedDescription = [];
for (const [title, value] of Object.entries(description)) {
flattenedDescription.push([title, null]);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/resources/discards/graph_tab_template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class DiscardsGraphChangeStreamImpl implements GraphChangeStreamInterface {
this.postMessage_('workerChanged', worker);
}

favIconDataAvailable(icon_info: FavIconInfo) {
this.postMessage_('favIconDataAvailable', icon_info);
favIconDataAvailable(iconInfo: FavIconInfo) {
this.postMessage_('favIconDataAvailable', iconInfo);
}

nodeDeleted(nodeId: bigint) {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/resources/extensions/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class Service implements ServiceInterface {
/**
* @return A signal that loading finished, rejected if any error occurred.
*/
private loadUnpackedHelper_(opt_options?:
private loadUnpackedHelper_(extraOptions?:
chrome.developerPrivate.LoadUnpackedOptions):
Promise<boolean> {
return new Promise(function(resolve, reject) {
Expand All @@ -167,7 +167,7 @@ export class Service implements ServiceInterface {
failQuietly: true,
populateError: true,
},
opt_options);
extraOptions);

chrome.developerPrivate.loadUnpacked(options, (loadError) => {
if (chrome.runtime.lastError &&
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/resources/history/history_clusters/clusters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ class HistoryClustersElement extends PolymerElement {
* loaded before the user ever gets a chance to see this button.
*/
private getLoadMoreButtonHidden_(
_result: QueryResult, _result_clusters: Array<Cluster>,
_result_can_load_more: Time): boolean {
_result: QueryResult, _resultClusters: Array<Cluster>,
_resultCanLoadMore: Time): boolean {
return !this.result_ || this.result_.clusters.length === 0 ||
!this.result_.canLoadMore;
}
Expand Down
30 changes: 14 additions & 16 deletions chrome/browser/resources/print_preview/data/destination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,27 +308,25 @@ export class Destination {
constructor(
id: string, type: DestinationType, origin: DestinationOrigin,
displayName: string, connectionStatus: DestinationConnectionStatus,
opt_params?: DestinationOptionalParams) {
params?: DestinationOptionalParams) {
this.id_ = id;
this.type_ = type;
this.origin_ = origin;
this.displayName_ = displayName || '';
this.tags_ = (opt_params && opt_params.tags) || [];
this.isOwned_ = (opt_params && opt_params.isOwned) || false;
this.isEnterprisePrinter_ =
(opt_params && opt_params.isEnterprisePrinter) || false;
this.account_ = (opt_params && opt_params.account) || '';
this.description_ = (opt_params && opt_params.description) || '';
this.tags_ = (params && params.tags) || [];
this.isOwned_ = (params && params.isOwned) || false;
this.isEnterprisePrinter_ = (params && params.isEnterprisePrinter) || false;
this.account_ = (params && params.account) || '';
this.description_ = (params && params.description) || '';
this.connectionStatus_ = connectionStatus;
this.lastAccessTime_ =
(opt_params && opt_params.lastAccessTime) || Date.now();
this.cloudID_ = (opt_params && opt_params.cloudID) || '';
this.extensionId_ = (opt_params && opt_params.extensionId) || '';
this.extensionName_ = (opt_params && opt_params.extensionName) || '';
this.provisionalType_ = (opt_params && opt_params.provisionalType) ||
DestinationProvisionalType.NONE;
this.certificateStatus_ = opt_params && opt_params.certificateStatus ||
DestinationCertificateStatus.NONE;
this.lastAccessTime_ = (params && params.lastAccessTime) || Date.now();
this.cloudID_ = (params && params.cloudID) || '';
this.extensionId_ = (params && params.extensionId) || '';
this.extensionName_ = (params && params.extensionName) || '';
this.provisionalType_ =
(params && params.provisionalType) || DestinationProvisionalType.NONE;
this.certificateStatus_ =
params && params.certificateStatus || DestinationCertificateStatus.NONE;

assert(
this.provisionalType_ !==
Expand Down
14 changes: 7 additions & 7 deletions chrome/browser/resources/print_preview/data/destination_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,14 @@ export class DestinationStore extends EventTarget {
}

/**
* @param opt_account Account to filter destinations by. When
* @param account Account to filter destinations by. When
* null or omitted, all destinations are returned.
* @return List of destinations accessible by the {@code account}.
*/
destinations(opt_account?: string|null): Destination[] {
destinations(account?: string|null): Destination[] {
return this.destinations_.filter(function(destination) {
return !destination.account ||
(!!opt_account && destination.account === opt_account);
(!!account && destination.account === account);
});
}

Expand Down Expand Up @@ -843,16 +843,16 @@ export class DestinationStore extends EventTarget {

/**
* Initiates loading of cloud destinations.
* @param opt_origin Search destinations for the specified origin only.
* @param origin Search destinations for the specified origin only.
*/
startLoadCloudDestinations(opt_origin?: DestinationOrigin) {
startLoadCloudDestinations(origin?: DestinationOrigin) {
if (this.cloudPrintInterface_ === null) {
return;
}

const origins = this.loadedCloudOrigins_.get(this.activeUser_) || [];
if (origins.length === 0 || (opt_origin && origins.includes(opt_origin))) {
this.cloudPrintInterface_.search(this.activeUser_, opt_origin);
if (origins.length === 0 || (origin && origins.includes(origin))) {
this.cloudPrintInterface_.search(this.activeUser_, origin);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export class ReadAnythingElement extends ReadAnythingElementBase {

const callbackRouter = this.apiProxy_.getCallbackRouter();
this.listenerIds_ = [callbackRouter.onEssentialContent.addListener(
(essential_content: string[]) =>
this.showEssentialContent_(essential_content))];
(essentialContent: string[]) =>
this.showEssentialContent_(essentialContent))];

this.apiProxy_.showUI();
}
Expand All @@ -51,8 +51,8 @@ export class ReadAnythingElement extends ReadAnythingElementBase {
id => this.apiProxy_.getCallbackRouter().removeListener(id));
}

showEssentialContent_(essential_content: string[]) {
this.paragraphs_ = essential_content;
showEssentialContent_(essentialContent: string[]) {
this.paragraphs_ = essentialContent;
}
}
customElements.define(ReadAnythingElement.is, ReadAnythingElement);
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
as="language">
<controlled-radio-button
class="cr-row continuation live-caption-language-radio-button"
label="[[language.display_name]]"
label="[[language.displayName]]"
name="[[language.code]]"
pref="[[prefs.accessibility.captions.live_caption_language]]">
<span class="cr-secondary-text cr-row-gap">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {getTemplate} from './live_caption_section.html.js';
* model is being downloaded.
*/
type LiveCaptionLanguage = {
display_name: string,
displayName: string,
code: string,
downloadProgress: string,
};
Expand Down Expand Up @@ -82,37 +82,37 @@ export class SettingsLiveCaptionElement extends SettingsLiveCaptionElementBase {
value() {
return [
{
display_name:
displayName:
loadTimeData.getString('sodaLanguageDisplayNameEnglish'),
code: loadTimeData.getString('sodaLanguageCodeEnglish'),
downloadProgress: '',
},
{
display_name:
displayName:
loadTimeData.getString('sodaLanguageDisplayNameFrench'),
code: loadTimeData.getString('sodaLanguageCodeFrench'),
downloadProgress: '',
},
{
display_name:
displayName:
loadTimeData.getString('sodaLanguageDisplayNameGerman'),
code: loadTimeData.getString('sodaLanguageCodeGerman'),
downloadProgress: '',
},
{
display_name:
displayName:
loadTimeData.getString('sodaLanguageDisplayNameItalian'),
code: loadTimeData.getString('sodaLanguageCodeItalian'),
downloadProgress: '',
},
{
display_name:
displayName:
loadTimeData.getString('sodaLanguageDisplayNameJapanese'),
code: loadTimeData.getString('sodaLanguageCodeJapanese'),
downloadProgress: '',
},
{
display_name:
displayName:
loadTimeData.getString('sodaLanguageDisplayNameSpanish'),
code: loadTimeData.getString('sodaLanguageCodeSpanish'),
downloadProgress: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ export enum PasswordDialogMode {
*/
export enum AddCredentialFromSettingsUserInteractions {
// Used when the add credential dialog is opened from the settings.
Add_Dialog_Opened = 0,
ADD_DIALOG_OPENED = 0,
// Used when the add credential dialog is closed from the settings.
Add_Dialog_Closed = 1,
ADD_DIALOG_CLOSED = 1,
// Used when a new credential is added from the settings .
Credential_Added = 2,
CREDENTIAL_ADDED = 2,
// Used when a new credential is being added from the add credential dialog in
// settings and another credential exists with the same username/website
// combination.
Duplicated_Credential_Entered = 3,
DUPLICATED_CREDENTIAL_ENTERED = 3,
// Used when an existing credential is viewed while adding a new credential
// from the settings.
Duplicate_Credential_Viewed = 4,
DUPLICATE_CREDENTIAL_VIEWED = 4,
// Must be last.
COUNT = 5,
}
Expand Down Expand Up @@ -715,7 +715,7 @@ export class PasswordEditDialogElement extends PasswordEditDialogElementBase {
private onViewExistingPasswordClick_() {
chrome.metricsPrivate.recordEnumerationValue(
'PasswordManager.AddCredentialFromSettings.UserAction',
AddCredentialFromSettingsUserInteractions.Duplicate_Credential_Viewed,
AddCredentialFromSettingsUserInteractions.DUPLICATE_CREDENTIAL_VIEWED,
AddCredentialFromSettingsUserInteractions.COUNT);
const existingEntry = this.savedPasswords.find(entry => {
return entry.urls.origin === this.websiteUrls_!.origin &&
Expand Down Expand Up @@ -758,7 +758,7 @@ export class PasswordEditDialogElement extends PasswordEditDialogElementBase {
chrome.metricsPrivate.recordEnumerationValue(
'PasswordManager.AddCredentialFromSettings.UserAction',
AddCredentialFromSettingsUserInteractions
.Duplicated_Credential_Entered,
.DUPLICATED_CREDENTIAL_ENTERED,
AddCredentialFromSettingsUserInteractions.COUNT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ export class PasswordsSectionElement extends PasswordsSectionElementBase {
private onAddPasswordTap_() {
chrome.metricsPrivate.recordEnumerationValue(
'PasswordManager.AddCredentialFromSettings.UserAction',
AddCredentialFromSettingsUserInteractions.Add_Dialog_Opened,
AddCredentialFromSettingsUserInteractions.ADD_DIALOG_OPENED,
AddCredentialFromSettingsUserInteractions.COUNT);
this.showAddPasswordDialog_ = true;
this.activeDialogAnchorStack_.push(
Expand All @@ -672,7 +672,7 @@ export class PasswordsSectionElement extends PasswordsSectionElementBase {
private onAddPasswordDialogClosed_() {
chrome.metricsPrivate.recordEnumerationValue(
'PasswordManager.AddCredentialFromSettings.UserAction',
AddCredentialFromSettingsUserInteractions.Add_Dialog_Closed,
AddCredentialFromSettingsUserInteractions.ADD_DIALOG_CLOSED,
AddCredentialFromSettingsUserInteractions.COUNT);
this.showAddPasswordDialog_ = false;
focusWithoutInk(assert(this.activeDialogAnchorStack_.pop()!));
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/resources/settings/prefs/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,18 @@ export class SettingsPrefsElement extends PolymerElement {
}

/**
* @param opt_settingsApi SettingsPrivate implementation to use
* @param settingsApi SettingsPrivate implementation to use
* (chrome.settingsPrivate by default).
*/
initialize(opt_settingsApi?: typeof chrome.settingsPrivate) {
initialize(settingsApi?: typeof chrome.settingsPrivate) {
// Only initialize once (or after resetForTesting() is called).
if (this.initialized_) {
return;
}
this.initialized_ = true;

if (opt_settingsApi) {
this.settingsApi_ = opt_settingsApi;
if (settingsApi) {
this.settingsApi_ = settingsApi;
}

this.boundPrefsChanged_ = this.onSettingsPrivatePrefsChanged_.bind(this);
Expand Down
17 changes: 8 additions & 9 deletions chrome/browser/resources/settings/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,19 @@ import {dedupingMixin} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun
/**
* Navigates to a canonical route and pushes a new history entry.
* @param {!Route} route
* @param {URLSearchParams=} opt_dynamicParameters Navigations to the same
* @param {URLSearchParams=} dynamicParameters Navigations to the same
* URL parameters in a different order will still push to history.
* @param {boolean=} opt_removeSearch Whether to strip the 'search' URL
* @param {boolean=} removeSearch Whether to strip the 'search' URL
* parameter during navigation. Defaults to false.
*/
navigateTo(route, opt_dynamicParameters, opt_removeSearch) {
navigateTo(route, dynamicParameters, removeSearch = false) {
// The ADVANCED route only serves as a parent of subpages, and should not
// be possible to navigate to it directly.
if (route === this.routes_.ADVANCED) {
route = this.routes_.BASIC;
}

const params = opt_dynamicParameters || new URLSearchParams();
const removeSearch = !!opt_removeSearch;
const params = dynamicParameters || new URLSearchParams();

const oldSearchParam = this.getQueryParameters().get('search') || '';
const newSearchParam = params.get('search') || '';
Expand Down Expand Up @@ -401,9 +400,9 @@ import {dedupingMixin} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun

/**
* @param {!Route} newRoute
* @param {!Route=} opt_oldRoute
* @param {!Route=} oldRoute
*/
currentRouteChanged(newRoute, opt_oldRoute) {
currentRouteChanged(newRoute, oldRoute) {
assertNotReached();
}
}
Expand All @@ -415,7 +414,7 @@ import {dedupingMixin} from 'chrome://resources/polymer/v3_0/polymer/polymer_bun
export class RouteObserverMixinInterface {
/**
* @param {!Route} newRoute
* @param {!Route=} opt_oldRoute
* @param {!Route=} oldRoute
*/
currentRouteChanged(newRoute, opt_oldRoute) {}
currentRouteChanged(newRoute, oldRoute) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ export interface SiteSettingsPrefsBrowserProxy {
* Deletes a protocol handler by url from the app approved list.
* @param protocol The protocol to delete the url from.
* @param url The url to delete.
* @param app_id The web app's ID to delete.
* @param appId The web app's ID to delete.
*/
removeAppDisallowedHandler(protocol: string, url: string, app_id: string):
removeAppDisallowedHandler(protocol: string, url: string, appId: string):
void;

/**
Expand Down Expand Up @@ -557,8 +557,8 @@ export class SiteSettingsPrefsBrowserProxyImpl implements
chrome.send('removeAppAllowedHandler', [protocol, url, appId]);
}

removeAppDisallowedHandler(protocol: string, url: string, app_id: string) {
chrome.send('removeAppDisallowedHandler', [protocol, url, app_id]);
removeAppDisallowedHandler(protocol: string, url: string, appId: string) {
chrome.send('removeAppDisallowedHandler', [protocol, url, appId]);
}

updateIncognitoStatus() {
Expand Down

0 comments on commit b721d28

Please sign in to comment.