OLD | NEW |
---|---|
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 "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 11 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
12 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" | |
13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
17 #include "chrome/browser/ui/browser_tabstrip.h" | 16 #include "chrome/browser/ui/browser_tabstrip.h" |
18 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
20 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
23 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
24 | 23 |
24 #if defined(FILE_MANAGER_EXTENSION) | |
25 #include "chrome/browser/chromeos/extensions/media_player_api.h" | |
26 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" | |
27 #endif | |
28 | |
25 using content::BrowserThread; | 29 using content::BrowserThread; |
26 | 30 |
27 namespace { | 31 namespace { |
28 | 32 |
29 const char kMediaPlayerAppName[] = "mediaplayer"; | 33 const char kMediaPlayerAppName[] = "mediaplayer"; |
30 const int kPopupRight = 20; | 34 const int kPopupRight = 20; |
31 const int kPopupBottom = 80; | 35 const int kPopupBottom = 80; |
32 const int kPopupWidth = 280; | 36 const int kPopupWidth = 280; |
33 | 37 |
34 // Set the initial height to the minimum possible height. Keep the constants | 38 // Set the initial height to the minimum possible height. Keep the constants |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 EnqueueMediaFileUrl(url); | 107 EnqueueMediaFileUrl(url); |
104 SetPlaylistPosition(0); | 108 SetPlaylistPosition(0); |
105 NotifyPlaylistChanged(); | 109 NotifyPlaylistChanged(); |
106 } | 110 } |
107 | 111 |
108 void MediaPlayer::SetPlaylistPosition(int position) { | 112 void MediaPlayer::SetPlaylistPosition(int position) { |
109 current_position_ = position; | 113 current_position_ = position; |
110 } | 114 } |
111 | 115 |
112 void MediaPlayer::NotifyPlaylistChanged() { | 116 void MediaPlayer::NotifyPlaylistChanged() { |
113 ExtensionMediaPlayerEventRouter::GetInstance()->NotifyPlaylistChanged(); | 117 #if defined(FILE_MANAGER_EXTENSION) |
118 Browser* browser = GetBrowser(); | |
119 if (browser) { | |
120 extensions::MediaPlayerAPI::Get(browser->profile())-> | |
121 media_player_event_router()->NotifyPlaylistChanged(); | |
122 } else { | |
123 // How do we handle this case?? | |
Yoyo Zhou
2012/12/20 22:45:20
Probably okay to let this notification drop on the
Joe Thomas
2012/12/20 23:20:28
Done.
| |
124 } | |
125 #endif | |
114 } | 126 } |
115 | 127 |
116 void MediaPlayer::PopupMediaPlayer() { | 128 void MediaPlayer::PopupMediaPlayer() { |
117 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 129 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
118 BrowserThread::PostTask( | 130 BrowserThread::PostTask( |
119 BrowserThread::UI, FROM_HERE, | 131 BrowserThread::UI, FROM_HERE, |
120 base::Bind(&MediaPlayer::PopupMediaPlayer, | 132 base::Bind(&MediaPlayer::PopupMediaPlayer, |
121 base::Unretained(this) /*this class is a singleton*/)); | 133 base::Unretained(this) /*this class is a singleton*/)); |
122 return; | 134 return; |
123 } | 135 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 if (base_url == GetMediaPlayerUrl()) | 170 if (base_url == GetMediaPlayerUrl()) |
159 return browser; | 171 return browser; |
160 } | 172 } |
161 } | 173 } |
162 return NULL; | 174 return NULL; |
163 } | 175 } |
164 | 176 |
165 MediaPlayer::MediaPlayer() | 177 MediaPlayer::MediaPlayer() |
166 : current_position_(0) { | 178 : current_position_(0) { |
167 }; | 179 }; |
OLD | NEW |