Skip to content

Commit

Permalink
Settings WebUI: Allow editing profile name and picture in Get Started…
Browse files Browse the repository at this point in the history
… section
  • Loading branch information
petemill committed Aug 13, 2019
1 parent 8da8273 commit 754e6e9
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 13 deletions.
4 changes: 4 additions & 0 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
<message name="IDS_UNVETTED_EXTENSION_INSTALL_PROMPT_TITLE" desc="Titlebar of the extension or app installation prompt which was not vetted by Brave. Asks the user if they want to install a particular extension or app.">
Brave has not reviewed this extension for security and safety. Only install this extension if you trust the developer.
</message>
<!-- Settings / Get Started -->
<message name="IDS_SETTINGS_BRAVE_EDIT_PROFILE" desc="Title to edit the profile user name and picture">
Profile name and icon
</message>
<!-- Appearance -->
<message name="IDS_SETTINGS_APPEARANCE_SETTINGS_BRAVE_THEMES" desc="The label for brave theme change setting options">
Brave colors
Expand Down
16 changes: 10 additions & 6 deletions browser/resources/settings/brave_settings_overrides.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
<settings-people-page prefs="{{prefs}}"
page-visibility="[[pageVisibility]]">
</settings-people-page>
<settings-default-browser-page></settings-default-browser-page>
<div class="settings-box">$i18n{onStartup}</div>
<div class="settings-box continuation">
<settings-on-startup-page prefs="{{prefs}}">
</settings-on-startup-page>
</div>
<settings-animated-pages id="pages" section="getStarted">
<div route-path="default">
<settings-default-browser-page></settings-default-browser-page>
<div class="settings-box">$i18n{onStartup}</div>
<div class="settings-box continuation">
<settings-on-startup-page prefs="{{prefs}}">
</settings-on-startup-page>
</div>
</div>
</settings-animated-pages>
</template>
</dom-module>

Expand Down
27 changes: 22 additions & 5 deletions browser/resources/settings/brave_settings_overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ BravePatching.RegisterPolymerTemplateModifications({
console.error('[Brave Settings Overrides] Routes: could not find BASIC page')
}
r.GET_STARTED = r.BASIC.createSection('/getStarted', 'getStarted')
// bring back people's /manageProfile (now in getStarted)
r.MANAGE_PROFILE = r.GET_STARTED.createChild('/manageProfile');
r.SHIELDS = r.BASIC.createSection('/shields', 'shields')
r.SOCIAL_BLOCKING = r.BASIC.createSection('/socialBlocking', 'socialBlocking')
r.EXTENSIONS = r.BASIC.createSection('/extensions', 'extensions')
Expand Down Expand Up @@ -325,12 +327,27 @@ BravePatching.RegisterPolymerTemplateModifications({
}
},
'settings-people-page': (templateContent) => {
// Import item needs to know it's the first in the section
const importItem = templateContent.querySelector('#importDataDialogTrigger[on-click="onImportDataTap_"]')
if (!importItem) {
console.error('[Brave Settings Overrides] Could not find import item in people_page')
// People page needs to think it's in the getStarted section, since it is
// (we remove the People section as a separate section).
const page = templateContent.querySelector('settings-animated-pages[section=people]')
page.setAttribute('section', 'getStarted')
const profileTemplate = templateContent.querySelector('template[is="dom-if"][if="[[diceEnabled_]]"]')
// In chromium, the whole 'manage profile' section is only
// displayed if dice is enabled.
// Instead, always show it, but remove the google account specific entry.
profileTemplate.setAttribute('if', 'true')
const manageGoogleAccount = profileTemplate.content.querySelector('#manage-google-account')
if (!manageGoogleAccount) {
console.error('[Brave Settings Overrides] Could not find the google account settings item')
}
importItem.classList.add('first')
manageGoogleAccount.remove()
// Edit profile item needs to know it's the first in the section
const firstItem = profileTemplate.content.querySelector('#edit-profile')
if (!firstItem) {
console.error('[Brave Settings Overrides] Could not find #edit-profile item in people_page')
return
}
firstItem.classList.add('first')
},
'settings-payments-section': (templateContent) => {
const manageLink = templateContent.querySelector('#manageLink')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@
namespace settings {
void BraveAddLocalizedStrings(content::WebUIDataSource*, Profile*);
} // namespace settings
#include "../../../../../../chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc" // NOLINT

#include "brave/browser/ui/webui/brave_settings_ui.h"
// Override some chromium strings
#include "brave/grit/brave_generated_resources.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"

#undef IDS_SETTINGS_EDIT_PERSON
#define IDS_SETTINGS_EDIT_PERSON IDS_SETTINGS_BRAVE_EDIT_PROFILE
#undef IDS_SETTINGS_PROFILE_NAME_AND_PICTURE
#define IDS_SETTINGS_PROFILE_NAME_AND_PICTURE IDS_SETTINGS_BRAVE_EDIT_PROFILE

#include "../../../../../../chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc" // NOLINT

#include "brave/browser/ui/webui/brave_settings_ui.h"
namespace settings {

void BraveAddImportDataStrings(content::WebUIDataSource* html_source) {
Expand Down
10 changes: 10 additions & 0 deletions chromium_src/chrome/grit/generated_resources.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
// Copyright (c) 2019 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// 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/.

#ifndef BRAVE_CHROMIUM_SRC_CHROME_GRIT_GENERATED_RESOURCES_H_
#define BRAVE_CHROMIUM_SRC_CHROME_GRIT_GENERATED_RESOURCES_H_

#include "brave/grit/brave_generated_resources.h"
#include "../gen/chrome/grit/generated_resources.h"

#endif // BRAVE_CHROMIUM_SRC_CHROME_GRIT_GENERATED_RESOURCES_H_

0 comments on commit 754e6e9

Please sign in to comment.