blob: ff4c14da93d30fe877ce4882f7b5466fb7da8fdc [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.
#ifndef CHROMECAST_BROWSER_CAST_WEB_VIEW_EXTENSION_H_
#define CHROMECAST_BROWSER_CAST_WEB_VIEW_EXTENSION_H_
#include <memory>
#include "chromecast/browser/cast_web_contents_impl.h"
#include "chromecast/browser/cast_web_view.h"
#include "content/public/browser/media_capture_devices.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/notification_types.h"
#include "extensions/common/extension.h"
#include "url/gurl.h"
namespace chromecast {
class CastExtensionHost;
// A simplified interface for loading and displaying WebContents in cast_shell.
class CastWebViewExtension : public CastWebView,
public content::WebContentsObserver {
public:
// |delegate| and |browser_context| should outlive the lifetime of this
// object.
CastWebViewExtension(const CreateParams& params,
content::BrowserContext* browser_context,
scoped_refptr<content::SiteInstance> site_instance,
const extensions::Extension* extension,
const GURL& initial_url);
~CastWebViewExtension() override;
shell::CastContentWindow* window() const override;
content::WebContents* web_contents() const override;
CastWebContents* cast_web_contents() override;
// CastWebView implementation:
void LoadUrl(GURL url) override;
void ClosePage(const base::TimeDelta& shutdown_delay) override;
void InitializeWindow(CastWindowManager* window_manager,
CastWindowManager::WindowId z_order,
VisibilityPriority initial_priority) override;
void GrantScreenAccess() override;
void RevokeScreenAccess() override;
private:
// WebContentsObserver implementation:
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
Delegate* const delegate_;
const std::unique_ptr<shell::CastContentWindow> window_;
const std::unique_ptr<CastExtensionHost> extension_host_;
CastWebContentsImpl cast_web_contents_;
scoped_refptr<content::SiteInstance> site_instance_;
DISALLOW_COPY_AND_ASSIGN(CastWebViewExtension);
};
} // namespace chromecast
#endif // CHROMECAST_BROWSER_CAST_WEB_VIEW_EXTENSION_H_