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

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

Issue 10094012: Made File Manager respect the user-selected launch type (tab/pinned tab/window/fullscreen) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved changes requiring external OWNERs approval to another patch Created 8 years, 8 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) 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 "chrome/browser/chromeos/extensions/file_manager_util.h" 10 #include "chrome/browser/chromeos/extensions/file_manager_util.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 void MediaPlayer::ClearPlaylist() { 81 void MediaPlayer::ClearPlaylist() {
82 current_playlist_.clear(); 82 current_playlist_.clear();
83 } 83 }
84 84
85 void MediaPlayer::EnqueueMediaFileUrl(const GURL& url) { 85 void MediaPlayer::EnqueueMediaFileUrl(const GURL& url) {
86 current_playlist_.push_back(url); 86 current_playlist_.push_back(url);
87 } 87 }
88 88
89 void MediaPlayer::ForcePlayMediaFile(Profile* profile,
90 const FilePath& file_path) {
91 GURL url;
92 if (!file_manager_util::ConvertFileToFileSystemUrl(profile, file_path,
93 GetOriginUrl(), &url))
94 return;
95 ForcePlayMediaURL(url);
96 }
97
98 void MediaPlayer::ForcePlayMediaURL(const GURL& url) { 89 void MediaPlayer::ForcePlayMediaURL(const GURL& url) {
99 ClearPlaylist(); 90 ClearPlaylist();
100 EnqueueMediaFileUrl(url); 91 EnqueueMediaFileUrl(url);
101 SetPlaylistPosition(0); 92 SetPlaylistPosition(0);
102 NotifyPlaylistChanged(); 93 NotifyPlaylistChanged();
103 } 94 }
104 95
105 void MediaPlayer::SetPlaylistPosition(int position) { 96 void MediaPlayer::SetPlaylistPosition(int position) {
106 current_position_ = position; 97 current_position_ = position;
107 } 98 }
108 99
109 void MediaPlayer::Observe(int type, 100 void MediaPlayer::Observe(int type,
110 const content::NotificationSource& source, 101 const content::NotificationSource& source,
111 const content::NotificationDetails& details) { 102 const content::NotificationDetails& details) {
112 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSED); 103 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSED);
113 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSED, source); 104 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSED, source);
114 105
115 if (content::Source<Browser>(source).ptr() == mediaplayer_browser_) 106 if (content::Source<Browser>(source).ptr() == mediaplayer_browser_)
116 mediaplayer_browser_ = NULL; 107 mediaplayer_browser_ = NULL;
117 } 108 }
118 109
119 void MediaPlayer::NotifyPlaylistChanged() { 110 void MediaPlayer::NotifyPlaylistChanged() {
120 ExtensionMediaPlayerEventRouter::GetInstance()->NotifyPlaylistChanged(); 111 ExtensionMediaPlayerEventRouter::GetInstance()->NotifyPlaylistChanged();
121 } 112 }
122 113
123 void MediaPlayer::PopupMediaPlayer(Browser* creator) { 114 void MediaPlayer::PopupMediaPlayer() {
124 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 115 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
125 BrowserThread::PostTask( 116 BrowserThread::PostTask(
126 BrowserThread::UI, FROM_HERE, 117 BrowserThread::UI, FROM_HERE,
127 base::Bind(&MediaPlayer::PopupMediaPlayer, 118 base::Bind(&MediaPlayer::PopupMediaPlayer,
128 base::Unretained(this), // this class is a singleton. 119 base::Unretained(this) /*this class is a singleton*/));
129 static_cast<Browser*>(NULL)));
130 return; 120 return;
131 } 121 }
132 if (mediaplayer_browser_) { // Already opened. 122 if (mediaplayer_browser_) { // Already opened.
133 mediaplayer_browser_->window()->Show(); 123 mediaplayer_browser_->window()->Show();
134 return; 124 return;
135 } 125 }
136 126
137 const gfx::Size screen = gfx::Screen::GetPrimaryMonitorSize(); 127 const gfx::Size screen = gfx::Screen::GetPrimaryMonitorSize();
138 const gfx::Rect bounds(screen.width() - kPopupRight - kPopupWidth, 128 const gfx::Rect bounds(screen.width() - kPopupRight - kPopupWidth,
139 screen.height() - kPopupBottom - kPopupHeight, 129 screen.height() - kPopupBottom - kPopupHeight,
140 kPopupWidth, 130 kPopupWidth,
141 kPopupHeight); 131 kPopupHeight);
142 132
143 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); 133 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
144 mediaplayer_browser_ = Browser::CreateWithParams( 134 mediaplayer_browser_ = Browser::CreateWithParams(
145 Browser::CreateParams::CreateForApp(Browser::TYPE_PANEL, 135 Browser::CreateParams::CreateForApp(Browser::TYPE_PANEL,
146 kMediaPlayerAppName, 136 kMediaPlayerAppName,
147 bounds, 137 bounds,
148 profile)); 138 profile));
149 registrar_.Add(this, 139 registrar_.Add(this,
150 chrome::NOTIFICATION_BROWSER_CLOSED, 140 chrome::NOTIFICATION_BROWSER_CLOSED,
151 content::Source<Browser>(mediaplayer_browser_)); 141 content::Source<Browser>(mediaplayer_browser_));
152 142
153 mediaplayer_browser_->AddSelectedTabWithURL(GetMediaPlayerUrl(), 143 mediaplayer_browser_->AddSelectedTabWithURL(GetMediaPlayerUrl(),
154 content::PAGE_TRANSITION_LINK); 144 content::PAGE_TRANSITION_LINK);
155 mediaplayer_browser_->window()->Show(); 145 mediaplayer_browser_->window()->Show();
156 } 146 }
157 147
158 GURL MediaPlayer::GetOriginUrl() const {
159 return file_manager_util::GetMediaPlayerUrl().GetOrigin();
160 }
161
162 GURL MediaPlayer::GetMediaPlayerUrl() const { 148 GURL MediaPlayer::GetMediaPlayerUrl() const {
163 return file_manager_util::GetMediaPlayerUrl(); 149 return file_manager_util::GetMediaPlayerUrl();
164 } 150 }
165 151
166 MediaPlayer::MediaPlayer() 152 MediaPlayer::MediaPlayer()
167 : current_position_(0), 153 : current_position_(0),
168 mediaplayer_browser_(NULL) { 154 mediaplayer_browser_(NULL) {
169 }; 155 };
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/media/media_player.h ('k') | chrome/browser/chromeos/media/media_player_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698