| Index: third_party/WebKit/Source/modules/media_controls/elements/MediaControlMuteButtonElement.cpp
|
| diff --git a/third_party/WebKit/Source/modules/media_controls/elements/MediaControlMuteButtonElement.cpp b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlMuteButtonElement.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c4bc99730b2d1ab3e01d1c3ac4f1b1b72c6fbcd2
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/modules/media_controls/elements/MediaControlMuteButtonElement.cpp
|
| @@ -0,0 +1,65 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "modules/media_controls/elements/MediaControlMuteButtonElement.h"
|
| +
|
| +#include "core/InputTypeNames.h"
|
| +#include "core/events/Event.h"
|
| +#include "core/html/HTMLMediaElement.h"
|
| +#include "modules/media_controls/MediaControlsImpl.h"
|
| +#include "public/platform/Platform.h"
|
| +
|
| +namespace blink {
|
| +
|
| +MediaControlMuteButtonElement::MediaControlMuteButtonElement(
|
| + MediaControlsImpl& media_controls)
|
| + : MediaControlInputElement(media_controls, kMediaMuteButton) {
|
| + EnsureUserAgentShadowRoot();
|
| + setType(InputTypeNames::button);
|
| + SetShadowPseudoId(AtomicString("-webkit-media-controls-mute-button"));
|
| +}
|
| +
|
| +bool MediaControlMuteButtonElement::WillRespondToMouseClickEvents() {
|
| + return true;
|
| +}
|
| +
|
| +void MediaControlMuteButtonElement::UpdateDisplayType() {
|
| + // TODO(mlamouri): checking for volume == 0 because the mute button will look
|
| + // 'muted' when the volume is 0 even if the element is not muted. This allows
|
| + // the painting and the display type to actually match.
|
| + SetDisplayType((MediaElement().muted() || MediaElement().volume() == 0)
|
| + ? kMediaUnMuteButton
|
| + : kMediaMuteButton);
|
| + UpdateOverflowString();
|
| +}
|
| +
|
| +WebLocalizedString::Name
|
| +MediaControlMuteButtonElement::GetOverflowStringName() {
|
| + if (MediaElement().muted())
|
| + return WebLocalizedString::kOverflowMenuUnmute;
|
| + return WebLocalizedString::kOverflowMenuMute;
|
| +}
|
| +
|
| +bool MediaControlMuteButtonElement::HasOverflowButton() {
|
| + return true;
|
| +}
|
| +
|
| +void MediaControlMuteButtonElement::DefaultEventHandler(Event* event) {
|
| + if (event->type() == EventTypeNames::click) {
|
| + if (MediaElement().muted()) {
|
| + Platform::Current()->RecordAction(
|
| + UserMetricsAction("Media.Controls.Unmute"));
|
| + } else {
|
| + Platform::Current()->RecordAction(
|
| + UserMetricsAction("Media.Controls.Mute"));
|
| + }
|
| +
|
| + MediaElement().setMuted(!MediaElement().muted());
|
| + event->SetDefaultHandled();
|
| + }
|
| +
|
| + MediaControlInputElement::DefaultEventHandler(event);
|
| +}
|
| +
|
| +} // namespace blink
|
|
|