summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/frame/panel_browser_view.cc11
-rw-r--r--chrome/browser/chromeos/frame/panel_browser_view.h7
-rw-r--r--chrome/browser/chromeos/frame/panel_controller.cc6
-rw-r--r--chrome/browser/chromeos/frame/panel_controller.h3
-rw-r--r--chrome/browser/chromeos/notifications/notification_panel.cc2
-rw-r--r--chrome/browser/dom_ui/filebrowse_ui.cc14
-rw-r--r--chrome/browser/dom_ui/mediaplayer_browsertest.cc4
-rw-r--r--chrome/browser/dom_ui/mediaplayer_ui.cc35
-rw-r--r--chrome/browser/dom_ui/mediaplayer_ui.h8
-rw-r--r--chrome/browser/platform_util_chromeos.cc2
10 files changed, 65 insertions, 27 deletions
diff --git a/chrome/browser/chromeos/frame/panel_browser_view.cc b/chrome/browser/chromeos/frame/panel_browser_view.cc
index 62bce29..0dda082 100644
--- a/chrome/browser/chromeos/frame/panel_browser_view.cc
+++ b/chrome/browser/chromeos/frame/panel_browser_view.cc
@@ -10,7 +10,8 @@
namespace chromeos {
PanelBrowserView::PanelBrowserView(Browser* browser)
- : BrowserView(browser) {
+ : BrowserView(browser),
+ creator_xid_(0) {
}
////////////////////////////////////////////////////////////////////////////////
@@ -35,7 +36,7 @@ void PanelBrowserView::Init() {
void PanelBrowserView::Show() {
panel_controller_.reset(new PanelController(this, GetNativeHandle()));
- panel_controller_->Init(true /* focus when opened */, bounds());
+ panel_controller_->Init(true /* focus when opened */, bounds(), creator_xid_);
BrowserView::Show();
}
@@ -61,6 +62,12 @@ void PanelBrowserView::ActivationChanged(bool activated) {
}
}
+void PanelBrowserView::SetCreatorView(PanelBrowserView* creator) {
+ DCHECK(creator);
+ GtkWindow* window = creator->GetNativeHandle();
+ creator_xid_ = x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(window));
+}
+
////////////////////////////////////////////////////////////////////////////////
// PanelController::Delegate overrides.
diff --git a/chrome/browser/chromeos/frame/panel_browser_view.h b/chrome/browser/chromeos/frame/panel_browser_view.h
index 5e8b770..c3d7ec3 100644
--- a/chrome/browser/chromeos/frame/panel_browser_view.h
+++ b/chrome/browser/chromeos/frame/panel_browser_view.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_CHROMEOS_FRAME_PANEL_BROWSER_VIEW_H_
#define CHROME_BROWSER_CHROMEOS_FRAME_PANEL_BROWSER_VIEW_H_
+#include "app/x11_util.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/chromeos/frame/panel_controller.h"
#include "chrome/browser/views/frame/browser_view.h"
@@ -28,6 +29,8 @@ class PanelBrowserView : public BrowserView,
virtual void UpdateTitleBar();
virtual void ActivationChanged(bool activated);
+ virtual void SetCreatorView(PanelBrowserView* creator);
+
// PanelController::Delegate overrides
virtual string16 GetPanelTitle();
virtual SkBitmap GetPanelIcon();
@@ -38,6 +41,10 @@ class PanelBrowserView : public BrowserView,
// Controls interactions with the window manager for popup panels.
scoped_ptr<chromeos::PanelController> panel_controller_;
+ // X id for the content window of the panel that created this
+ // panel. This tells ChromeOS that it should be created next to the
+ // content window of this panel.
+ XID creator_xid_;
DISALLOW_COPY_AND_ASSIGN(PanelBrowserView);
};
diff --git a/chrome/browser/chromeos/frame/panel_controller.cc b/chrome/browser/chromeos/frame/panel_controller.cc
index 1c0aa1c..7d0e5f3 100644
--- a/chrome/browser/chromeos/frame/panel_controller.cc
+++ b/chrome/browser/chromeos/frame/panel_controller.cc
@@ -7,7 +7,6 @@
#include <vector>
#include "app/resource_bundle.h"
-#include "app/x11_util.h"
#include "base/logging.h"
#include "base/singleton.h"
#include "base/scoped_ptr.h"
@@ -89,7 +88,9 @@ PanelController::PanelController(Delegate* delegate,
client_event_handler_id_(0) {
}
-void PanelController::Init(bool initial_focus, const gfx::Rect& window_bounds) {
+void PanelController::Init(bool initial_focus,
+ const gfx::Rect& window_bounds,
+ XID creator_xid) {
gfx::Rect title_bounds(
0, 0, window_bounds.width(), kTitleHeight);
@@ -108,6 +109,7 @@ void PanelController::Init(bool initial_focus, const gfx::Rect& window_bounds) {
type_params.push_back(title_xid_);
type_params.push_back(expanded_ ? 1 : 0);
type_params.push_back(initial_focus ? 1 : 0);
+ type_params.push_back(creator_xid);
WmIpc::instance()->SetWindowType(
GTK_WIDGET(panel_),
WM_IPC_WINDOW_CHROME_PANEL_CONTENT,
diff --git a/chrome/browser/chromeos/frame/panel_controller.h b/chrome/browser/chromeos/frame/panel_controller.h
index b4ad0c8..58a1660 100644
--- a/chrome/browser/chromeos/frame/panel_controller.h
+++ b/chrome/browser/chromeos/frame/panel_controller.h
@@ -7,6 +7,7 @@
#include <gtk/gtk.h>
+#include "app/x11_util.h"
#include "views/controls/button/button.h"
class BrowserView;
@@ -51,7 +52,7 @@ class PanelController : public views::ButtonListener {
// Initializes the panel controller with the initial state of the focus and
// the window bounds.
- void Init(bool initial_focus, const gfx::Rect& init_bounds);
+ void Init(bool initial_focus, const gfx::Rect& init_bounds, XID creator_xid);
bool TitleMousePressed(const views::MouseEvent& event);
void TitleMouseReleased(const views::MouseEvent& event, bool canceled);
diff --git a/chrome/browser/chromeos/notifications/notification_panel.cc b/chrome/browser/chromeos/notifications/notification_panel.cc
index 8773b94..96b00b9 100644
--- a/chrome/browser/chromeos/notifications/notification_panel.cc
+++ b/chrome/browser/chromeos/notifications/notification_panel.cc
@@ -458,7 +458,7 @@ void NotificationPanel::Show() {
panel_controller_.reset(
new PanelController(this, GTK_WINDOW(panel_widget_->GetNativeView())));
panel_controller_->Init(false /* don't focus when opened */,
- gfx::Rect(0, 0, kBalloonMinWidth, 1));
+ gfx::Rect(0, 0, kBalloonMinWidth, 1), 0);
registrar_.Add(this, NotificationType::PANEL_STATE_CHANGED,
Source<PanelController>(panel_controller_.get()));
}
diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc
index 4818cff..d5a3e2e 100644
--- a/chrome/browser/dom_ui/filebrowse_ui.cc
+++ b/chrome/browser/dom_ui/filebrowse_ui.cc
@@ -188,6 +188,7 @@ class FilebrowseHandler : public net::DirectoryLister::DirectoryListerDelegate,
scoped_ptr<ListValue> filelist_value_;
FilePath currentpath_;
Profile* profile_;
+ TabContents* tab_contents_;
std::string current_file_contents_;
std::string current_file_uploaded_;
int upload_response_code_;
@@ -320,6 +321,7 @@ void FileBrowseUIHTMLSource::StartDataRequest(const std::string& path,
////////////////////////////////////////////////////////////////////////////////
FilebrowseHandler::FilebrowseHandler()
: profile_(NULL),
+ tab_contents_(NULL),
is_refresh_(false),
fetch_(NULL),
download_manager_(NULL),
@@ -365,7 +367,7 @@ DOMMessageHandler* FilebrowseHandler::Attach(DOMUI* dom_ui) {
&ChromeURLDataManager::AddDataSource,
make_scoped_refptr(new DOMUIFavIconSource(dom_ui->GetProfile()))));
profile_ = dom_ui->GetProfile();
-
+ tab_contents_ = dom_ui->tab_contents();
return DOMMessageHandler::Attach(dom_ui);
}
@@ -571,8 +573,9 @@ void FilebrowseHandler::PlayMediaFile(const Value* value) {
std::string url = currentpath.value();
GURL gurl(url);
-
- mediaplayer->ForcePlayMediaURL(gurl);
+ Browser* browser = Browser::GetBrowserForController(
+ &tab_contents_->controller(), NULL);
+ mediaplayer->ForcePlayMediaURL(gurl, browser);
} else {
LOG(ERROR) << "Unable to get string";
return;
@@ -596,8 +599,9 @@ void FilebrowseHandler::EnqueueMediaFile(const Value* value) {
std::string url = currentpath.value();
GURL gurl(url);
-
- mediaplayer->EnqueueMediaURL(gurl);
+ Browser* browser = Browser::GetBrowserForController(
+ &tab_contents_->controller(), NULL);
+ mediaplayer->EnqueueMediaURL(gurl, browser);
} else {
LOG(ERROR) << "Unable to get string";
return;
diff --git a/chrome/browser/dom_ui/mediaplayer_browsertest.cc b/chrome/browser/dom_ui/mediaplayer_browsertest.cc
index 3e7bf70..92869ae 100644
--- a/chrome/browser/dom_ui/mediaplayer_browsertest.cc
+++ b/chrome/browser/dom_ui/mediaplayer_browsertest.cc
@@ -66,7 +66,7 @@ IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, Popup) {
// Check that its not currently visible
ASSERT_FALSE(IsPlayerVisible());
- player->EnqueueMediaURL(GetMusicTestURL());
+ player->EnqueueMediaURL(GetMusicTestURL(), NULL);
ASSERT_TRUE(IsPlayerVisible());
}
@@ -78,7 +78,7 @@ IN_PROC_BROWSER_TEST_F(MediaPlayerBrowserTest, PopupPlaylist) {
GURL("chrome://downloads"));
MediaPlayer* player = MediaPlayer::Get();
- player->EnqueueMediaURL(GetMusicTestURL());
+ player->EnqueueMediaURL(GetMusicTestURL(), NULL);
EXPECT_FALSE(IsPlaylistVisible());
diff --git a/chrome/browser/dom_ui/mediaplayer_ui.cc b/chrome/browser/dom_ui/mediaplayer_ui.cc
index 90098d6..a3e8bcd 100644
--- a/chrome/browser/dom_ui/mediaplayer_ui.cc
+++ b/chrome/browser/dom_ui/mediaplayer_ui.cc
@@ -37,6 +37,10 @@
#include "net/base/load_flags.h"
#include "net/url_request/url_request_job.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/frame/panel_browser_view.h"
+#endif
+
#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -347,19 +351,19 @@ struct RunnableMethodTraits<MediaPlayer> {
void ReleaseCallee(MediaPlayer* obj) {}
};
-void MediaPlayer::EnqueueMediaURL(const GURL& url) {
+void MediaPlayer::EnqueueMediaURL(const GURL& url, Browser* creator) {
if (handler_ == NULL) {
unhandled_urls_.push_back(url);
- PopupMediaPlayer();
+ PopupMediaPlayer(creator);
} else {
handler_->EnqueueMediaFile(url);
}
}
-void MediaPlayer::ForcePlayMediaURL(const GURL& url) {
+void MediaPlayer::ForcePlayMediaURL(const GURL& url, Browser* creator) {
if (handler_ == NULL) {
unhandled_urls_.push_back(url);
- PopupMediaPlayer();
+ PopupMediaPlayer(creator);
} else {
handler_->PlaybackMediaFile(url);
}
@@ -375,7 +379,7 @@ void MediaPlayer::TogglePlaylistWindowVisible() {
void MediaPlayer::ShowPlaylistWindow() {
if (playlist_browser_ == NULL) {
- PopupPlaylist();
+ PopupPlaylist(NULL);
}
}
@@ -470,7 +474,7 @@ void MediaPlayer::RemoveHandler(MediaplayerHandler* handler) {
}
}
-void MediaPlayer::PopupPlaylist() {
+void MediaPlayer::PopupPlaylist(Browser* creator) {
Profile* profile = BrowserList::GetLastActive()->profile();
playlist_browser_ = Browser::CreateForPopup(profile);
playlist_browser_->AddTabWithURL(
@@ -483,15 +487,28 @@ void MediaPlayer::PopupPlaylist() {
playlist_browser_->window()->Show();
}
-void MediaPlayer::PopupMediaPlayer() {
+void MediaPlayer::PopupMediaPlayer(Browser* creator) {
if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) {
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE,
- NewRunnableMethod(this, &MediaPlayer::PopupMediaPlayer));
+ NewRunnableMethod(this, &MediaPlayer::PopupMediaPlayer,
+ static_cast<Browser*>(NULL)));
return;
}
Profile* profile = BrowserList::GetLastActive()->profile();
mediaplayer_browser_ = Browser::CreateForPopup(profile);
+#if defined(OS_CHROMEOS)
+ // Since we are on chromeos, popups should be a PanelBrowserView,
+ // so we can just cast it.
+ if (creator) {
+ chromeos::PanelBrowserView* creatorview =
+ static_cast<chromeos::PanelBrowserView*>(creator->window());
+ chromeos::PanelBrowserView* view =
+ static_cast<chromeos::PanelBrowserView*>(
+ mediaplayer_browser_->window());
+ view->SetCreatorView(creatorview);
+ }
+#endif
mediaplayer_browser_->AddTabWithURL(
GURL(kMediaplayerURL), GURL(), PageTransition::LINK,
-1, Browser::ADD_SELECTED, NULL, std::string());
@@ -531,7 +548,7 @@ URLRequestJob* MediaPlayer::MaybeInterceptResponse(
if (supported_mime_types_.find(mime_type) != supported_mime_types_.end()) {
if (request->referrer() != chrome::kChromeUIMediaplayerURL &&
!request->referrer().empty()) {
- EnqueueMediaURL(request->url());
+ EnqueueMediaURL(request->url(), NULL);
request->Cancel();
}
}
diff --git a/chrome/browser/dom_ui/mediaplayer_ui.h b/chrome/browser/dom_ui/mediaplayer_ui.h
index 5f565dd..a34c39c 100644
--- a/chrome/browser/dom_ui/mediaplayer_ui.h
+++ b/chrome/browser/dom_ui/mediaplayer_ui.h
@@ -31,11 +31,11 @@ class MediaPlayer : public NotificationObserver,
// Enqueues this url into the current playlist. If the mediaplayer is
// not currently visible, show it, and play the given url.
- void EnqueueMediaURL(const GURL& url);
+ void EnqueueMediaURL(const GURL& url, Browser* creator);
// Clears out the current playlist, and start playback of the given url.
// If there is no mediaplayer currently, show it, and play the given url.
- void ForcePlayMediaURL(const GURL& url);
+ void ForcePlayMediaURL(const GURL& url, Browser* creator);
// Toggle the visibility of the playlist window.
void TogglePlaylistWindowVisible();
@@ -99,11 +99,11 @@ class MediaPlayer : public NotificationObserver,
// Popup the mediaplayer, this shows the browser, and sets up its
// locations correctly.
- void PopupMediaPlayer();
+ void PopupMediaPlayer(Browser* creator);
// Popup the playlist. Shows the browser, sets it up to point at
// chrome://mediaplayer#playlist
- void PopupPlaylist();
+ void PopupPlaylist(Browser* creator);
// Registers the listeners for the close events on the browser windows.
void RegisterListeners();
diff --git a/chrome/browser/platform_util_chromeos.cc b/chrome/browser/platform_util_chromeos.cc
index 1ca9cb3..a537aa4 100644
--- a/chrome/browser/platform_util_chromeos.cc
+++ b/chrome/browser/platform_util_chromeos.cc
@@ -77,7 +77,7 @@ void OpenItem(const FilePath& full_path) {
std::string url = "file://";
url += full_path.value();
GURL gurl(url);
- mediaplayer->EnqueueMediaURL(gurl);
+ mediaplayer->EnqueueMediaURL(gurl, NULL);
return;
}
}