blob: 3cd42c269ed3e9ac13241e9c0350f4da00782335 [file] [log] [blame]
// Copyright 2018 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 "chromecast/browser/cast_web_contents.h"
namespace chromecast {
std::vector<chromecast::shell::mojom::FeaturePtr>
CastWebContents::Delegate::GetRendererFeatures() {
return std::vector<chromecast::shell::mojom::FeaturePtr>();
}
CastWebContents::Observer::Observer() : cast_web_contents_(nullptr) {}
CastWebContents::Observer::~Observer() {
if (cast_web_contents_) {
cast_web_contents_->RemoveObserver(this);
}
}
void CastWebContents::Observer::Observe(CastWebContents* cast_web_contents) {
if (cast_web_contents == cast_web_contents_) {
// Early exit to avoid infinite loops if we're in the middle of a callback.
return;
}
if (cast_web_contents_) {
cast_web_contents_->RemoveObserver(this);
}
cast_web_contents_ = cast_web_contents;
if (cast_web_contents_) {
cast_web_contents_->AddObserver(this);
}
}
void CastWebContents::Observer::ResetCastWebContents() {
cast_web_contents_->RemoveObserver(this);
cast_web_contents_ = nullptr;
}
} // namespace chromecast