Skip to content

Commit

Permalink
add sync to the settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Nov 16, 2018
1 parent 246c75d commit fc0d391
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 8 deletions.
7 changes: 7 additions & 0 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,13 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
<message name="IDS_SETTINGS_WEBRTC_POLICY_DISABLE_NON_PROXIED_UDP" desc="Select value">
Disable non-proxied UDP
</message>
<!-- Brave Sync Settings -->
<message name="IDS_SETTINGS_BRAVE_SYNC_TITLE" desc="The title for Brave Sync in settings">
Brave Sync
</message>
<message name="IDS_SETTINGS_BRAVE_SYNC_LINK_LABEL" desc="Brave Sync link label">
Access Brave Sync via
</message>
</messages>
<includes>
<include name="IDR_BRAVE_TAG_SERVICES_POLYFILL" file="resources/js/tag_services_polyfill.js" type="BINDATA" />
Expand Down
7 changes: 7 additions & 0 deletions browser/resources/settings/brave_page_visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ cr.define('settings', function() {
}
}

const braveSyncHandler = {
get: function(obj, prop) {
return true;
}
};

const handler = {
get: function(obj, prop) {
if (prop === 'appearance') return new Proxy({}, appearanceHandler);
if (prop === 'braveShieldsDefaults') return new Proxy({}, braveShieldsDefaultsHandler);
if (prop === 'privacy') return new Proxy({}, privacyHandler);
if (prop === 'braveSync') return new Proxy({}, braveSyncHandler);
return prop === 'a11y' ? false : true;
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<link rel="href" src="chrome://resources/html/cr.html">
<script src="brave_sync_browser_proxy.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* 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/. */

cr.define('settings', function() {
/** @interface */
class DefaultBraveSyncBrowserProxy {}

/**
* @implements {settings.DefaultBraveSyncBrowserProxy}
*/
class DefaultBraveSyncBrowserProxyImpl {}

cr.addSingletonGetter(DefaultBraveSyncBrowserProxyImpl);

return {
DefaultBraveSyncBrowserProxy,
DefaultBraveSyncBrowserProxyImpl
};
});
20 changes: 20 additions & 0 deletions browser/resources/settings/brave_sync_page/brave_sync_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<link rel="import" href="chrome://resources/html/polymer.html">

<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/html/md_select_css.html">
<link rel="import" href="brave_sync_browser_proxy.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="../settings_vars_css.html">

<dom-module id="settings-brave-sync-page">
<template>
<style include="settings-shared md-select iron-flex">
</style>
<div class="settings-box">
<div class="start">
$i18n{braveSyncLabel} <a href="brave://bravesync" target="_blank">brave://bravesync</a>
</div>
</div>
</template>
<script src="brave_sync_page.js"></script>
</dom-module>
29 changes: 29 additions & 0 deletions browser/resources/settings/brave_sync_page/brave_sync_page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* 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/. */

(function() {
'use strict';

/**
* 'settings-brave-sync-page' is the settings page containing brave's
* custom sync.
*/
Polymer({
is: 'settings-brave-sync-page',

properties: {},

/** @private {?settings.DefaultBraveSyncBrowserProxy} */
browserProxy_: null,

/** @override */
created: function() {
this.browserProxy_ = settings.DefaultBraveSyncBrowserProxyImpl.getInstance();
},

/** @override */
ready: function() {
},
});
})();
5 changes: 5 additions & 0 deletions browser/resources/settings/settings_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<structure name="IDR_SETTINGS_BRAVE_PERSONALIZATION_OPTIONS_JS" file="brave_privacy_page/brave_personalization_options.js" type="chrome_html" preprocess="true" />
<structure name="IDR_SETTINGS_BRAVE_PRIVACY_PAGE_BROWSER_PROXY_HTML" file="brave_privacy_page/brave_privacy_page_browser_proxy.html" type="chrome_html" />
<structure name="IDR_SETTINGS_BRAVE_PRIVACY_PAGE_BROWSER_PROXY_JS" file="brave_privacy_page/brave_privacy_page_browser_proxy.js" type="chrome_html" preprocess="true" />
<!-- brave sync -->
<structure name="IDR_SETTINGS_BRAVE_SYNC_BROWSER_PROXY_HTML" file="brave_sync_page/brave_sync_browser_proxy.html" type="chrome_html" />
<structure name="IDR_SETTINGS_BRAVE_SYNC_BROWSER_PROXY_JS" file="brave_sync_page/brave_sync_browser_proxy.js" type="chrome_html" preprocess="true" />
<structure name="IDR_SETTINGS_BRAVE_SYNC_PAGE_JS" file="brave_sync_page/brave_sync_page.js" type="chrome_html" preprocess="true" />
<structure name="IDR_SETTINGS_BRAVE_SYNC_PAGE_HTML" file="brave_sync_page/brave_sync_page.html" type="chrome_html" preprocess="true" allowexternalscript="true" />
</structures>
<includes>
<include name="IDR_SETTINGS_BRAVE_STAMP" file="brave_unpack.stamp" type="BINDATA" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source,
{"defaultPublicInterfaceOnly",
IDS_SETTINGS_WEBRTC_POLICY_DEFAULT_PUBLIC_INTERFACE_ONLY},
{"disableNonProxiedUdp",
IDS_SETTINGS_WEBRTC_POLICY_DISABLE_NON_PROXIED_UDP}
IDS_SETTINGS_WEBRTC_POLICY_DISABLE_NON_PROXIED_UDP},
{"braveSync",
IDS_SETTINGS_BRAVE_SYNC_TITLE},
{"braveSyncLabel",
IDS_SETTINGS_BRAVE_SYNC_LINK_LABEL}
};
AddLocalizedStringsBulk(html_source, localized_strings,
arraysize(localized_strings));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
diff --git a/chrome/browser/resources/settings/basic_page/basic_page.html b/chrome/browser/resources/settings/basic_page/basic_page.html
index 2e8fb6c622b75e53380e0e21c38e14e116d2c59e..3d0fc996e7e0203a6362b434e96c8139d709c4c7 100644
index 2e8fb6c622b75e53380e0e21c38e14e116d2c59e..83eb299d0c9b71ad56d646affb139d0039582b5f 100644
--- a/chrome/browser/resources/settings/basic_page/basic_page.html
+++ b/chrome/browser/resources/settings/basic_page/basic_page.html
@@ -26,6 +26,7 @@
@@ -26,6 +26,8 @@

<if expr="not chromeos">
<link rel="import" href="../default_browser_page/default_browser_page.html">
+<link rel="import" href="../default_brave_shields_page/default_brave_shields_page.html">
+<link rel="import" href="../brave_sync_page/brave_sync_page.html">
</if>

<!-- TODO(michaelpg): Rename to something better than "basic" now that this page
@@ -205,6 +206,13 @@
@@ -205,6 +207,20 @@
</settings-section>
</template>
</if>
Expand All @@ -20,6 +21,13 @@ index 2e8fb6c622b75e53380e0e21c38e14e116d2c59e..3d0fc996e7e0203a6362b434e96c8139
+ section="braveShieldsDefaults">
+ <settings-default-brave-shields-page prefs="{{prefs}}"></settings-default-brave-shields-page>
+ </settings-section>
+ </template>
+ <template is="dom-if" if="[[showPage_(pageVisibility.braveSync)]]"
+ restamp>
+ <settings-section page-title="$i18n{braveSync}"
+ section="braveSync">
+ <settings-brave-sync-page prefs="{{prefs}}"></settings-brave-sync-page>
+ </settings-section>
+ </template>
<template is="dom-if" if="[[showPage_(pageVisibility.onStartup)]]"
restamp>
Expand Down
9 changes: 5 additions & 4 deletions patches/chrome-browser-resources-settings-route.js.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
diff --git a/chrome/browser/resources/settings/route.js b/chrome/browser/resources/settings/route.js
index 3099fa50bcfc1e2ba442910650de4fcdd871fdca..5905b2be45533cc4985e31d8cf0d77c831f20c10 100644
index 3099fa50bcfc1e2ba442910650de4fcdd871fdca..4a6631076d8b68776acc294807924150ca1a8e59 100644
--- a/chrome/browser/resources/settings/route.js
+++ b/chrome/browser/resources/settings/route.js
@@ -256,6 +256,7 @@ cr.define('settings', function() {
@@ -256,6 +256,8 @@ cr.define('settings', function() {

r.SEARCH = r.BASIC.createSection('/search', 'search');
r.SEARCH_ENGINES = r.SEARCH.createChild('/searchEngines');
+ r.SHIELDS = r.BASIC.createSection('/shields', 'braveShieldsDefaults');
+ r.BRAVE_SYNC = r.BASIC.createSection('/braveSync', 'braveSync');
// <if expr="chromeos">
r.GOOGLE_ASSISTANT = r.SEARCH.createChild('/googleAssistant');

@@ -333,9 +334,12 @@ cr.define('settings', function() {
@@ -333,9 +335,12 @@ cr.define('settings', function() {

// TODO(tommycli): Find a way to refactor these repetitive category
// routes.
Expand All @@ -23,7 +24,7 @@ index 3099fa50bcfc1e2ba442910650de4fcdd871fdca..5905b2be45533cc4985e31d8cf0d77c8
r.SITE_SETTINGS_BACKGROUND_SYNC =
r.SITE_SETTINGS.createChild('backgroundSync');
r.SITE_SETTINGS_CAMERA = r.SITE_SETTINGS.createChild('camera');
@@ -401,7 +405,9 @@ cr.define('settings', function() {
@@ -401,7 +406,9 @@ cr.define('settings', function() {
}

r.PRINTING = r.ADVANCED.createSection('/printing', 'printing');
Expand Down

0 comments on commit fc0d391

Please sign in to comment.