-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ungoogled-software/master
Fast Forward
- Loading branch information
Showing
13 changed files
with
575 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
## Adds a copy of the bookmark bar into the toolbar to the right of the locationbar | ||
# | ||
# 'Other Bookmarks' and the Reading List are not shown. | ||
# You'll probably want to hide the existing bookmark bar through the right-click menu | ||
# as well as launch with --bookmark-bar-ntp=never | ||
# The location can be changed by moving the position in chrome/browser/ui/views/toolbar/toolbar_view.cc | ||
|
||
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc | ||
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc | ||
@@ -604,10 +604,11 @@ END_METADATA | ||
|
||
// BookmarkBarView ------------------------------------------------------------ | ||
|
||
-BookmarkBarView::BookmarkBarView(Browser* browser, BrowserView* browser_view) | ||
+BookmarkBarView::BookmarkBarView(Browser* browser, BrowserView* browser_view, bool isbbar) | ||
: AnimationDelegateViews(this), | ||
browser_(browser), | ||
- browser_view_(browser_view) { | ||
+ browser_view_(browser_view), | ||
+ isbbar_(isbbar) { | ||
SetID(VIEW_ID_BOOKMARK_BAR); | ||
Init(); | ||
|
||
@@ -873,7 +874,7 @@ void BookmarkBarView::Layout() { | ||
if (!model_) | ||
return; | ||
|
||
- int x = kBookmarkBarHorizontalMargin; | ||
+ int x = isbbar_ ? 0 : kBookmarkBarHorizontalMargin; | ||
int width = View::width() - 2 * kBookmarkBarHorizontalMargin; | ||
|
||
const int button_height = GetLayoutConstant(BOOKMARK_BAR_BUTTON_HEIGHT); | ||
@@ -949,7 +950,7 @@ void BookmarkBarView::Layout() { | ||
} | ||
|
||
if (model_->loaded() && !model_->bookmark_bar_node()->children().empty()) { | ||
- bool last_visible = x < max_x; | ||
+ bool last_visible = x < max_x || isbbar_; | ||
size_t button_count = bookmark_buttons_.size(); | ||
for (size_t i = 0; i <= button_count; ++i) { | ||
if (i == button_count) { | ||
@@ -971,6 +972,10 @@ void BookmarkBarView::Layout() { | ||
gfx::Size pref = child->GetPreferredSize(); | ||
int next_x = x + pref.width() + bookmark_bar_button_padding; | ||
last_visible = next_x < max_x; | ||
+ if (isbbar_) { | ||
+ next_x -= bookmark_bar_button_padding; | ||
+ last_visible = true; | ||
+ } | ||
child->SetVisible(last_visible); | ||
// Only need to set bounds if the view is actually visible. | ||
if (last_visible) | ||
@@ -979,6 +984,18 @@ void BookmarkBarView::Layout() { | ||
} | ||
} | ||
|
||
+ if (isbbar_ && !bookmark_buttons_.empty()) { | ||
+ bookmarks_separator_view_->SetBounds(x, (View::height() - bookmarks_separator_pref.height()) / 2, | ||
+ bookmarks_separator_pref.width(), bookmarks_separator_pref.height()); | ||
+ bookmarks_separator_view_->SetVisible(true); | ||
+ gfx::Size prefsize(x + bookmarks_separator_pref.width(), GetLayoutConstant(BOOKMARK_BAR_HEIGHT)); | ||
+ if (prefsize != GetPreferredSize()) { | ||
+ SetPreferredSize(prefsize); | ||
+ PreferredSizeChanged(); | ||
+ } | ||
+ return; | ||
+ } | ||
+ | ||
// Layout the right side buttons. | ||
x = max_x + bookmark_bar_button_padding; | ||
|
||
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h | ||
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h | ||
@@ -76,7 +76,7 @@ class BookmarkBarView : public views::Ac | ||
|
||
METADATA_HEADER(BookmarkBarView); | ||
// |browser_view| can be NULL during tests. | ||
- BookmarkBarView(Browser* browser, BrowserView* browser_view); | ||
+ BookmarkBarView(Browser* browser, BrowserView* browser_view, bool isbbar = false); | ||
BookmarkBarView(const BookmarkBarView&) = delete; | ||
BookmarkBarView& operator=(const BookmarkBarView&) = delete; | ||
~BookmarkBarView() override; | ||
@@ -477,6 +477,8 @@ class BookmarkBarView : public views::Ac | ||
// Returns WeakPtrs used in GetDropCallback(). Used to ensure | ||
// safety if `model_` is mutated after getting the callback. | ||
base::WeakPtrFactory<BookmarkBarView> drop_weak_ptr_factory_{this}; | ||
+ | ||
+ bool isbbar_ = false; | ||
}; | ||
|
||
#endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ | ||
--- a/chrome/browser/ui/views/frame/browser_view.cc | ||
+++ b/chrome/browser/ui/views/frame/browser_view.cc | ||
@@ -3388,6 +3388,7 @@ bool BrowserView::MaybeShowBookmarkBar(W | ||
// Don't change the visibility of the BookmarkBarView. BrowserViewLayout | ||
// handles it. | ||
bookmark_bar_view_->SetPageNavigator(GetActiveWebContents()); | ||
+ toolbar_->SetBookmarkPageNavigator(); | ||
|
||
// Update parenting for the bookmark bar. This may detach it from all views. | ||
bool needs_layout = false; | ||
--- a/chrome/browser/ui/views/toolbar/toolbar_view.cc | ||
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc | ||
@@ -38,6 +38,7 @@ | ||
#include "chrome/browser/ui/toolbar/chrome_labs_prefs.h" | ||
#include "chrome/browser/ui/ui_features.h" | ||
#include "chrome/browser/ui/view_ids.h" | ||
+#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | ||
#include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" | ||
#include "chrome/browser/ui/views/extensions/extension_popup.h" | ||
#include "chrome/browser/ui/views/extensions/extensions_side_panel_controller.h" | ||
@@ -332,6 +333,8 @@ void ToolbarView::Init() { | ||
|
||
location_bar_ = AddChildView(std::move(location_bar)); | ||
|
||
+ bbar_ = AddChildView(std::make_unique<BookmarkBarView>(browser_, browser_view_, true)); | ||
+ | ||
if (extensions_container) | ||
extensions_container_ = AddChildView(std::move(extensions_container)); | ||
|
||
@@ -502,6 +505,10 @@ bool ToolbarView::GetAppMenuFocused() co | ||
return app_menu_button_ && app_menu_button_->HasFocus(); | ||
} | ||
|
||
+void ToolbarView::SetBookmarkPageNavigator() { | ||
+ bbar_->SetPageNavigator(GetWebContents()); | ||
+} | ||
+ | ||
void ToolbarView::ShowIntentPickerBubble( | ||
std::vector<IntentPickerBubbleView::AppInfo> app_info, | ||
bool show_stay_in_chrome, | ||
--- a/chrome/browser/ui/views/toolbar/toolbar_view.h | ||
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.h | ||
@@ -124,6 +124,8 @@ class ToolbarView : public views::Access | ||
// Returns true if the app menu is focused. | ||
bool GetAppMenuFocused() const; | ||
|
||
+ void SetBookmarkPageNavigator(); | ||
+ | ||
void ShowIntentPickerBubble( | ||
std::vector<IntentPickerBubbleView::AppInfo> app_info, | ||
bool show_stay_in_chrome, | ||
@@ -275,6 +277,7 @@ class ToolbarView : public views::Access | ||
HomeButton* home_ = nullptr; | ||
CustomTabBarView* custom_tab_bar_ = nullptr; | ||
LocationBarView* location_bar_ = nullptr; | ||
+ BookmarkBarView* bbar_ = nullptr; | ||
ExtensionsToolbarContainer* extensions_container_ = nullptr; | ||
ChromeLabsButton* chrome_labs_button_ = nullptr; | ||
media_router::CastToolbarButton* cast_ = nullptr; |
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,37 @@ | ||
## Replaces the Show all downloads button in the download bar with a button that clears all downloads | ||
|
||
--- a/chrome/browser/download/download_shelf.cc | ||
+++ b/chrome/browser/download/download_shelf.cc | ||
@@ -151,3 +151,8 @@ void DownloadShelf::OnGetDownloadDoneFor | ||
ShowDownload(OfflineItemModel::Wrap(manager, item.value())); | ||
} | ||
} | ||
+ | ||
+void DownloadShelf::Clear() { | ||
+ auto* const manager = profile()->GetDownloadManager(); | ||
+ if (manager) manager->RemoveDownloadsByURLAndTime(base::BindRepeating([](const GURL&) { return true; }), base::Time(), base::Time()); | ||
+} | ||
--- a/chrome/browser/download/download_shelf.h | ||
+++ b/chrome/browser/download/download_shelf.h | ||
@@ -69,6 +69,8 @@ class DownloadShelf { | ||
virtual views::View* GetView() = 0; | ||
bool is_hidden() const { return is_hidden_; } | ||
|
||
+ void Clear(); | ||
+ | ||
protected: | ||
virtual void DoShowDownload(DownloadUIModel::DownloadUIModelPtr download) = 0; | ||
virtual void DoOpen() = 0; | ||
--- a/chrome/browser/ui/views/download/download_shelf_view.cc | ||
+++ b/chrome/browser/ui/views/download/download_shelf_view.cc | ||
@@ -78,8 +78,8 @@ DownloadShelfView::DownloadShelfView(Bro | ||
SetVisible(false); | ||
|
||
show_all_view_ = AddChildView(std::make_unique<views::MdTextButton>( | ||
- base::BindRepeating(&chrome::ShowDownloads, browser), | ||
- l10n_util::GetStringUTF16(IDS_SHOW_ALL_DOWNLOADS))); | ||
+ base::BindRepeating(&DownloadShelf::Clear, base::Unretained(this)), | ||
+ l10n_util::GetStringUTF16(IDS_DOWNLOAD_LINK_CLEAR_ALL))); | ||
show_all_view_->SizeToPreferredSize(); | ||
|
||
close_button_ = AddChildView(views::CreateVectorImageButton( |
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,159 @@ | ||
## Adds a flag to prevent autoplaying media | ||
|
||
--- a/chrome/browser/ungoogled_flag_entries.h | ||
+++ b/chrome/browser/ungoogled_flag_entries.h | ||
@@ -7,1 +7,5 @@ | ||
+ {"prevent-autoplay", | ||
+ "PreventAutoplay", | ||
+ "Prevents media from playing automatically. ungoogled-chromium flag.", | ||
+ kOsAll, FEATURE_VALUE_TYPE(media::kPreventAutoplay)}, | ||
#endif // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_ | ||
--- a/media/base/media_switches.cc | ||
+++ b/media/base/media_switches.cc | ||
@@ -908,6 +908,8 @@ const base::Feature kBresenhamCadence{"B | ||
const base::Feature kPlaybackSpeedButton{"PlaybackSpeedButton", | ||
base::FEATURE_ENABLED_BY_DEFAULT}; | ||
|
||
+const base::Feature kPreventAutoplay{"PreventAutoplay", base::FEATURE_DISABLED_BY_DEFAULT}; | ||
+ | ||
bool IsVideoCaptureAcceleratedJpegDecodingEnabled() { | ||
if (base::CommandLine::ForCurrentProcess()->HasSwitch( | ||
switches::kDisableAcceleratedMjpegDecode)) { | ||
--- a/media/base/media_switches.h | ||
+++ b/media/base/media_switches.h | ||
@@ -255,6 +255,8 @@ MEDIA_EXPORT extern const base::Feature | ||
MEDIA_EXPORT extern const base::Feature kDeprecateLowUsageCodecs; | ||
#endif | ||
|
||
+MEDIA_EXPORT extern const base::Feature kPreventAutoplay; | ||
+ | ||
// Based on a |command_line| and the current platform, returns the effective | ||
// autoplay policy. In other words, it will take into account the default policy | ||
// if none is specified via the command line and options passed for testing. | ||
--- a/third_party/blink/renderer/core/dom/document.cc | ||
+++ b/third_party/blink/renderer/core/dom/document.cc | ||
@@ -4081,6 +4081,7 @@ void Document::SetURL(const KURL& url) { | ||
if (GetFrame()) { | ||
if (FrameScheduler* frame_scheduler = GetFrame()->GetFrameScheduler()) | ||
frame_scheduler->TraceUrlChange(url_.GetString()); | ||
+ GetFrame()->ClearRealUserActivation(); | ||
} | ||
} | ||
|
||
--- a/third_party/blink/renderer/core/frame/local_frame.h | ||
+++ b/third_party/blink/renderer/core/frame/local_frame.h | ||
@@ -722,7 +722,17 @@ class CORE_EXPORT LocalFrame final : pub | ||
void RebindTextInputHostForTesting(); | ||
#endif | ||
|
||
+ void RealUserActivation() { rua_time_ = base::TimeTicks::Now(); } | ||
+ void ClearRealUserActivation() { rua_time_ = base::TimeTicks(); rua_allowed_ = false; } | ||
+ bool HasRealUserActivation() { | ||
+ if (!rua_allowed_) rua_allowed_ = (base::TimeTicks::Now() - rua_time_).InSeconds() < 1; | ||
+ return rua_allowed_; | ||
+ } | ||
+ | ||
private: | ||
+ bool rua_allowed_ = false; | ||
+ base::TimeTicks rua_time_ = base::TimeTicks(); | ||
+ | ||
friend class FrameNavigationDisabler; | ||
// LocalFrameMojoHandler is a part of LocalFrame. | ||
friend class LocalFrameMojoHandler; | ||
--- a/third_party/blink/renderer/core/html/media/html_media_element.cc | ||
+++ b/third_party/blink/renderer/core/html/media/html_media_element.cc | ||
@@ -2530,6 +2530,7 @@ bool HTMLMediaElement::ended() const { | ||
} | ||
|
||
bool HTMLMediaElement::Autoplay() const { | ||
+ if (base::FeatureList::IsEnabled(media::kPreventAutoplay)) return false; | ||
return FastHasAttribute(html_names::kAutoplayAttr); | ||
} | ||
|
||
@@ -2638,6 +2639,17 @@ ScriptPromise HTMLMediaElement::playForB | ||
absl::optional<DOMExceptionCode> HTMLMediaElement::Play() { | ||
DVLOG(2) << "play(" << *this << ")"; | ||
|
||
+ if (base::FeatureList::IsEnabled(media::kPreventAutoplay)) { | ||
+ if (!GetDocument().GetFrame()->HasRealUserActivation()) { | ||
+ if (rua_mute_state_ == -1) rua_mute_state_ = muted_; | ||
+ return DOMExceptionCode::kNotAllowedError; | ||
+ } | ||
+ if (rua_mute_state_ > -1) { | ||
+ if (muted_ != rua_mute_state_) setMuted(rua_mute_state_); | ||
+ rua_mute_state_ = -1; | ||
+ } | ||
+ } | ||
+ | ||
absl::optional<DOMExceptionCode> exception_code = | ||
autoplay_policy_->RequestPlay(); | ||
|
||
--- a/third_party/blink/renderer/core/html/media/html_media_element.h | ||
+++ b/third_party/blink/renderer/core/html/media/html_media_element.h | ||
@@ -763,6 +763,8 @@ class CORE_EXPORT HTMLMediaElement | ||
// playback raters other than 1.0. | ||
bool preserves_pitch_ = true; | ||
|
||
+ signed char rua_mute_state_ = -1; | ||
+ | ||
// Keeps track of when the player seek event was sent to the browser process. | ||
base::TimeTicks last_seek_update_time_; | ||
|
||
--- a/third_party/blink/renderer/core/input/event_handler.cc | ||
+++ b/third_party/blink/renderer/core/input/event_handler.cc | ||
@@ -830,6 +830,7 @@ WebInputEventResult EventHandler::Handle | ||
return WebInputEventResult::kHandledSuppressed; | ||
} | ||
|
||
+ frame_->RealUserActivation(); | ||
LocalFrame::NotifyUserActivation( | ||
frame_, mojom::blink::UserActivationNotificationType::kInteraction, | ||
RuntimeEnabledFeatures::BrowserVerifiedUserActivationMouseEnabled()); | ||
--- a/third_party/blink/renderer/core/input/gesture_manager.cc | ||
+++ b/third_party/blink/renderer/core/input/gesture_manager.cc | ||
@@ -240,6 +240,7 @@ WebInputEventResult GestureManager::Hand | ||
FlooredIntPoint(gesture_event.PositionInRootFrame()); | ||
Node* tapped_node = current_hit_test.InnerNode(); | ||
Element* tapped_element = current_hit_test.InnerElement(); | ||
+ if(tapped_node) tapped_node->GetDocument().GetFrame()->RealUserActivation(); | ||
LocalFrame::NotifyUserActivation( | ||
tapped_node ? tapped_node->GetDocument().GetFrame() : nullptr, | ||
mojom::blink::UserActivationNotificationType::kInteraction); | ||
@@ -403,6 +404,7 @@ WebInputEventResult GestureManager::Hand | ||
return WebInputEventResult::kNotHandled; | ||
} | ||
|
||
+ if(inner_node) inner_node->GetDocument().GetFrame()->RealUserActivation(); | ||
LocalFrame::NotifyUserActivation( | ||
inner_node ? inner_node->GetDocument().GetFrame() : nullptr, | ||
mojom::blink::UserActivationNotificationType::kInteraction); | ||
--- a/third_party/blink/renderer/core/input/keyboard_event_manager.cc | ||
+++ b/third_party/blink/renderer/core/input/keyboard_event_manager.cc | ||
@@ -210,6 +210,7 @@ WebInputEventResult KeyboardEventManager | ||
if (!is_modifier && initial_key_event.dom_key != ui::DomKey::ESCAPE && | ||
(initial_key_event.GetType() == WebInputEvent::Type::kKeyDown || | ||
initial_key_event.GetType() == WebInputEvent::Type::kRawKeyDown)) { | ||
+ frame_->RealUserActivation(); | ||
LocalFrame::NotifyUserActivation( | ||
frame_, mojom::blink::UserActivationNotificationType::kInteraction, | ||
RuntimeEnabledFeatures::BrowserVerifiedUserActivationKeyboardEnabled()); | ||
--- a/third_party/blink/renderer/core/input/pointer_event_manager.cc | ||
+++ b/third_party/blink/renderer/core/input/pointer_event_manager.cc | ||
@@ -650,6 +650,7 @@ WebInputEventResult PointerEventManager: | ||
// associated with so just pick the pointer event that comes. | ||
if (event.GetType() == WebInputEvent::Type::kPointerUp && | ||
!non_hovering_pointers_canceled_ && pointer_event_target.target_frame) { | ||
+ pointer_event_target.target_frame->RealUserActivation(); | ||
LocalFrame::NotifyUserActivation( | ||
pointer_event_target.target_frame, | ||
mojom::blink::UserActivationNotificationType::kInteraction); | ||
--- a/third_party/blink/renderer/modules/mediasession/media_session.cc | ||
+++ b/third_party/blink/renderer/modules/mediasession/media_session.cc | ||
@@ -410,6 +410,7 @@ void MediaSession::DidReceiveAction( | ||
LocalDOMWindow* window = GetSupplementable()->DomWindow(); | ||
if (!window) | ||
return; | ||
+ window->GetFrame()->RealUserActivation(); | ||
LocalFrame::NotifyUserActivation( | ||
window->GetFrame(), | ||
mojom::blink::UserActivationNotificationType::kInteraction); |
Oops, something went wrong.