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

Side by Side Diff: chrome/browser/chromeos/media/media_player.cc

Issue 9353010: Add FullscreenController::ToggleFullscreenModeWithExtension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Show "An extension triggered full screen." when the extension's name is not available. Created 8 years, 10 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
« no previous file with comments | « chrome/browser/chromeos/login/screen_locker_browsertest.cc ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/media/media_player.h" 5 #include "chrome/browser/chromeos/media/media_player.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 // static 80 // static
81 MediaPlayer* MediaPlayer::GetInstance() { 81 MediaPlayer* MediaPlayer::GetInstance() {
82 return Singleton<MediaPlayer>::get(); 82 return Singleton<MediaPlayer>::get();
83 } 83 }
84 84
85 void MediaPlayer::EnqueueMediaFile(Profile* profile, 85 void MediaPlayer::EnqueueMediaFile(Profile* profile,
86 const FilePath& file_path) { 86 const FilePath& file_path) {
87 GURL url; 87 GURL url;
88 if (!file_manager_util::ConvertFileToFileSystemUrl(profile, file_path, 88 file_manager_util::ConvertFileToFileSystemUrl(profile, file_path,
89 GetOriginUrl(), &url)) { 89 GetOriginUrl(), &url);
90 }
91 EnqueueMediaFileUrl(url); 90 EnqueueMediaFileUrl(url);
92 } 91 }
93 92
94 void MediaPlayer::EnqueueMediaFileUrl(const GURL& url) { 93 void MediaPlayer::EnqueueMediaFileUrl(const GURL& url) {
95 current_playlist_.push_back(MediaUrl(url)); 94 current_playlist_.push_back(MediaUrl(url));
96 NotifyPlaylistChanged(); 95 NotifyPlaylistChanged();
97 } 96 }
98 97
99 void MediaPlayer::ForcePlayMediaFile(Profile* profile, 98 void MediaPlayer::ForcePlayMediaFile(Profile* profile,
100 const FilePath& file_path) { 99 const FilePath& file_path) {
101 GURL url; 100 GURL url;
102 if (!file_manager_util::ConvertFileToFileSystemUrl(profile, file_path, 101 if (!file_manager_util::ConvertFileToFileSystemUrl(profile, file_path,
103 GetOriginUrl(), &url)) { 102 GetOriginUrl(), &url))
104 return; 103 return;
105 }
106 ForcePlayMediaURL(url); 104 ForcePlayMediaURL(url);
107 } 105 }
108 106
109 void MediaPlayer::ForcePlayMediaURL(const GURL& url) { 107 void MediaPlayer::ForcePlayMediaURL(const GURL& url) {
110 current_playlist_.clear(); 108 current_playlist_.clear();
111 current_playlist_.push_back(MediaUrl(url)); 109 current_playlist_.push_back(MediaUrl(url));
112 current_position_ = current_playlist_.size() - 1; 110 current_position_ = current_playlist_.size() - 1;
113 pending_playback_request_ = true; 111 pending_playback_request_ = true;
114 NotifyPlaylistChanged(); 112 NotifyPlaylistChanged();
115 } 113 }
116 114
117 void MediaPlayer::TogglePlaylistWindowVisible() { 115 void MediaPlayer::TogglePlaylistWindowVisible() {
118 if (playlist_browser_) { 116 if (playlist_browser_)
119 ClosePlaylistWindow(); 117 ClosePlaylistWindow();
120 } else { 118 else
121 PopupPlaylist(NULL); 119 PopupPlaylist(NULL);
122 }
123 } 120 }
124 121
125 void MediaPlayer::ClosePlaylistWindow() { 122 void MediaPlayer::ClosePlaylistWindow() {
126 if (playlist_browser_ != NULL) { 123 if (playlist_browser_ != NULL)
127 playlist_browser_->window()->Close(); 124 playlist_browser_->window()->Close();
128 }
129 } 125 }
130 126
131 void MediaPlayer::SetPlaylistPosition(int position) { 127 void MediaPlayer::SetPlaylistPosition(int position) {
132 const int playlist_size = current_playlist_.size(); 128 const int playlist_size = current_playlist_.size();
133 if (current_position_ < 0 || current_position_ > playlist_size) 129 if (current_position_ < 0 || current_position_ > playlist_size)
134 position = current_playlist_.size(); 130 position = current_playlist_.size();
135 if (current_position_ != position) { 131 if (current_position_ != position) {
136 current_position_ = position; 132 current_position_ = position;
137 NotifyPlaylistChanged(); 133 NotifyPlaylistChanged();
138 } 134 }
139 } 135 }
140 136
141 void MediaPlayer::SetPlaybackError(GURL const& url) { 137 void MediaPlayer::SetPlaybackError(GURL const& url) {
142 for (size_t x = 0; x < current_playlist_.size(); x++) { 138 for (size_t x = 0; x < current_playlist_.size(); x++) {
143 if (current_playlist_[x].url == url) { 139 if (current_playlist_[x].url == url)
144 current_playlist_[x].haderror = true; 140 current_playlist_[x].haderror = true;
145 }
146 } 141 }
147 NotifyPlaylistChanged(); 142 NotifyPlaylistChanged();
148 } 143 }
149 144
150 void MediaPlayer::Observe(int type, 145 void MediaPlayer::Observe(int type,
151 const content::NotificationSource& source, 146 const content::NotificationSource& source,
152 const content::NotificationDetails& details) { 147 const content::NotificationDetails& details) {
153 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSED); 148 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSED);
154 registrar_.Remove(this, 149 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSED, source);
155 chrome::NOTIFICATION_BROWSER_CLOSED, 150
156 source); 151 if (content::Source<Browser>(source).ptr() == mediaplayer_browser_)
157 if (content::Source<Browser>(source).ptr() == mediaplayer_browser_) {
158 mediaplayer_browser_ = NULL; 152 mediaplayer_browser_ = NULL;
159 } else if (content::Source<Browser>(source).ptr() == playlist_browser_) { 153 else if (content::Source<Browser>(source).ptr() == playlist_browser_)
160 playlist_browser_ = NULL; 154 playlist_browser_ = NULL;
161 }
162 } 155 }
163 156
164 void MediaPlayer::NotifyPlaylistChanged() { 157 void MediaPlayer::NotifyPlaylistChanged() {
165 ExtensionMediaPlayerEventRouter::GetInstance()->NotifyPlaylistChanged(); 158 ExtensionMediaPlayerEventRouter::GetInstance()->NotifyPlaylistChanged();
166 } 159 }
167 160
168 bool MediaPlayer::GetPendingPlayRequestAndReset() { 161 bool MediaPlayer::GetPendingPlayRequestAndReset() {
169 bool result = pending_playback_request_; 162 bool result = pending_playback_request_;
170 pending_playback_request_ = false; 163 pending_playback_request_ = false;
171 return result; 164 return result;
172 } 165 }
173 166
174 void MediaPlayer::SetPlaybackRequest() { 167 void MediaPlayer::SetPlaybackRequest() {
175 pending_playback_request_ = true; 168 pending_playback_request_ = true;
176 } 169 }
177 170
178 void MediaPlayer::ToggleFullscreen() { 171 void MediaPlayer::ToggleFullscreen() {
179 if (mediaplayer_browser_) { 172 if (mediaplayer_browser_)
180 mediaplayer_browser_->ToggleFullscreenMode(false); 173 mediaplayer_browser_->ToggleFullscreenMode();
181 }
182 } 174 }
183 175
184 void MediaPlayer::PopupPlaylist(Browser* creator) { 176 void MediaPlayer::PopupPlaylist(Browser* creator) {
185 if (playlist_browser_) 177 if (playlist_browser_)
186 return; // Already opened. 178 return; // Already opened.
187 179
188 Profile* profile = BrowserList::GetLastActive()->profile(); 180 Profile* profile = BrowserList::GetLastActive()->profile();
189 playlist_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL, 181 playlist_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL,
190 kMediaPlayerAppName, 182 kMediaPlayerAppName,
191 gfx::Rect(), 183 gfx::Rect(),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // Document Viewer. 246 // Document Viewer.
255 static const char* const supported_mime_type_list[] = { 247 static const char* const supported_mime_type_list[] = {
256 "audio/mpeg", 248 "audio/mpeg",
257 "video/mp4", 249 "video/mp4",
258 "audio/mp3" 250 "audio/mp3"
259 }; 251 };
260 252
261 net::URLRequestJob* MediaPlayer::MaybeInterceptResponse( 253 net::URLRequestJob* MediaPlayer::MaybeInterceptResponse(
262 net::URLRequest* request) { 254 net::URLRequest* request) {
263 // Do not intercept this request if it is a download. 255 // Do not intercept this request if it is a download.
264 if (request->load_flags() & net::LOAD_IS_DOWNLOAD) { 256 if (request->load_flags() & net::LOAD_IS_DOWNLOAD)
265 return NULL; 257 return NULL;
266 }
267 258
268 std::string mime_type; 259 std::string mime_type;
269 request->GetMimeType(&mime_type); 260 request->GetMimeType(&mime_type);
270 // If it is in our list of known URLs, enqueue the url then 261 // If it is in our list of known URLs, enqueue the url then
271 // Cancel the request so the mediaplayer can handle it when 262 // Cancel the request so the mediaplayer can handle it when
272 // it hits it in the playlist. 263 // it hits it in the playlist.
273 if (supported_mime_types_.find(mime_type) != supported_mime_types_.end()) { 264 if (supported_mime_types_.find(mime_type) != supported_mime_types_.end()) {
274 if (request->referrer() != chrome::kChromeUIMediaplayerURL && 265 if (request->referrer() != chrome::kChromeUIMediaplayerURL &&
275 !request->referrer().empty()) { 266 !request->referrer().empty()) {
276 PopupMediaPlayer(NULL); 267 PopupMediaPlayer(NULL);
(...skipping 18 matching lines...) Expand all
295 286
296 MediaPlayer::MediaPlayer() 287 MediaPlayer::MediaPlayer()
297 : current_position_(0), 288 : current_position_(0),
298 pending_playback_request_(false), 289 pending_playback_request_(false),
299 playlist_browser_(NULL), 290 playlist_browser_(NULL),
300 mediaplayer_browser_(NULL) { 291 mediaplayer_browser_(NULL) {
301 for (size_t i = 0; i < arraysize(supported_mime_type_list); ++i) { 292 for (size_t i = 0; i < arraysize(supported_mime_type_list); ++i) {
302 supported_mime_types_.insert(supported_mime_type_list[i]); 293 supported_mime_types_.insert(supported_mime_type_list[i]);
303 } 294 }
304 }; 295 };
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screen_locker_browsertest.cc ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698