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 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 Jun 19, 2018
@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

bridiver commented Jun 19, 2018

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">

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 19, 2018

Collaborator

we're turning off accessibility settings?

This comment has been minimized.

Copy link
@yrliou

yrliou Jun 19, 2018

Author Member

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

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 19, 2018

Collaborator

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

bridiver commented Jun 19, 2018

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"

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 19, 2018

Collaborator

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

This comment has been minimized.

Copy link
@yrliou

yrliou Jun 19, 2018

Author Member

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

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 19, 2018

Collaborator

ok, makes sense

This comment has been minimized.

Copy link
@bbondy

bbondy Jun 20, 2018

Member

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

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 20, 2018

Collaborator

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

This comment has been minimized.

Copy link
@bbondy

bbondy Jun 20, 2018

Member

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">

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 19, 2018

Collaborator

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

This comment has been minimized.

Copy link
@yrliou

yrliou Jun 19, 2018

Author Member

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.

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 19, 2018

Collaborator

any reason not to also support that extension?

This comment has been minimized.

Copy link
@yrliou

yrliou Jun 20, 2018

Author Member

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

This comment has been minimized.

Copy link
@yrliou

yrliou Jun 23, 2018

Author Member

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"

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 19, 2018

Collaborator

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 = {

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 19, 2018

Collaborator

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

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 19, 2018

Collaborator

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

This comment has been minimized.

Copy link
@yrliou

yrliou Jun 21, 2018

Author Member

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"

This comment has been minimized.

Copy link
@bbondy

bbondy Jun 20, 2018

Member

ditto

Copy link
Member

bbondy left a comment

👍

@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 Jun 20, 2018

accidental thought it was just the last commit.

@yrliou yrliou force-pushed the branding2 branch 7 times, most recently from c79ee45 to ae3455c Jun 21, 2018
@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':

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 26, 2018

Collaborator

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

This comment has been minimized.

Copy link
@yrliou

yrliou Jun 26, 2018

Author Member

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() {

This comment has been minimized.

Copy link
@bridiver

bridiver Jun 26, 2018

Collaborator

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

This comment has been minimized.

Copy link
@yrliou

yrliou Jun 26, 2018

Author Member

comments are added in 6b43657

@yrliou yrliou force-pushed the branding2 branch from ae3455c to 6b43657 Jun 26, 2018
@yrliou yrliou merged commit aed38ed into master Jun 26, 2018
@yrliou yrliou deleted the branding2 branch Jul 3, 2018
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
NejcZdovc added a commit that referenced this pull request Sep 19, 2019
NejcZdovc added a commit that referenced this pull request Sep 19, 2019
NejcZdovc added a commit that referenced this pull request Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.