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

Unified Diff: chrome/browser/ui/webui/active_downloads_ui.cc

Issue 6969057: Support for re-using open tabs (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/active_downloads_ui.cc
===================================================================
--- chrome/browser/ui/webui/active_downloads_ui.cc (revision 86295)
+++ chrome/browser/ui/webui/active_downloads_ui.cc (working copy)
@@ -31,6 +31,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/favicon_source.h"
#include "chrome/browser/ui/webui/mediaplayer_ui.h"
#include "chrome/common/chrome_paths.h"
@@ -110,7 +111,6 @@
void HandlePauseToggleDownload(const ListValue* args);
void HandleCancelDownload(const ListValue* args);
void HandleAllowDownload(const ListValue* args);
- void OpenNewPopupWindow(const ListValue* args);
void OpenNewFullWindow(const ListValue* args);
void PlayMediaFile(const ListValue* args);
@@ -120,9 +120,8 @@
void UpdateDownloadList();
void SendDownloads();
void AddDownload(DownloadItem* item);
+ bool SelectTab(const GURL& url);
- void OpenNewWindow(const ListValue* args, bool popup);
-
Profile* profile_;
TabContents* tab_contents_;
DownloadManager* download_manager_;
@@ -230,8 +229,6 @@
NewCallback(this, &ActiveDownloadsHandler::HandleCancelDownload));
web_ui_->RegisterMessageCallback("allowDownload",
NewCallback(this, &ActiveDownloadsHandler::HandleAllowDownload));
- web_ui_->RegisterMessageCallback("openNewPopupWindow",
- NewCallback(this, &ActiveDownloadsHandler::OpenNewPopupWindow));
web_ui_->RegisterMessageCallback("openNewFullWindow",
NewCallback(this, &ActiveDownloadsHandler::OpenNewFullWindow));
web_ui_->RegisterMessageCallback("playMediaFile",
@@ -277,27 +274,28 @@
}
}
-void ActiveDownloadsHandler::OpenNewFullWindow(const ListValue* args) {
- OpenNewWindow(args, false);
+bool ActiveDownloadsHandler::SelectTab(const GURL& url) {
+ for (TabContentsIterator it; !it.done(); ++it) {
+ TabContents* tab_contents = it->tab_contents();
+ if (tab_contents->GetURL() == url) {
+ tab_contents->Activate();
+ return true;
+ }
+ }
+ return false;
}
-void ActiveDownloadsHandler::OpenNewPopupWindow(const ListValue* args) {
- OpenNewWindow(args, true);
-}
-
-void ActiveDownloadsHandler::OpenNewWindow(const ListValue* args, bool popup) {
+void ActiveDownloadsHandler::OpenNewFullWindow(const ListValue* args) {
std::string url = UTF16ToUTF8(ExtractStringValue(args));
- Browser* browser = popup ?
- Browser::CreateForApp(Browser::TYPE_PANEL, kActiveDownloadAppName,
- gfx::Size(), profile_) :
- BrowserList::GetLastActive();
+
+ if (SelectTab(GURL(url)))
+ return;
+
+ Browser* browser = BrowserList::GetLastActive();
browser::NavigateParams params(browser, GURL(url), PageTransition::LINK);
params.disposition = NEW_FOREGROUND_TAB;
browser::Navigate(&params);
- // TODO(beng): The following two calls should be automatic by Navigate().
- if (popup)
- params.browser->window()->SetBounds(gfx::Rect(0, 0, 400, 300));
- params.browser->window()->Show();
+ browser->window()->Show();
}
void ActiveDownloadsHandler::ModelChanged() {
@@ -403,16 +401,15 @@
params.disposition = NEW_FOREGROUND_TAB;
browser::Navigate(&params);
+ DCHECK_EQ(browser, params.browser);
// TODO(beng): The following two calls should be automatic by Navigate().
- params.browser->window()->SetBounds(gfx::Rect(kPopupLeft,
- kPopupTop,
- kPopupWidth,
- kPopupHeight));
- params.browser->window()->Show();
- } else {
- browser->window()->Show();
+ browser->window()->SetBounds(gfx::Rect(kPopupLeft,
+ kPopupTop,
+ kPopupWidth,
+ kPopupHeight));
}
+ browser->window()->Show();
return browser;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698