| Index: third_party/WebKit/Source/core/dom/MediaIPHManager.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/MediaIPHManager.cpp b/third_party/WebKit/Source/core/dom/MediaIPHManager.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..57f80749bc7ea3cae84c642f3344ddec2c03bed2
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/dom/MediaIPHManager.cpp
|
| @@ -0,0 +1,67 @@
|
| +// 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/dom/MediaIPHManager.h"
|
| +
|
| +#include "core/dom/Document.h"
|
| +#include "core/html/HTMLMediaElement.h"
|
| +#include "platform/heap/GarbageCollected.h"
|
| +
|
| +namespace blink {
|
| +// static
|
| +MediaIPHManager* MediaIPHManager::Create(
|
| + std::unique_ptr<WebMediaIPH> media_iph) {
|
| + return new MediaIPHManager(std::move(media_iph));
|
| +}
|
| +
|
| +MediaIPHManager::MediaIPHManager(std::unique_ptr<WebMediaIPH> media_iph)
|
| + : media_iph_(std::move(media_iph)) {
|
| + media_iph_->BindToClient(this);
|
| +}
|
| +
|
| +MediaIPHManager::~MediaIPHManager() = default;
|
| +
|
| +DEFINE_TRACE(MediaIPHManager) {
|
| + visitor->Trace(active_element_);
|
| +}
|
| +
|
| +bool MediaIPHManager::IPHTriggerObservedOnElement(HTMLMediaElement& element) {
|
| + if (state_ != IPHState::kNotShowing)
|
| + return false;
|
| +
|
| + active_element_ = &element;
|
| + state_ = IPHState::kShowing;
|
| + return true;
|
| +}
|
| +
|
| +void MediaIPHManager::LayoutUpdated() {
|
| + if (state_ != IPHState::kShowing)
|
| + return;
|
| +
|
| + // If the element was removed or the download button was removed, hide the
|
| + // IPH widget.
|
| + IntRect button_rect;
|
| + if (!active_element_ ||
|
| + !active_element_->GetMediaControls()->GetDownloadButtonRect(
|
| + button_rect)) {
|
| + // Request hide and wait for an ack from the browser.
|
| + state_ = IPHState::kHideRequested;
|
| + media_iph_->HideMediaDownloadIPH();
|
| + return;
|
| + }
|
| +
|
| + media_iph_->ShowMediaDownloadIPH(button_rect);
|
| +}
|
| +
|
| +void MediaIPHManager::DidHideMediaIPHWidget() {
|
| + if (state_ == IPHState::kNotShowing)
|
| + return;
|
| +
|
| + state_ = IPHState::kNotShowing;
|
| + if (active_element_)
|
| + active_element_->GetMediaControls()->IPHDisabled();
|
| + active_element_ = nullptr;
|
| +}
|
| +
|
| +} // namespace blink
|
|
|