| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMECAST_BROWSER_CAST_CONTENT_WINDOW_H_ | 5 #ifndef CHROMECAST_BROWSER_CAST_CONTENT_WINDOW_H_ |
| 6 #define CHROMECAST_BROWSER_CAST_CONTENT_WINDOW_H_ | 6 #define CHROMECAST_BROWSER_CAST_CONTENT_WINDOW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chromecast/graphics/cast_vsync_settings.h" | 11 #include "ui/events/event.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | |
| 13 | |
| 14 namespace aura { | |
| 15 class WindowTreeHost; | |
| 16 } | |
| 17 | 12 |
| 18 namespace content { | 13 namespace content { |
| 19 class BrowserContext; | 14 class BrowserContext; |
| 20 class WebContents; | 15 class WebContents; |
| 21 } | 16 } |
| 22 | 17 |
| 23 namespace chromecast { | 18 namespace chromecast { |
| 24 namespace shell { | 19 namespace shell { |
| 25 | 20 |
| 26 class CastContentWindow : public content::WebContentsObserver, | 21 // Class that represents the "window" a WebContents is displayed in cast_shell. |
| 27 public CastVSyncSettings::Observer { | 22 // For Linux, this represents an Aura window. For Android, this is a Activity. |
| 23 // See CastContentWindowLinux and CastContentWindowAndroid. |
| 24 class CastContentWindow { |
| 28 public: | 25 public: |
| 29 CastContentWindow(); | 26 class Delegate { |
| 27 public: |
| 28 virtual void OnWindowDestroyed() = 0; |
| 29 virtual void OnKeyEvent(const ui::KeyEvent& key_event) = 0; |
| 30 | 30 |
| 31 // Removes the window from the screen. | 31 protected: |
| 32 ~CastContentWindow() override; | 32 virtual ~Delegate() {} |
| 33 }; |
| 34 |
| 35 // Creates the platform specific CastContentWindow. |delegate| should outlive |
| 36 // the created CastContentWindow. |
| 37 static std::unique_ptr<CastContentWindow> Create( |
| 38 CastContentWindow::Delegate* delegate); |
| 39 |
| 40 virtual ~CastContentWindow() {} |
| 33 | 41 |
| 34 // Sets the window's background to be transparent (call before | 42 // Sets the window's background to be transparent (call before |
| 35 // CreateWindowTree). | 43 // CreateWindowTree). |
| 36 void SetTransparent() { transparent_ = true; } | 44 virtual void SetTransparent() = 0; |
| 37 | 45 |
| 38 // Create a full-screen window for |web_contents|. | 46 // Creates a full-screen window for |web_contents| and display it. |
| 39 void CreateWindowTree(content::WebContents* web_contents); | 47 // |web_contents| should outlive this CastContentWindow. |
| 48 virtual void ShowWebContents(content::WebContents* web_contents) = 0; |
| 40 | 49 |
| 41 std::unique_ptr<content::WebContents> CreateWebContents( | 50 // Creates a WebContents. |
| 42 content::BrowserContext* browser_context); | 51 // TODO(derekjchow): remove this function from this class, since it doesn't |
| 43 | 52 // have anything to do with displaying web_contents. |
| 44 // content::WebContentsObserver implementation: | 53 virtual std::unique_ptr<content::WebContents> CreateWebContents( |
| 45 void DidFirstVisuallyNonEmptyPaint() override; | 54 content::BrowserContext* browser_context) = 0; |
| 46 void MediaStartedPlaying(const MediaPlayerInfo& media_info, | |
| 47 const MediaPlayerId& id) override; | |
| 48 void MediaStoppedPlaying(const MediaPlayerInfo& media_info, | |
| 49 const MediaPlayerId& id) override; | |
| 50 void RenderViewCreated(content::RenderViewHost* render_view_host) override; | |
| 51 | |
| 52 // CastVSyncSettings::Observer implementation: | |
| 53 void OnVSyncIntervalChanged(base::TimeDelta interval) override; | |
| 54 | |
| 55 private: | |
| 56 #if defined(USE_AURA) | |
| 57 std::unique_ptr<aura::WindowTreeHost> window_tree_host_; | |
| 58 #endif | |
| 59 bool transparent_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(CastContentWindow); | |
| 62 }; | 55 }; |
| 63 | 56 |
| 64 } // namespace shell | 57 } // namespace shell |
| 65 } // namespace chromecast | 58 } // namespace chromecast |
| 66 | 59 |
| 67 #endif // CHROMECAST_BROWSER_CAST_CONTENT_WINDOW_H_ | 60 #endif // CHROMECAST_BROWSER_CAST_CONTENT_WINDOW_H_ |
| OLD | NEW |