Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branding in setting and extension pages #179

Merged
merged 9 commits into from Jun 26, 2018
Merged

Branding in setting and extension pages #179

merged 9 commits into from Jun 26, 2018

Conversation

yrliou
Copy link
Member

@yrliou yrliou commented Jun 19, 2018

Parts of solving brave/brave-browser#12, this PR involves

  • Hide things without proper replacements available by adding <if expr="_google_chrome"> guards
  • Copy generated_resources.grd and its sub files using l10nUtil.js to replace branding strings

I tried to utilize hidden and dom-if conditions which were pre-defined by chrome to avoid patching, unfortunately, usually those properties are shared between different elements that we don't want to hide, so it turned out to be patching case by case for most elements. The reason adding guards instead of using css is because those entries would still show up in searching results, so I prefer to not have those elements in the first place than hiding them. If there's a better way to do this, please feel free to suggest.

In the future, when we have our own extension store, most of the patches can be deleted, and only patching for cloud printer and chrome's password manager link sections will be left since we might not have these features in the short term.

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed.

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions

@yrliou yrliou self-assigned this Jun 19, 2018
@yrliou yrliou changed the title [WIP] Branding in setting and extension pages Branding in setting and extension pages Jun 19, 2018
@yrliou yrliou requested a review from bbondy June 19, 2018 03:16
@yrliou
Copy link
Member Author

yrliou commented Jun 19, 2018

There's an error when I try push_l10n, so I probably have some details missing, I'll add a commit to fix it ASAP.

@bridiver
Copy link
Collaborator

This looks like a lot of copying (grd and grdp files) so I think we should talk about other ways to do this.

$i18n{multidevicePageTitle}
</a>
</if>
+<if expr="_google_chrome">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're turning off accessibility settings?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm removing this section because the only entry I could see is adding features by accessing chrome web store.
screen shot 2018-06-18 at 9 18 48 pm

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks

@yrliou
Copy link
Member Author

yrliou commented Jun 19, 2018

By quick glancing those grd/grdp files again, we don't need to replace bookmarks_strings.grdp.
I will revisit this topic tomorrow to see what options we might have.

This looks like a lot of copying (grd and grdp files) so I think we should talk about other ways to do this.

@bridiver
Copy link
Collaborator

I think this needs to happen build-time and write to gen - https://github.com/brave/brave-browser/blob/master/lib/l10nUtil.js
I'll open an issue for a follow-up

type="chrome_html" />
<structure name="IDR_MD_EXTENSIONS_SIDEBAR_HTML"
file="sidebar.html"
+ preprocess="true"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain this change? I'm not sure what this is doing

Copy link
Member Author

@yrliou yrliou Jun 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without preprocess=true, the <if expr> will not be parsed and was shown as <if expr=xxx> in the final HTML.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, makes sense

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yrliou can we pls do a substitution find and replace via the l10n scripts? I prefer not to patch grd files at all.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, is it possible to change the attributes using that method? That's great if so

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya it's just find and replace, but we can find <structure name="IDR_MD_EXTENSIONS_SIDEBAR_HTML" and replace with <structure name="IDR_MD_EXTENSIONS_SIDEBAR_HTML" preprocess="true"

module.exports.rebaseBraveStringFilesOnChromiumL10nFiles = (path) =>
  Object.entries({
    [chromiumStringsPath]: braveStringsPath,
    [chroimumSettingsPartPath]: braveSettingsPartPath,
    [chromiumComponentsStringsPath]: braveComponentsStringsPath
  }).forEach(([sourcePath, destPath]) =>
    fs.writeFileSync(destPath,
      fs.readFileSync(sourcePath, 'utf8')
        .replace(/settings_chromium_strings.grdp/g, 'settings_brave_strings.grdp')
        .replace(/The Chromium Authors/g, 'Brave Software Inc')
        .replace(/Google Chrome/g, 'Brave')
        .replace(/Chromium/g, 'Brave')
        .replace(/Chrome/g, 'Brave')
        .replace(/Google/g, 'Brave'), 'utf8'))

$i18n{quickBrownFox}
</div>
</div>
+<if expr="_google_chrome">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this give access to things like allowing extensions in incognito mode? Why do we want to hide it?

Copy link
Member Author

@yrliou yrliou Jun 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is for the below part in settings->appearance->customized fonts.
screen shot 2018-06-19 at 11 25 49 am
So we'are hidding it in our build no matter what before our own extension store is ready.
For _google_chrome build, the condition !isGuest_ still stands.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason not to also support that extension?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now this extension is not supported yet, I'll open a follow up issue for handling this later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow up issue created in brave/brave-browser#415

#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#if defined(BRAVE_CHROMIUM_BUILD)
+#include "brave/grit/brave_generated_resources.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can override chrome_generated_resources.h in chromium_src to include our resources and then re-include chrome

};
// </if>
+ // <if expr="not _google_chrome">
+ pageVisibility = {
Copy link
Collaborator

@bridiver bridiver Jun 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to specifically override things here vs repeating the entire list:
pageVisibility. a11y = false for instance

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or if we want our own completely independent list then maybe we should override IDR_SETTINGS_PAGE_VISIBILITY_JS ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pageVisibility would be undefined for non chrome os && not guest.
And sadly I couldn't only write the false values here because there are places using hidden=[[!pageVisibility.people]] which make undesired items to be hidden if the value was undefined.

I'll try overriding IDR_SETTINGS_PAGE_VISIBILITY_JS and see how it goes first thing tomorrow.

<structure name="IDR_SETTINGS_APPEARANCE_FONTS_PAGE_HTML"
file="appearance_page/appearance_fonts_page.html"
type="chrome_html"
+ preprocess="true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

bbondy
bbondy previously approved these changes Jun 20, 2018
Copy link
Member

@bbondy bbondy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bbondy
Copy link
Member

bbondy commented Jun 20, 2018

Oops I meant just to approve the last commit, let me cancel that approval.

@bbondy bbondy dismissed their stale review June 20, 2018 20:28

accidental thought it was just the last commit.

@yrliou yrliou force-pushed the branding2 branch 7 times, most recently from c79ee45 to ae3455c Compare June 23, 2018 02:07
@yrliou
Copy link
Member Author

yrliou commented Jun 25, 2018

@bridiver @bbondy Thanks for the review comments, they are all addressed, please review this PR again, thanks!

else:
assert False, ('Unexpected tag name %s' % element.tag)

elements = lxml.etree.parse(grd_file_path).findall('.//part')
for element in elements:
grd_base_path = os.path.dirname(grd_file_path)
grd_part_filename = element.get('file')
if grd_part_filename == 'chromeos_strings.grdp':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we care about anything for chromeos, or is this needed to avoid breaking something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is explicitly ignore here to avoid this script to try to process(read) this file, which we don't copy it at all into our src and caused read error.

* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

cr.define('settings', function() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably have a comment here explaining the reason why we used the proxy here vs just overriding individual settings. We don't want the next person who comes along to think that you can just override individual attributes like I assumed originally

Copy link
Member Author

@yrliou yrliou Jun 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments are added in 6b43657

@yrliou yrliou merged commit aed38ed into master Jun 26, 2018
@yrliou yrliou deleted the branding2 branch July 3, 2018 16:23
NejcZdovc added a commit that referenced this pull request Dec 10, 2018
Adds category to contribution completion function
NejcZdovc added a commit that referenced this pull request Dec 11, 2018
Adds category to contribution completion function
NejcZdovc pushed a commit that referenced this pull request Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants