Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(824)

Side by Side Diff: chrome/browser/ui/webui/mediaplayer_ui.h

Issue 7067020: Moving mediaplayer to the chrome filebrowser. Observable behaviour should not change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolved conflicts. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_MEDIAPLAYER_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_MEDIAPLAYER_UI_H_
7 #pragma once
8
9 #include <set>
10 #include <vector>
11
12 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
13 #include "content/browser/webui/web_ui.h"
14 #include "content/common/notification_observer.h"
15 #include "content/common/notification_registrar.h"
16 #include "content/common/notification_source.h"
17 #include "content/common/notification_type.h"
18 #include "net/base/directory_lister.h"
19 #include "net/url_request/url_request.h"
20
21 template <typename T> struct DefaultSingletonTraits;
22
23 class Browser;
24 class GURL;
25 class MediaplayerHandler;
26 class Profile;
27
28 class MediaPlayer : public NotificationObserver,
29 public net::URLRequest::Interceptor {
30 public:
31 virtual ~MediaPlayer();
32
33 // Enqueues this file into the current playlist. If the mediaplayer is
34 // not currently visible, show it, and play the given url.
35 void EnqueueMediaFile(Profile* profile, const FilePath& file_path,
36 Browser* creator);
37
38 // Enqueues this fileschema url into the current playlist. If the mediaplayer
39 // is not currently visible, show it, and play the given url.
40 void EnqueueMediaFileUrl(const GURL& url, Browser* creator);
41
42 // Clears out the current playlist, and start playback of the given
43 // |file_path|. If there is no mediaplayer currently, show it, and play the
44 // given |file_path|.
45 void ForcePlayMediaFile(Profile* profile, const FilePath& file_path,
46 Browser* creator);
47
48 // Clears out the current playlist, and start playback of the given url.
49 // If there is no mediaplayer currently, show it, and play the given url.
50 void ForcePlayMediaURL(const GURL& url, Browser* creator);
51
52 // Toggle the visibility of the playlist window.
53 void TogglePlaylistWindowVisible();
54
55 // Force the playlist window to be shown.
56 void ShowPlaylistWindow();
57
58 // Toggle the mediaplayer between fullscreen and windowed.
59 void ToggleFullscreen();
60
61 // Force the playlist window to be closed.
62 void ClosePlaylistWindow();
63
64 // Sets the currently playing element to the given offset.
65 void SetPlaylistOffset(int offset);
66
67 // Set a new playback handler to give events to, along with the
68 // tab contents of the page which holds the mediaplayer. it is expected
69 // That only one of these will exist at any given time.
70 void SetNewHandler(MediaplayerHandler* handler,
71 TabContents* contents);
72
73 // Removes the handler.
74 void RemoveHandler(MediaplayerHandler* handler);
75
76 // Registers a new playlist handler which receives events from the
77 // mediaplayer, along with the tab contents which has the playlist in it.
78 void RegisterNewPlaylistHandler(MediaplayerHandler* handler,
79 TabContents* contents);
80
81 // Removes the playlist handler.
82 void RemovePlaylistHandler(MediaplayerHandler* handler);
83
84 // Notfiys the mediaplayer that the playlist changed. This could be
85 // called from the mediaplayer itself for example.
86 void NotifyPlaylistChanged();
87
88 // Always returns NULL because we don't want to attempt a redirect
89 // before seeing the detected mime type of the request.
90 // Implementation of net::URLRequest::Interceptor.
91 virtual net::URLRequestJob* MaybeIntercept(net::URLRequest* request);
92
93 // Determines if the requested document can be viewed by the
94 // MediaPlayer. If it can, returns a net::URLRequestJob that
95 // redirects the browser to the view URL.
96 // Implementation of net::URLRequest::Interceptor.
97 virtual net::URLRequestJob* MaybeInterceptResponse(net::URLRequest* request);
98
99 // Used to detect when the mediaplayer is closed.
100 virtual void Observe(NotificationType type,
101 const NotificationSource& source,
102 const NotificationDetails& details);
103
104 // Getter for the singleton.
105 static MediaPlayer* GetInstance();
106
107 private:
108 friend struct DefaultSingletonTraits<MediaPlayer>;
109
110 MediaPlayer();
111
112 // Popup the mediaplayer, this shows the browser, and sets up its
113 // locations correctly.
114 void PopupMediaPlayer(Browser* creator);
115
116 // Popup the playlist. Shows the browser, sets it up to point at
117 // chrome://mediaplayer#playlist
118 void PopupPlaylist(Browser* creator);
119
120 // Registers the listeners for the close events on the browser windows.
121 void RegisterListeners();
122
123 // Set when the register handler is called. When the media player is
124 // closed, this pointer is set back to NULL.
125 MediaplayerHandler* handler_;
126
127 // Set when the register playlist handler is called. When the playlist
128 // is closed, this pointer is set back to NULL.
129 MediaplayerHandler* playlist_;
130
131 // Browser containing the playlist. Used to force closes. This is created
132 // By the PopupPlaylist call, and is NULLed out when the window is closed.
133 Browser* playlist_browser_;
134
135 // Browser containing the Mediaplayer. Used to force closes. This is
136 // created by the PopupMediaplayer call, and is NULLed out when the window
137 // is closed.
138 Browser* mediaplayer_browser_;
139
140 // List of URLs that were enqueued during the time that the mediaplayer
141 // had not poped up yet. This is claered out after the mediaplayer pops up.
142 std::vector<GURL> unhandled_urls_;
143
144 // Used to register for events on the windows, like to listen for closes.
145 NotificationRegistrar registrar_;
146
147 // Tab contents of the mediaplayer. Used to listen for events
148 // which would cause the mediaplayer to be closed. These are cleared out
149 // when the mediaplayer is closed.
150 TabContents* mediaplayer_tab_;
151
152 // Tab contents of the playlist tab. used to listen for events which would
153 // cause the mediaplayer to be closed. These are cleared out when the
154 // playlist is closed.
155 TabContents* playlist_tab_;
156
157 // List of mimetypes that the mediaplayer should listen to. Used for
158 // interceptions of url GETs.
159 std::set<std::string> supported_mime_types_;
160 DISALLOW_COPY_AND_ASSIGN(MediaPlayer);
161 };
162
163 class MediaplayerUI : public WebUI {
164 public:
165 explicit MediaplayerUI(TabContents* contents);
166
167 private:
168 DISALLOW_COPY_AND_ASSIGN(MediaplayerUI);
169 };
170
171 #endif // CHROME_BROWSER_UI_WEBUI_MEDIAPLAYER_UI_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/mediaplayer_browsertest.cc ('k') | chrome/browser/ui/webui/mediaplayer_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698