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

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

Issue 2802133002: Move MediaControlsWindowEventListener to modules/media_controls/. (Closed)
Patch Set: rebase after blink rename 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/MediaControlsWindowEventListener.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControlsWindowEventListener.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControlsWindowEventListener.cpp
deleted file mode 100644
index 3e3a9d75b89cfd04f890a61768562a8cd307227d..0000000000000000000000000000000000000000
--- a/third_party/WebKit/Source/core/html/shadow/MediaControlsWindowEventListener.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2016 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/MediaControlsWindowEventListener.h"
-
-#include "core/events/Event.h"
-#include "core/frame/LocalDOMWindow.h"
-#include "core/html/media/MediaControls.h"
-#include "core/html/shadow/MediaControlElements.h"
-
-namespace blink {
-
-namespace {
-
-// Helper returning the top DOMWindow as a LocalDOMWindow. Returns nullptr if it
-// is not a LocalDOMWindow.
-// This does not work with OOPIF.
-LocalDOMWindow* GetTopLocalDOMWindow(LocalDOMWindow* window) {
- if (!window->top() || !window->top()->IsLocalDOMWindow())
- return nullptr;
- return static_cast<LocalDOMWindow*>(window->top());
-}
-
-} // anonymous namespace
-
-MediaControlsWindowEventListener* MediaControlsWindowEventListener::Create(
- MediaControls* media_controls,
- std::unique_ptr<Callback> callback) {
- return new MediaControlsWindowEventListener(media_controls,
- std::move(callback));
-}
-
-MediaControlsWindowEventListener::MediaControlsWindowEventListener(
- MediaControls* media_controls,
- std::unique_ptr<Callback> callback)
- : EventListener(kCPPEventListenerType),
- media_controls_(media_controls),
- callback_(std::move(callback)),
- is_active_(false) {
- DCHECK(callback_);
-}
-
-bool MediaControlsWindowEventListener::operator==(
- const EventListener& other) const {
- return this == &other;
-}
-
-void MediaControlsWindowEventListener::Start() {
- if (is_active_)
- return;
-
- if (LocalDOMWindow* window = media_controls_->OwnerDocument().domWindow()) {
- window->addEventListener(EventTypeNames::click, this, true);
-
- if (LocalDOMWindow* outer_window = GetTopLocalDOMWindow(window)) {
- if (window != outer_window)
- outer_window->addEventListener(EventTypeNames::click, this, true);
- outer_window->addEventListener(EventTypeNames::resize, this, true);
- }
- }
-
- media_controls_->PanelElement()->addEventListener(EventTypeNames::click, this,
- false);
- media_controls_->TimelineElement()->addEventListener(EventTypeNames::click,
- this, false);
- media_controls_->CastButtonElement()->addEventListener(EventTypeNames::click,
- this, false);
- media_controls_->VolumeSliderElement()->addEventListener(
- EventTypeNames::click, this, false);
-
- is_active_ = true;
-}
-
-void MediaControlsWindowEventListener::Stop() {
- if (!is_active_)
- return;
-
- if (LocalDOMWindow* window = media_controls_->OwnerDocument().domWindow()) {
- window->removeEventListener(EventTypeNames::click, this, true);
-
- if (LocalDOMWindow* outer_window = GetTopLocalDOMWindow(window)) {
- if (window != outer_window)
- outer_window->removeEventListener(EventTypeNames::click, this, true);
- outer_window->removeEventListener(EventTypeNames::resize, this, true);
- }
-
- is_active_ = false;
- }
-
- media_controls_->PanelElement()->removeEventListener(EventTypeNames::click,
- this, false);
- media_controls_->TimelineElement()->removeEventListener(EventTypeNames::click,
- this, false);
- media_controls_->CastButtonElement()->removeEventListener(
- EventTypeNames::click, this, false);
- media_controls_->VolumeSliderElement()->removeEventListener(
- EventTypeNames::click, this, false);
-
- is_active_ = false;
-}
-
-void MediaControlsWindowEventListener::handleEvent(
- ExecutionContext* execution_context,
- Event* event) {
- DCHECK(event->type() == EventTypeNames::click ||
- event->type() == EventTypeNames::resize);
-
- if (!is_active_)
- return;
- (*callback_.get())();
-}
-
-DEFINE_TRACE(MediaControlsWindowEventListener) {
- EventListener::Trace(visitor);
- visitor->Trace(media_controls_);
-}
-
-} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698