summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/media
diff options
context:
space:
mode:
authorkaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-15 13:18:55 +0000
committerkaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-15 13:18:55 +0000
commit1a7e98c76b23553bc57628b142bab7a45b5d7373 (patch)
treec81f332c7bf0f72569f3c0eb9c0e60329bc45a84 /chrome/browser/chromeos/media
parentdd8678f89eba316c04d9f19495967f8e946ecdd3 (diff)
downloadchromium_src-1a7e98c76b23553bc57628b142bab7a45b5d7373.zip
chromium_src-1a7e98c76b23553bc57628b142bab7a45b5d7373.tar.gz
chromium_src-1a7e98c76b23553bc57628b142bab7a45b5d7373.tar.bz2
Position the Chrome OS Audio Player properly.
This patch is trying to revive some of the behavior that the Audio Player had in the old panel manager, specifically it puts it in the lower right corner of the screen. This is likely to be a temporary solution. BUG=chromium-os:27701 TEST= Review URL: http://codereview.chromium.org/9704052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126900 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/media')
-rw-r--r--chrome/browser/chromeos/media/media_player.cc35
1 files changed, 22 insertions, 13 deletions
diff --git a/chrome/browser/chromeos/media/media_player.cc b/chrome/browser/chromeos/media/media_player.cc
index b0569c6..d33ae15 100644
--- a/chrome/browser/chromeos/media/media_player.cc
+++ b/chrome/browser/chromeos/media/media_player.cc
@@ -46,6 +46,7 @@
#include "net/base/load_flags.h"
#include "net/url_request/url_request_job.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/screen.h"
#if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK)
#include "chrome/browser/chromeos/frame/panel_browser_view.h"
@@ -55,8 +56,8 @@ using content::BrowserThread;
using content::UserMetricsAction;
static const char* kMediaPlayerAppName = "mediaplayer";
-static const int kPopupLeft = 0;
-static const int kPopupTop = 0;
+static const int kPopupRight = 20;
+static const int kPopupBottom = 50;
static const int kPopupWidth = 280;
// Set the initial height to the minimum possible height. Keep the constants
@@ -91,12 +92,15 @@ MediaPlayer* MediaPlayer::GetInstance() {
return Singleton<MediaPlayer>::get();
}
-void MediaPlayer::SetWindowHeight(int height) {
+void MediaPlayer::SetWindowHeight(int content_height) {
if (mediaplayer_browser_ != NULL) {
- mediaplayer_browser_->window()->SetBounds(gfx::Rect(kPopupLeft,
- kPopupTop,
- kPopupWidth,
- height + kTitleHeight));
+ int window_height = content_height + kTitleHeight;
+ gfx::Rect bounds = mediaplayer_browser_->window()->GetBounds();
+ mediaplayer_browser_->window()->SetBounds(gfx::Rect(
+ bounds.x(),
+ std::max(0, bounds.bottom() - window_height),
+ bounds.width(),
+ window_height));
}
}
@@ -157,16 +161,21 @@ void MediaPlayer::PopupMediaPlayer(Browser* creator) {
static_cast<Browser*>(NULL)));
return;
}
- if (mediaplayer_browser_)
- return; // Already opened.
+ if (mediaplayer_browser_) { // Already opened.
+ mediaplayer_browser_->window()->Show();
+ return;
+ }
+
+ const gfx::Size screen = gfx::Screen::GetPrimaryMonitorSize();
+ const gfx::Rect bounds(screen.width() - kPopupRight - kPopupWidth,
+ screen.height() - kPopupBottom - kPopupHeight,
+ kPopupWidth,
+ kPopupHeight);
Profile* profile = BrowserList::GetLastActive()->profile();
mediaplayer_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL,
kMediaPlayerAppName,
- gfx::Rect(kPopupLeft,
- kPopupTop,
- kPopupWidth,
- kPopupHeight),
+ bounds,
profile);
registrar_.Add(this,
chrome::NOTIFICATION_BROWSER_CLOSED,