Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / chrome / browser / media / android / remote / remote_media_player_manager.h
blob1cbe8fd9e7b9ffeb396c2ad1f0ed6788f97a2842
1 // Copyright 2013 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_BROWSER_MEDIA_ANDROID_REMOTE_REMOTE_MEDIA_PLAYER_MANAGER_H_
6 #define CHROME_BROWSER_MEDIA_ANDROID_REMOTE_REMOTE_MEDIA_PLAYER_MANAGER_H_
8 #include <vector>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "chrome/browser/media/android/remote/remote_media_player_bridge.h"
13 #include "content/browser/media/android/browser_media_player_manager.h"
14 #include "media/base/android/media_player_android.h"
16 struct MediaPlayerHostMsg_Initialize_Params;
18 namespace remote_media {
20 // media::MediaPlayerManager implementation that allows the user to play media
21 // remotely.
22 class RemoteMediaPlayerManager : public content::BrowserMediaPlayerManager {
23 public:
24 explicit RemoteMediaPlayerManager(
25 content::RenderFrameHost* render_frame_host);
26 ~RemoteMediaPlayerManager() override;
28 void OnPlaying(int player_id);
29 void OnPaused(int player_id);
31 // Callback to trigger when a remote device has been selected.
32 void OnRemoteDeviceSelected(int player_id);
34 // Callback to trigger when a remote device has been unselected.
35 void OnRemoteDeviceUnselected(int player_id);
37 // Callback to trigger when the video on a remote device finishes playing.
38 void OnRemotePlaybackFinished(int player_id);
40 // Callback to trigger when the availability of remote routes changes.
41 void OnRouteAvailabilityChanged(int tab_id, bool routes_available);
43 void OnMediaMetadataChanged(int player_id,
44 base::TimeDelta duration,
45 int width,
46 int height,
47 bool success) override;
49 protected:
50 void OnSetPoster(int player_id, const GURL& url) override;
52 private:
53 // Returns a MediaPlayerAndroid implementation for playing the media remotely.
54 RemoteMediaPlayerBridge* CreateRemoteMediaPlayer(
55 media::MediaPlayerAndroid* local_player);
57 // Replaces the given local player with the remote one. Does nothing if the
58 // player is remote already.
59 void ReplaceLocalPlayerWithRemote(media::MediaPlayerAndroid* player);
61 // Replaces the remote player with the local player this class is holding.
62 // Does nothing if there is no remote player.
63 void ReplaceRemotePlayerWithLocal();
65 // Checks if the URL managed by the player should be played remotely.
66 // Returns true if the manager should do nothing, false if it needs to
67 // proceed.
68 bool MaybeStartPlayingRemotely(int player_id);
70 // content::BrowserMediaPlayerManager overrides.
71 void OnStart(int player_id) override;
72 void OnInitialize(
73 const MediaPlayerHostMsg_Initialize_Params& media_player_params) override;
74 void OnDestroyPlayer(int player_id) override;
75 void OnReleaseResources(int player_id) override;
76 void OnRequestRemotePlayback(int player_id) override;
77 void OnRequestRemotePlaybackControl(int player_id) override;
79 void ReleaseFullscreenPlayer(media::MediaPlayerAndroid* player) override;
81 // Callback for when the download of poster image is done.
82 void DidDownloadPoster(
83 int player_id,
84 int id,
85 int http_status_code,
86 const GURL& image_url,
87 const std::vector<SkBitmap>& bitmaps,
88 const std::vector<gfx::Size>& original_bitmap_sizes);
90 // Return the ID of the tab that's associated with this controller. Returns
91 // -1 in case something goes wrong.
92 int GetTabId();
94 // Get the player id of current remote player, if any, or -1 if none.
95 int RemotePlayerId();
97 // Get the remote player for a given player id, whether or not it is currently
98 // playing remotely.
99 RemoteMediaPlayerBridge* GetRemotePlayer(int player_id);
101 // The local player that we have replaced with a remote player. This is NULL
102 // if we do not have a remote player currently running.
103 scoped_ptr<media::MediaPlayerAndroid> replaced_local_player_;
105 ScopedVector<RemoteMediaPlayerBridge> remote_players_;
107 base::WeakPtrFactory<RemoteMediaPlayerManager> weak_ptr_factory_;
109 DISALLOW_COPY_AND_ASSIGN(RemoteMediaPlayerManager);
112 } // namespace remote_media
114 #endif // CHROME_BROWSER_MEDIA_ANDROID_REMOTE_REMOTE_MEDIA_PLAYER_MANAGER_H_