1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_PRERENDER_PRERENDER_WEBMEDIAPLAYER_H_
6 #define CHROME_RENDERER_PRERENDER_PRERENDER_WEBMEDIAPLAYER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/public/renderer/render_view_observer.h"
11 #include "webkit/media/webmediaplayer_impl.h"
15 // Substitute for WebMediaPlayerImpl to be used in prerendered pages. Defers
16 // the loading of the media till the prerendered page is swapped in.
17 class PrerenderWebMediaPlayer
18 : public content::RenderViewObserver
,
19 public webkit_media::WebMediaPlayerImpl
{
21 PrerenderWebMediaPlayer(
22 content::RenderView
* render_view
,
23 WebKit::WebFrame
* frame
,
24 WebKit::WebMediaPlayerClient
* client
,
25 base::WeakPtr
<webkit_media::WebMediaPlayerDelegate
> delegate
,
26 const webkit_media::WebMediaPlayerParams
& params
);
27 virtual ~PrerenderWebMediaPlayer();
29 // WebMediaPlayerImpl methods:
30 virtual void load(const WebKit::WebURL
& url
, CORSMode cors_mode
) OVERRIDE
;
31 virtual void cancelLoad() OVERRIDE
;
34 // RenderViewObserver method:
35 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
37 void OnSetIsPrerendering(bool is_prerendering
);
39 bool is_prerendering_
;
41 scoped_ptr
<WebKit::WebURL
> url_to_load_
;
44 DISALLOW_COPY_AND_ASSIGN(PrerenderWebMediaPlayer
);
47 } // namespace prerender
49 #endif // CHROME_RENDERER_PRERENDER_PRERENDER_WEBMEDIAPLAYER_H_