Commit d42ff3d7 authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

[Picture in Picture] Use ButtonHandler for controls

Use a ButtonHandler for the play/pause and close buttons so
they can be picked up by voiceover.

BUG=848509

Change-Id: I6fb063c03156d48b814fd3d370703724753a0b29
Reviewed-on: https://chromium-review.googlesource.com/1153623
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Reviewed-by: default avatarapacible <apacible@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578821}
parent 71e508b9
...@@ -134,8 +134,8 @@ OverlayWindowViews::OverlayWindowViews( ...@@ -134,8 +134,8 @@ OverlayWindowViews::OverlayWindowViews(
window_background_view_(new views::View()), window_background_view_(new views::View()),
video_view_(new views::View()), video_view_(new views::View()),
controls_background_view_(new views::View()), controls_background_view_(new views::View()),
close_controls_view_(new views::ImageButton(nullptr)), close_controls_view_(new views::ImageButton(this)),
play_pause_controls_view_(new views::ToggleImageButton(nullptr)) { play_pause_controls_view_(new views::ToggleImageButton(this)) {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = CalculateAndUpdateWindowBounds(); params.bounds = CalculateAndUpdateWindowBounds();
...@@ -498,22 +498,6 @@ void OverlayWindowViews::OnNativeWidgetWorkspaceChanged() { ...@@ -498,22 +498,6 @@ void OverlayWindowViews::OnNativeWidgetWorkspaceChanged() {
// does not trigger this function. http://crbug.com/819673 // does not trigger this function. http://crbug.com/819673
} }
void OverlayWindowViews::OnKeyEvent(ui::KeyEvent* event) {
if (event->type() != ui::ET_KEY_RELEASED)
return;
if (event->key_code() == ui::VKEY_RETURN ||
event->key_code() == ui::VKEY_SPACE) {
if (play_pause_controls_view_->HasFocus()) {
TogglePlayPause();
} else if (close_controls_view_->HasFocus()) {
controller_->Close(true /* should_pause_video */);
}
event->SetHandled();
}
}
void OverlayWindowViews::OnMouseEvent(ui::MouseEvent* event) { void OverlayWindowViews::OnMouseEvent(ui::MouseEvent* event) {
switch (event->type()) { switch (event->type()) {
// Only show the media controls when the mouse is hovering over the window. // Only show the media controls when the mouse is hovering over the window.
...@@ -574,6 +558,15 @@ void OverlayWindowViews::OnGestureEvent(ui::GestureEvent* event) { ...@@ -574,6 +558,15 @@ void OverlayWindowViews::OnGestureEvent(ui::GestureEvent* event) {
} }
} }
void OverlayWindowViews::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == close_controls_view_.get())
controller_->Close(true /* should_pause_video */);
if (sender == play_pause_controls_view_.get())
TogglePlayPause();
}
void OverlayWindowViews::OnNativeFocus() { void OverlayWindowViews::OnNativeFocus() {
// Show the controls when the window takes focus. This is used for tab and // Show the controls when the window takes focus. This is used for tab and
// touch interactions. If initialisation happens after the window takes // touch interactions. If initialisation happens after the window takes
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "content/public/browser/overlay_window.h" #include "content/public/browser/overlay_window.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
namespace views { namespace views {
...@@ -17,7 +18,9 @@ class ToggleImageButton; ...@@ -17,7 +18,9 @@ class ToggleImageButton;
// The Chrome desktop implementation of OverlayWindow. This will only be // The Chrome desktop implementation of OverlayWindow. This will only be
// implemented in views, which will support all desktop platforms. // implemented in views, which will support all desktop platforms.
class OverlayWindowViews : public content::OverlayWindow, public views::Widget { class OverlayWindowViews : public content::OverlayWindow,
public views::ButtonListener,
public views::Widget {
public: public:
explicit OverlayWindowViews( explicit OverlayWindowViews(
content::PictureInPictureWindowController* controller); content::PictureInPictureWindowController* controller);
...@@ -42,10 +45,12 @@ class OverlayWindowViews : public content::OverlayWindow, public views::Widget { ...@@ -42,10 +45,12 @@ class OverlayWindowViews : public content::OverlayWindow, public views::Widget {
gfx::Size GetMinimumSize() const override; gfx::Size GetMinimumSize() const override;
gfx::Size GetMaximumSize() const override; gfx::Size GetMaximumSize() const override;
void OnNativeWidgetWorkspaceChanged() override; void OnNativeWidgetWorkspaceChanged() override;
void OnKeyEvent(ui::KeyEvent* event) override;
void OnMouseEvent(ui::MouseEvent* event) override; void OnMouseEvent(ui::MouseEvent* event) override;
void OnGestureEvent(ui::GestureEvent* event) override; void OnGestureEvent(ui::GestureEvent* event) override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// views::internal::NativeWidgetDelegate: // views::internal::NativeWidgetDelegate:
void OnNativeFocus() override; void OnNativeFocus() override;
void OnNativeBlur() override; void OnNativeBlur() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment