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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
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"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/string_piece.h" 13 #include "base/string_piece.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/browser/bookmarks/bookmark_model.h" 18 #include "chrome/browser/bookmarks/bookmark_model.h"
19 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" 19 #include "chrome/browser/chromeos/extensions/media_player_event_router.h"
20 #include "chrome/browser/download/download_manager.h" 20 #include "chrome/browser/download/download_manager.h"
21 #include "chrome/browser/download/download_util.h" 21 #include "chrome/browser/download/download_util.h"
22 #include "chrome/browser/extensions/file_manager_util.h" 22 #include "chrome/browser/extensions/file_manager_util.h"
23 #include "chrome/browser/history/history_types.h" 23 #include "chrome/browser/history/history_types.h"
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/tabs/tab_strip_model.h" 25 #include "chrome/browser/tabs/tab_strip_model.h"
26 #include "chrome/browser/ui/browser.h" 26 #include "chrome/browser/ui/browser.h"
27 #include "chrome/browser/ui/browser_list.h" 27 #include "chrome/browser/ui/browser_list.h"
28 #include "chrome/browser/ui/browser_window.h" 28 #include "chrome/browser/ui/browser_window.h"
29 #include "chrome/browser/ui/webui/favicon_source.h" 29 #include "chrome/browser/ui/webui/favicon_source.h"
30 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
31 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/jstemplate_builder.h" 33 #include "chrome/common/jstemplate_builder.h"
33 #include "chrome/common/time_format.h" 34 #include "chrome/common/time_format.h"
34 #include "chrome/common/url_constants.h" 35 #include "chrome/common/url_constants.h"
35 #include "content/browser/browser_thread.h" 36 #include "content/browser/browser_thread.h"
36 #include "content/browser/tab_contents/tab_contents.h" 37 #include "content/browser/tab_contents/tab_contents.h"
37 #include "content/browser/user_metrics.h" 38 #include "content/browser/user_metrics.h"
38 #include "content/common/url_fetcher.h" 39 #include "content/common/url_fetcher.h"
39 #include "grit/browser_resources.h" 40 #include "grit/browser_resources.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 156
156 void MediaPlayer::SetPlaybackError(GURL const& url) { 157 void MediaPlayer::SetPlaybackError(GURL const& url) {
157 for (size_t x = 0; x < current_playlist_.size(); x++) { 158 for (size_t x = 0; x < current_playlist_.size(); x++) {
158 if (current_playlist_[x].url == url) { 159 if (current_playlist_[x].url == url) {
159 current_playlist_[x].haderror = true; 160 current_playlist_[x].haderror = true;
160 } 161 }
161 } 162 }
162 NotifyPlaylistChanged(); 163 NotifyPlaylistChanged();
163 } 164 }
164 165
165 void MediaPlayer::Observe(NotificationType type, 166 void MediaPlayer::Observe(int type,
166 const NotificationSource& source, 167 const NotificationSource& source,
167 const NotificationDetails& details) { 168 const NotificationDetails& details) {
168 DCHECK(type == NotificationType::BROWSER_CLOSING); 169 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING);
169 registrar_.Remove(this, 170 registrar_.Remove(this,
170 NotificationType::BROWSER_CLOSING, 171 chrome::NOTIFICATION_BROWSER_CLOSING,
171 source); 172 source);
172 if (Source<Browser>(source).ptr() == mediaplayer_browser_) { 173 if (Source<Browser>(source).ptr() == mediaplayer_browser_) {
173 mediaplayer_browser_ = NULL; 174 mediaplayer_browser_ = NULL;
174 } else if (Source<Browser>(source).ptr() == playlist_browser_) { 175 } else if (Source<Browser>(source).ptr() == playlist_browser_) {
175 playlist_browser_ = NULL; 176 playlist_browser_ = NULL;
176 } 177 }
177 } 178 }
178 179
179 void MediaPlayer::NotifyPlaylistChanged() { 180 void MediaPlayer::NotifyPlaylistChanged() {
180 ExtensionMediaPlayerEventRouter::GetInstance()->NotifyPlaylistChanged(); 181 ExtensionMediaPlayerEventRouter::GetInstance()->NotifyPlaylistChanged();
(...skipping 15 matching lines...) Expand all
196 } 197 }
197 } 198 }
198 199
199 void MediaPlayer::PopupPlaylist(Browser* creator) { 200 void MediaPlayer::PopupPlaylist(Browser* creator) {
200 Profile* profile = BrowserList::GetLastActive()->profile(); 201 Profile* profile = BrowserList::GetLastActive()->profile();
201 playlist_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL, 202 playlist_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL,
202 kMediaPlayerAppName, 203 kMediaPlayerAppName,
203 gfx::Rect(), 204 gfx::Rect(),
204 profile); 205 profile);
205 registrar_.Add(this, 206 registrar_.Add(this,
206 NotificationType::BROWSER_CLOSING, 207 chrome::NOTIFICATION_BROWSER_CLOSING,
207 Source<Browser>(playlist_browser_)); 208 Source<Browser>(playlist_browser_));
208 playlist_browser_->AddSelectedTabWithURL(GetMediaplayerPlaylistUrl(), 209 playlist_browser_->AddSelectedTabWithURL(GetMediaplayerPlaylistUrl(),
209 PageTransition::LINK); 210 PageTransition::LINK);
210 playlist_browser_->window()->SetBounds(gfx::Rect(kPopupLeft, 211 playlist_browser_->window()->SetBounds(gfx::Rect(kPopupLeft,
211 kPopupTop, 212 kPopupTop,
212 kPopupWidth, 213 kPopupWidth,
213 kPopupHeight)); 214 kPopupHeight));
214 playlist_browser_->window()->Show(); 215 playlist_browser_->window()->Show();
215 } 216 }
216 217
217 void MediaPlayer::PopupMediaPlayer(Browser* creator) { 218 void MediaPlayer::PopupMediaPlayer(Browser* creator) {
218 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 219 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
219 BrowserThread::PostTask( 220 BrowserThread::PostTask(
220 BrowserThread::UI, FROM_HERE, 221 BrowserThread::UI, FROM_HERE,
221 NewRunnableMethod(this, &MediaPlayer::PopupMediaPlayer, 222 NewRunnableMethod(this, &MediaPlayer::PopupMediaPlayer,
222 static_cast<Browser*>(NULL))); 223 static_cast<Browser*>(NULL)));
223 return; 224 return;
224 } 225 }
225 Profile* profile = BrowserList::GetLastActive()->profile(); 226 Profile* profile = BrowserList::GetLastActive()->profile();
226 mediaplayer_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL, 227 mediaplayer_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL,
227 kMediaPlayerAppName, 228 kMediaPlayerAppName,
228 gfx::Rect(), 229 gfx::Rect(),
229 profile); 230 profile);
230 registrar_.Add(this, 231 registrar_.Add(this,
231 NotificationType::BROWSER_CLOSING, 232 chrome::NOTIFICATION_BROWSER_CLOSING,
232 Source<Browser>(mediaplayer_browser_)); 233 Source<Browser>(mediaplayer_browser_));
233 234
234 #if defined(OS_CHROMEOS) 235 #if defined(OS_CHROMEOS)
235 // Since we are on chromeos, popups should be a PanelBrowserView, 236 // Since we are on chromeos, popups should be a PanelBrowserView,
236 // so we can just cast it. 237 // so we can just cast it.
237 if (creator) { 238 if (creator) {
238 chromeos::PanelBrowserView* creatorview = 239 chromeos::PanelBrowserView* creatorview =
239 static_cast<chromeos::PanelBrowserView*>(creator->window()); 240 static_cast<chromeos::PanelBrowserView*>(creator->window());
240 chromeos::PanelBrowserView* view = 241 chromeos::PanelBrowserView* view =
241 static_cast<chromeos::PanelBrowserView*>( 242 static_cast<chromeos::PanelBrowserView*>(
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 303
303 MediaPlayer::MediaPlayer() 304 MediaPlayer::MediaPlayer()
304 : current_position_(0), 305 : current_position_(0),
305 pending_playback_request_(false), 306 pending_playback_request_(false),
306 playlist_browser_(NULL), 307 playlist_browser_(NULL),
307 mediaplayer_browser_(NULL) { 308 mediaplayer_browser_(NULL) {
308 for (size_t i = 0; i < arraysize(supported_mime_type_list); ++i) { 309 for (size_t i = 0; i < arraysize(supported_mime_type_list); ++i) {
309 supported_mime_types_.insert(supported_mime_type_list[i]); 310 supported_mime_types_.insert(supported_mime_type_list[i]);
310 } 311 }
311 }; 312 };
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/media/media_player.h ('k') | chrome/browser/chromeos/network_state_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698