Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / xwalk / tizen / browser / browser_mediaplayer_manager.h
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.
5
6 #ifndef XWALK_TIZEN_BROWSER_BROWSER_MEDIAPLAYER_MANAGER_H_
7 #define XWALK_TIZEN_BROWSER_BROWSER_MEDIAPLAYER_MANAGER_H_
8
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "content/public/browser/web_contents_observer.h"
12 #include "url/gurl.h"
13 #include "xwalk/tizen/browser/audio_session_manager.h"
14
15 namespace tizen {
16
17 // This class manages all AudioSessionManager objects in the browser
18 // process. It receives control operations from the render process, and
19 // forwards them to corresponding AudioSessionManager object. Callbacks
20 // from AudioSessionManager objects are converted to IPCs and then sent
21 // to the render process.
22 class CONTENT_EXPORT BrowserMediaPlayerManager
23     : public content::WebContentsObserver {
24  public:
25   virtual ~BrowserMediaPlayerManager();
26
27   // Returns a new instance.
28   static BrowserMediaPlayerManager* Create(
29       content::RenderViewHost* render_view_host);
30
31   // WebContentsObserver overrides.
32   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
33   virtual AudioSessionManager* GetAudioSessionManager(
34       MediaPlayerID player_id) OVERRIDE;
35
36   ASM_cb_result_t AudioSessionEventPause(
37       ASM_event_sources_t eventSource, MediaPlayerID player_id);
38   ASM_cb_result_t AudioSessionEventPlay(
39       ASM_event_sources_t eventSource, MediaPlayerID player_id);
40
41  protected:
42   explicit BrowserMediaPlayerManager(content::RenderViewHost* render_view_host);
43
44  private:
45   virtual void OnInitialize(MediaPlayerID player_id,
46       int process_id, const GURL& url);
47   virtual void OnDestroyAllMediaPlayers();
48   virtual void OnDestroyPlayer(MediaPlayerID player_id);
49   virtual void OnPause(MediaPlayerID player_id);
50   virtual void OnStart(MediaPlayerID player_id);
51
52   // Adds a audio session manager for the given player to the list.
53   void AddAudioSessionManager(AudioSessionManager* session_manager);
54
55   // Removes the audio session manager of given |player_id|.
56   void RemoveAudioSessionManager(MediaPlayerID player_id);
57
58   ScopedVector<AudioSessionManager> audio_session_managers_;
59
60   DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager);
61 };
62
63 }  // namespace tizen
64
65 #endif  // XWALK_TIZEN_BROWSER_BROWSER_MEDIAPLAYER_MANAGER_H_