| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 void MediaPlayer::SetPlaybackError(GURL const& url) { | 156 void MediaPlayer::SetPlaybackError(GURL const& url) { |
| 157 for (size_t x = 0; x < current_playlist_.size(); x++) { | 157 for (size_t x = 0; x < current_playlist_.size(); x++) { |
| 158 if (current_playlist_[x].url == url) { | 158 if (current_playlist_[x].url == url) { |
| 159 current_playlist_[x].haderror = true; | 159 current_playlist_[x].haderror = true; |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 NotifyPlaylistChanged(); | 162 NotifyPlaylistChanged(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void MediaPlayer::Observe(NotificationType type, | 165 void MediaPlayer::Observe(int type, |
| 166 const NotificationSource& source, | 166 const NotificationSource& source, |
| 167 const NotificationDetails& details) { | 167 const NotificationDetails& details) { |
| 168 DCHECK(type == NotificationType::BROWSER_CLOSING); | 168 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING); |
| 169 registrar_.Remove(this, | 169 registrar_.Remove(this, |
| 170 NotificationType::BROWSER_CLOSING, | 170 chrome::NOTIFICATION_BROWSER_CLOSING, |
| 171 source); | 171 source); |
| 172 if (Source<Browser>(source).ptr() == mediaplayer_browser_) { | 172 if (Source<Browser>(source).ptr() == mediaplayer_browser_) { |
| 173 mediaplayer_browser_ = NULL; | 173 mediaplayer_browser_ = NULL; |
| 174 } else if (Source<Browser>(source).ptr() == playlist_browser_) { | 174 } else if (Source<Browser>(source).ptr() == playlist_browser_) { |
| 175 playlist_browser_ = NULL; | 175 playlist_browser_ = NULL; |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 void MediaPlayer::NotifyPlaylistChanged() { | 179 void MediaPlayer::NotifyPlaylistChanged() { |
| 180 ExtensionMediaPlayerEventRouter::GetInstance()->NotifyPlaylistChanged(); | 180 ExtensionMediaPlayerEventRouter::GetInstance()->NotifyPlaylistChanged(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 void MediaPlayer::PopupPlaylist(Browser* creator) { | 199 void MediaPlayer::PopupPlaylist(Browser* creator) { |
| 200 Profile* profile = BrowserList::GetLastActive()->profile(); | 200 Profile* profile = BrowserList::GetLastActive()->profile(); |
| 201 playlist_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL, | 201 playlist_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL, |
| 202 kMediaPlayerAppName, | 202 kMediaPlayerAppName, |
| 203 gfx::Rect(), | 203 gfx::Rect(), |
| 204 profile); | 204 profile); |
| 205 registrar_.Add(this, | 205 registrar_.Add(this, |
| 206 NotificationType::BROWSER_CLOSING, | 206 chrome::NOTIFICATION_BROWSER_CLOSING, |
| 207 Source<Browser>(playlist_browser_)); | 207 Source<Browser>(playlist_browser_)); |
| 208 playlist_browser_->AddSelectedTabWithURL(GetMediaplayerPlaylistUrl(), | 208 playlist_browser_->AddSelectedTabWithURL(GetMediaplayerPlaylistUrl(), |
| 209 PageTransition::LINK); | 209 PageTransition::LINK); |
| 210 playlist_browser_->window()->SetBounds(gfx::Rect(kPopupLeft, | 210 playlist_browser_->window()->SetBounds(gfx::Rect(kPopupLeft, |
| 211 kPopupTop, | 211 kPopupTop, |
| 212 kPopupWidth, | 212 kPopupWidth, |
| 213 kPopupHeight)); | 213 kPopupHeight)); |
| 214 playlist_browser_->window()->Show(); | 214 playlist_browser_->window()->Show(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void MediaPlayer::PopupMediaPlayer(Browser* creator) { | 217 void MediaPlayer::PopupMediaPlayer(Browser* creator) { |
| 218 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 218 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 219 BrowserThread::PostTask( | 219 BrowserThread::PostTask( |
| 220 BrowserThread::UI, FROM_HERE, | 220 BrowserThread::UI, FROM_HERE, |
| 221 NewRunnableMethod(this, &MediaPlayer::PopupMediaPlayer, | 221 NewRunnableMethod(this, &MediaPlayer::PopupMediaPlayer, |
| 222 static_cast<Browser*>(NULL))); | 222 static_cast<Browser*>(NULL))); |
| 223 return; | 223 return; |
| 224 } | 224 } |
| 225 Profile* profile = BrowserList::GetLastActive()->profile(); | 225 Profile* profile = BrowserList::GetLastActive()->profile(); |
| 226 mediaplayer_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL, | 226 mediaplayer_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL, |
| 227 kMediaPlayerAppName, | 227 kMediaPlayerAppName, |
| 228 gfx::Rect(), | 228 gfx::Rect(), |
| 229 profile); | 229 profile); |
| 230 registrar_.Add(this, | 230 registrar_.Add(this, |
| 231 NotificationType::BROWSER_CLOSING, | 231 chrome::NOTIFICATION_BROWSER_CLOSING, |
| 232 Source<Browser>(mediaplayer_browser_)); | 232 Source<Browser>(mediaplayer_browser_)); |
| 233 | 233 |
| 234 #if defined(OS_CHROMEOS) | 234 #if defined(OS_CHROMEOS) |
| 235 // Since we are on chromeos, popups should be a PanelBrowserView, | 235 // Since we are on chromeos, popups should be a PanelBrowserView, |
| 236 // so we can just cast it. | 236 // so we can just cast it. |
| 237 if (creator) { | 237 if (creator) { |
| 238 chromeos::PanelBrowserView* creatorview = | 238 chromeos::PanelBrowserView* creatorview = |
| 239 static_cast<chromeos::PanelBrowserView*>(creator->window()); | 239 static_cast<chromeos::PanelBrowserView*>(creator->window()); |
| 240 chromeos::PanelBrowserView* view = | 240 chromeos::PanelBrowserView* view = |
| 241 static_cast<chromeos::PanelBrowserView*>( | 241 static_cast<chromeos::PanelBrowserView*>( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 302 |
| 303 MediaPlayer::MediaPlayer() | 303 MediaPlayer::MediaPlayer() |
| 304 : current_position_(0), | 304 : current_position_(0), |
| 305 pending_playback_request_(false), | 305 pending_playback_request_(false), |
| 306 playlist_browser_(NULL), | 306 playlist_browser_(NULL), |
| 307 mediaplayer_browser_(NULL) { | 307 mediaplayer_browser_(NULL) { |
| 308 for (size_t i = 0; i < arraysize(supported_mime_type_list); ++i) { | 308 for (size_t i = 0; i < arraysize(supported_mime_type_list); ++i) { |
| 309 supported_mime_types_.insert(supported_mime_type_list[i]); | 309 supported_mime_types_.insert(supported_mime_type_list[i]); |
| 310 } | 310 } |
| 311 }; | 311 }; |
| OLD | NEW |