blob: f3d64aef5197e500b7f61823a0bfe9d65f1ee1ca [file] [log] [blame]
// Copyright 2014 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.
#ifndef CHROMECAST_BROWSER_SERVICE_CAST_SERVICE_SIMPLE_H_
#define CHROMECAST_BROWSER_SERVICE_CAST_SERVICE_SIMPLE_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chromecast/browser/cast_content_window.h"
#include "chromecast/browser/cast_web_view.h"
#include "chromecast/service/cast_service.h"
#include "url/gurl.h"
namespace content {
class BrowserContext;
} // namespace content
namespace chromecast {
class CastWebService;
class CastWebViewFactory;
class CastWindowManager;
namespace shell {
class CastServiceSimple : public CastService, public CastWebView::Delegate {
public:
CastServiceSimple(content::BrowserContext* browser_context,
CastWindowManager* window_manager);
CastServiceSimple(const CastServiceSimple&) = delete;
CastServiceSimple& operator=(const CastServiceSimple&) = delete;
~CastServiceSimple() override;
protected:
// CastService implementation:
void InitializeInternal() override;
void FinalizeInternal() override;
void StartInternal() override;
void StopInternal() override;
// CastContentWindow::Delegate implementation:
void OnWindowDestroyed() override;
void OnVisibilityChange(VisibilityType visibility_type) override;
private:
const std::unique_ptr<CastWebViewFactory> web_view_factory_;
const std::unique_ptr<CastWebService> web_service_;
CastWebView::Scoped cast_web_view_;
GURL startup_url_;
base::WeakPtrFactory<CastServiceSimple> weak_factory_{this};
};
} // namespace shell
} // namespace chromecast
#endif // CHROMECAST_BROWSER_SERVICE_CAST_SERVICE_SIMPLE_H_