diff options
author | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-04 23:01:20 +0000 |
---|---|---|
committer | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-04 23:01:20 +0000 |
commit | 93a58bf71562d84d4c8d6b05c18c8ffdfbdeada1 (patch) | |
tree | 631688362e7d53c37baa71cf3dc4ed1a31960c76 /chrome/browser/dom_ui | |
parent | 485e05f8951cddaa6caf374b80987ec437dbb125 (diff) | |
download | chromium_src-93a58bf71562d84d4c8d6b05c18c8ffdfbdeada1.zip chromium_src-93a58bf71562d84d4c8d6b05c18c8ffdfbdeada1.tar.gz chromium_src-93a58bf71562d84d4c8d6b05c18c8ffdfbdeada1.tar.bz2 |
Adding reporting of parent browser's id, so that we can open up next to that browser if wanted.
BUG=chromium-os:3711
TEST=none
Review URL: http://codereview.chromium.org/2640002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48987 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r-- | chrome/browser/dom_ui/filebrowse_ui.cc | 14 | ||||
-rw-r--r-- | chrome/browser/dom_ui/mediaplayer_browsertest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/dom_ui/mediaplayer_ui.cc | 35 | ||||
-rw-r--r-- | chrome/browser/dom_ui/mediaplayer_ui.h | 8 |
4 files changed, 41 insertions, 20 deletions
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(); |