-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add horizontal margin to LocationBar, centering on Toolbar where poss…
…ible Can be disabled via user preference under Appearance section of settings page. Takes the opportunity to create a Brave whitelist for the settingsPrivate javascript API without adding items through patching chromium directly. This is achieved via subclassing `extensions::PrefsUtil`. Whilst a target margin is determined according to window's width and a maximum LocationBar width, such as 3%, 5%, 7% or more consider we determined that it's a nicer effect if the LocationBar is centered on the Toolbar, and not within the space between items on the left and right side of the Toolbar, which can be varying widths, especially with many extensions. Therefore space is allocated from the right margin to the left in order to 'shim' the center point of the LocationBar towards the center point of the Toolbar. Similarly space can also be allocated from the left margin to the right for the same purpose, but not so much that it encroaches more than 25% in to the right margin, so not to get too close to extension Browser Actions. BookmarkButton is then anchored to the floating LocationBar. LocationBar max width is 1080px which is calculated from Brave 0.23's 900px width and increased with appropriate space for the Brave Actions.
- Loading branch information
Showing
17 changed files
with
260 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
browser/extensions/api/settings_private/brave_prefs_util.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* 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/. */ | ||
|
||
#include "brave/browser/extensions/api/settings_private/brave_prefs_util.h" | ||
|
||
#include "brave/common/pref_names.h" | ||
#include "chrome/browser/extensions/api/settings_private/prefs_util.h" | ||
#include "chrome/common/pref_names.h" | ||
#include "chrome/common/extensions/api/settings_private.h" | ||
|
||
namespace extensions{ | ||
|
||
namespace settings_api = api::settings_private; | ||
|
||
const PrefsUtil::TypedPrefMap& BravePrefsUtil::GetWhitelistedKeys() { | ||
// Static cache, similar to parent class | ||
static PrefsUtil::TypedPrefMap* s_brave_whitelist = nullptr; | ||
if (s_brave_whitelist) | ||
return *s_brave_whitelist; | ||
s_brave_whitelist = new PrefsUtil::TypedPrefMap(); | ||
// Start with parent class whitelist | ||
const auto chromium_prefs = PrefsUtil::GetWhitelistedKeys(); | ||
s_brave_whitelist->insert(chromium_prefs.begin(), chromium_prefs.end()); | ||
// Add Brave values to the whitelist | ||
#if !defined(OS_CHROMEOS) | ||
// import data | ||
(*s_brave_whitelist)[::prefs::kImportDialogCookies] = | ||
settings_api::PrefType::PREF_TYPE_BOOLEAN; | ||
(*s_brave_whitelist)[::prefs::kImportDialogStats] = | ||
settings_api::PrefType::PREF_TYPE_BOOLEAN; | ||
#endif | ||
// appearance prefs | ||
(*s_brave_whitelist)[kLocationBarIsWide] = | ||
settings_api::PrefType::PREF_TYPE_BOOLEAN; | ||
return *s_brave_whitelist; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
browser/extensions/api/settings_private/brave_prefs_util.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* 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_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_BRAVE_PREFS_UTIL_H | ||
#define BRAVE_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_BRAVE_PREFS_UTIL_H | ||
|
||
#include "chrome/browser/extensions/api/settings_private/prefs_util.h" | ||
namespace extensions{ | ||
|
||
class BravePrefsUtil : public PrefsUtil { | ||
public: | ||
using PrefsUtil::PrefsUtil; | ||
// Gets the list of whitelisted pref keys -- that is, those which correspond | ||
// to prefs that clients of the settingsPrivate API may retrieve and | ||
// manipulate. | ||
const PrefsUtil::TypedPrefMap& GetWhitelistedKeys() override; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
chromium_src/chrome/browser/extensions/api/settings_private/settings_private_delegate.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "brave/browser/extensions/api/settings_private/brave_prefs_util.h" | ||
|
||
#define PrefsUtil BravePrefsUtil | ||
#include "../../../../../../chrome/browser/extensions/api/settings_private/settings_private_delegate.cc" | ||
#undef PrefsUtil |
5 changes: 5 additions & 0 deletions
5
chromium_src/chrome/browser/extensions/api/settings_private/settings_private_event_router.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "brave/browser/extensions/api/settings_private/brave_prefs_util.h" | ||
|
||
#define PrefsUtil BravePrefsUtil | ||
#include "../../../../../../chrome/browser/extensions/api/settings_private/settings_private_event_router.cc" | ||
#undef PrefsUtil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.