Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / media / media_web_contents_observer.h
blob382dcdf772f63b00749b65918d4d87bcd3098028
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_
6 #define CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_
8 #include "base/compiler_specific.h"
9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "content/common/content_export.h"
11 #include "content/public/browser/web_contents_observer.h"
13 namespace content {
15 class BrowserCdmManager;
16 class BrowserMediaPlayerManager;
18 // This class manages all RenderFrame based media related managers at the
19 // browser side. It receives IPC messages from media RenderFrameObservers and
20 // forwards them to the corresponding managers. The managers are responsible
21 // for sending IPCs back to the RenderFrameObservers at the render side.
22 class CONTENT_EXPORT MediaWebContentsObserver : public WebContentsObserver {
23 public:
24 explicit MediaWebContentsObserver(WebContents* web_contents);
25 ~MediaWebContentsObserver() override;
27 // WebContentsObserver implementations.
28 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
30 #if defined(OS_ANDROID)
31 bool OnMessageReceived(const IPC::Message& message,
32 RenderFrameHost* render_frame_host) override;
34 // Helper functions to handle media player IPC messages. Returns whether the
35 // |message| is handled in the function.
36 bool OnMediaPlayerMessageReceived(const IPC::Message& message,
37 RenderFrameHost* render_frame_host);
38 bool OnMediaPlayerSetCdmMessageReceived(const IPC::Message& message,
39 RenderFrameHost* render_frame_host);
41 // Gets the media player manager associated with |render_frame_host|. Creates
42 // a new one if it doesn't exist. The caller doesn't own the returned pointer.
43 BrowserMediaPlayerManager* GetMediaPlayerManager(
44 RenderFrameHost* render_frame_host);
46 void OnSetCdm(RenderFrameHost* render_frame_host, int player_id, int cdm_id);
48 #if defined(VIDEO_HOLE)
49 void OnFrameInfoUpdated();
50 #endif // defined(VIDEO_HOLE)
52 private:
53 // Map from RenderFrameHost* to BrowserMediaPlayerManager.
54 typedef base::ScopedPtrHashMap<uintptr_t,
55 scoped_ptr<BrowserMediaPlayerManager>>
56 MediaPlayerManagerMap;
57 MediaPlayerManagerMap media_player_managers_;
58 #endif // defined(OS_ANDROID)
60 private:
61 DISALLOW_COPY_AND_ASSIGN(MediaWebContentsObserver);
64 } // namespace content
66 #endif // CONTENT_BROWSER_MEDIA_MEDIA_WEB_CONTENTS_OBSERVER_H_