Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: third_party/WebKit/Source/core/html/shadow/MediaRemotingElements.cpp

Issue 2767823002: Media Remoting: Add interstitial elements to media element shadow dom. (Closed)
Patch Set: Updated with new UX design. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/shadow/MediaRemotingElements.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/MediaRemotingElements.cpp b/third_party/WebKit/Source/core/html/shadow/MediaRemotingElements.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4374a7af5482acb3d0bd9e741d4d7b5fffd7a77d
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/shadow/MediaRemotingElements.cpp
@@ -0,0 +1,89 @@
+// 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 "core/html/shadow/MediaRemotingElements.h"
+
+#include "core/InputTypeNames.h"
+#include "core/dom/ClientRect.h"
+#include "core/dom/Text.h"
+#include "core/dom/shadow/ShadowRoot.h"
+#include "core/events/MouseEvent.h"
+#include "core/html/HTMLVideoElement.h"
+#include "core/input/EventHandler.h"
+#include "platform/text/PlatformLocale.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebLocalizedString.h"
+
+namespace blink {
+
+using namespace HTMLNames;
+
+class MediaRemotingDisableButtonElement::MouseEventsListener final
+ : public EventListener {
+ public:
+ explicit MouseEventsListener(MediaRemotingDisableButtonElement& element)
+ : EventListener(kCPPEventListenerType), element_(element) {}
+
+ bool operator==(const EventListener& other) const override {
+ return this == &other;
+ }
+
+ void Trace(blink::Visitor* visitor) {
+ visitor->Trace(element_);
+ EventListener::Trace(visitor);
+ }
+
+ private:
+ void handleEvent(ExecutionContext* context, Event* event) override {
+ DCHECK(event->type() == EventTypeNames::click);
+
+ MouseEvent* mouse_event = ToMouseEvent(event);
+ ClientRect* client_rect = element_->getBoundingClientRect();
+ const double x = mouse_event->x();
+ const double y = mouse_event->y();
+ if (x < client_rect->left() || x > client_rect->right() ||
+ y < client_rect->top() || y > client_rect->bottom())
+ return;
+
+ element_->VideoElement().DisableMediaRemoting();
+ event->SetDefaultHandled();
+ event->stopPropagation();
+ element_->GetDocument().removeEventListener(EventTypeNames::click, this,
+ true);
+ }
+
+ Member<MediaRemotingDisableButtonElement> element_;
+};
+
+MediaRemotingDisableButtonElement::MediaRemotingDisableButtonElement(
+ MediaRemotingInterstitialElements& interstitial_elements)
+ : HTMLInputElement(interstitial_elements.GetDocument(), false),
+ interstitial_elements_(interstitial_elements) {
+ listener_ = new MouseEventsListener(*this);
+ EnsureUserAgentShadowRoot();
+ setType(InputTypeNames::text);
+ setValue(interstitial_elements.VideoElement().GetLocale().QueryString(
+ WebLocalizedString::kMediaRemotingDisableText));
+ SetShadowPseudoId(AtomicString("-internal-media-remoting-disable-button"));
+}
+
+void MediaRemotingDisableButtonElement::OnShown() {
+ GetDocument().addEventListener(EventTypeNames::click, listener_, true);
+}
+
+void MediaRemotingDisableButtonElement::OnHidden() {
+ GetDocument().removeEventListener(EventTypeNames::click, listener_, true);
+}
+
+HTMLVideoElement& MediaRemotingDisableButtonElement::VideoElement() const {
+ return interstitial_elements_->VideoElement();
+}
+
+DEFINE_TRACE(MediaRemotingDisableButtonElement) {
+ visitor->Trace(interstitial_elements_);
+ visitor->Trace(listener_);
+ HTMLInputElement::Trace(visitor);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698