1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Copyright (c) 2013 Intel Corporation. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #ifndef XWALK_TIZEN_BROWSER_MEDIA_BROWSER_MEDIAPLAYER_MANAGER_H_
7 #define XWALK_TIZEN_BROWSER_MEDIA_BROWSER_MEDIAPLAYER_MANAGER_H_
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "content/public/browser/web_contents_observer.h"
13 #include "xwalk/tizen/browser/media/murphy_resource_manager.h"
14 #include "xwalk/tizen/browser/media/murphy_resource.h"
18 // This class manages all MurphyResource objects in the browser process. It
19 // receives control operations from the render process, and forwards them to
20 // corresponding MurphyResource object. Callbacks from MurphyResource objects
21 // are converted to IPCs and then sent to the render process.
22 class CONTENT_EXPORT BrowserMediaPlayerManager {
24 virtual ~BrowserMediaPlayerManager();
26 // Returns a new instance.
27 static BrowserMediaPlayerManager* Create(
28 content::RenderFrameHost* render_frame_host,
29 MurphyResourceManager* resource_manager);
31 virtual MurphyResource* GetMurphyResource(
32 MediaPlayerID player_id);
34 void ResourceNotifyCallback(mrp_res_resource_state_t state,
35 MediaPlayerID player_id);
39 // Helper function to send messages to RenderFrameObserver.
40 bool Send(IPC::Message* msg);
43 virtual void OnInitialize(MediaPlayerID player_id,
44 int process_id, const GURL& url);
45 virtual void OnDestroyPlayer(MediaPlayerID player_id);
46 virtual void OnPause(MediaPlayerID player_id);
47 virtual void OnStart(MediaPlayerID player_id);
50 explicit BrowserMediaPlayerManager(
51 content::RenderFrameHost* render_frame_host,
52 MurphyResourceManager* resource_manager);
55 // Adds a murphy resource for the given player to the list.
56 void AddMurphyResource(MurphyResource* resource);
58 // Removes the murphy resource of given |player_id|.
59 void RemoveMurphyResource(MediaPlayerID player_id);
61 content::RenderFrameHost* const render_frame_host_;
63 MurphyResourceManager* resource_manager_;
64 ScopedVector<MurphyResource> murphy_resources_;
66 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager);
71 #endif // XWALK_TIZEN_BROWSER_MEDIA_BROWSER_MEDIAPLAYER_MANAGER_H_