diff options
author | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 19:41:56 +0000 |
---|---|---|
committer | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 19:41:56 +0000 |
commit | 46729329047dc02f672d9d5ead5ffaf1c49552b3 (patch) | |
tree | c6dac551a3abc7a62e58dbea257848979e14bf3e /chrome | |
parent | 365e821c6fb698c132a69d8c6bc9bc48667f4137 (diff) | |
download | chromium_src-46729329047dc02f672d9d5ead5ffaf1c49552b3.zip chromium_src-46729329047dc02f672d9d5ead5ffaf1c49552b3.tar.gz chromium_src-46729329047dc02f672d9d5ead5ffaf1c49552b3.tar.bz2 |
fixing issues with filebrowser namely, namely allowing it to grow on mount, and fixing download cases so the flow is better.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/1527036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser.cc | 5 | ||||
-rw-r--r-- | chrome/browser/browser_resources.grd | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/usb_mount_observer.cc | 24 | ||||
-rw-r--r-- | chrome/browser/chromeos/usb_mount_observer.h | 4 | ||||
-rw-r--r-- | chrome/browser/dom_ui/filebrowse_ui.cc | 15 | ||||
-rw-r--r-- | chrome/browser/dom_ui/filebrowse_ui.h | 10 | ||||
-rw-r--r-- | chrome/browser/resources/filebrowse.html | 29 |
7 files changed, 64 insertions, 25 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 8772248..231cc5a 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -2495,7 +2495,10 @@ void Browser::OnStartDownload(DownloadItem* download) { #if defined(OS_CHROMEOS) // skip the download shelf and just open the file browser in chromeos std::string arg = download->full_path().DirName().value(); - FileBrowseUI::OpenPopup(profile_, arg); + FileBrowseUI::OpenPopup(profile_, + arg, + FileBrowseUI::kPopupWidth, + FileBrowseUI::kPopupHeight); #else // GetDownloadShelf creates the download shelf if it was not yet created. diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index abc9a55..c5e5a84 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- This comment is only here because changes to resources are not picked up -without changes to the corresponding grd file. euuu --> +without changes to the corresponding grd file. partydownup --> <grit latest_public_release="0" current_release="1"> <outputs> <output filename="grit/browser_resources.h" type="rc_header"> diff --git a/chrome/browser/chromeos/usb_mount_observer.cc b/chrome/browser/chromeos/usb_mount_observer.cc index 91790d1..892b9bb 100644 --- a/chrome/browser/chromeos/usb_mount_observer.cc +++ b/chrome/browser/chromeos/usb_mount_observer.cc @@ -35,8 +35,20 @@ void USBMountObserver::Observe(NotificationType type, } void USBMountObserver::OpenFileBrowse(const std::string& url, - const std::string& device_path) { - Browser *browser = FileBrowseUI::OpenPopup(profile_, url); + const std::string& device_path, + bool small) { + Browser *browser; + if (small) { + browser = FileBrowseUI::OpenPopup(profile_, + url, + FileBrowseUI::kSmallPopupWidth, + FileBrowseUI::kSmallPopupHeight); + } else { + browser = FileBrowseUI::OpenPopup(profile_, + url, + FileBrowseUI::kPopupWidth, + FileBrowseUI::kPopupHeight); + } registrar_.Add(this, NotificationType::BROWSER_CLOSED, Source<Browser>(browser)); @@ -44,7 +56,6 @@ void USBMountObserver::OpenFileBrowse(const std::string& url, new_browser.browser = browser; new_browser.device_path = device_path; browsers_.push_back(new_browser); - } void USBMountObserver::MountChanged(chromeos::MountLibrary* obj, @@ -85,12 +96,14 @@ void USBMountObserver::MountChanged(chromeos::MountLibrary* obj, std::string url = kFilebrowseURLHash; url += disks[i].mount_path; TabContents* tab = iter->browser->GetSelectedTabContents(); + iter->browser->window()->SetBounds(gfx::Rect( + 0, 0, FileBrowseUI::kPopupWidth, FileBrowseUI::kPopupHeight)); tab->OpenURL(GURL(url), GURL(), CURRENT_TAB, PageTransition::LINK); tab->NavigateToPendingEntry(NavigationController::RELOAD); iter->device_path = path; } else { - OpenFileBrowse(disks[i].mount_path, disks[i].device_path); + OpenFileBrowse(disks[i].mount_path, disks[i].device_path, false); } } return; @@ -99,8 +112,7 @@ void USBMountObserver::MountChanged(chromeos::MountLibrary* obj, } } else if (evt == chromeos::DEVICE_ADDED) { LOG(INFO) << "Got device added" << path; - // TODO(dhg): Refactor once mole api is ready. - OpenFileBrowse(kFilebrowseScanning, path); + OpenFileBrowse(kFilebrowseScanning, path, true); } else if (evt == chromeos::DEVICE_SCANNED) { LOG(INFO) << "Got device scanned:" << path; } diff --git a/chrome/browser/chromeos/usb_mount_observer.h b/chrome/browser/chromeos/usb_mount_observer.h index 11e5f26..7141de3 100644 --- a/chrome/browser/chromeos/usb_mount_observer.h +++ b/chrome/browser/chromeos/usb_mount_observer.h @@ -52,7 +52,9 @@ class USBMountObserver : public chromeos::MountLibrary::Observer, // Used to create a window of a standard size, and add it to a list // of tracked browser windows in case that device goes away. - void OpenFileBrowse(const std::string& url, const std::string& device_path); + void OpenFileBrowse(const std::string& url, + const std::string& device_path, + bool small); Profile* profile_; std::vector<BrowserWithPath> browsers_; diff --git a/chrome/browser/dom_ui/filebrowse_ui.cc b/chrome/browser/dom_ui/filebrowse_ui.cc index 8d4f874..95143b7 100644 --- a/chrome/browser/dom_ui/filebrowse_ui.cc +++ b/chrome/browser/dom_ui/filebrowse_ui.cc @@ -62,8 +62,6 @@ static const std::string kPicasawebBaseUrl = "http://picasaweb.google.com/"; static const char* kFilebrowseURLHash = "chrome://filebrowse#"; static const int kPopupLeft = 0; static const int kPopupTop = 0; -static const int kPopupWidth = 250; -static const int kPopupHeight = 300; class FileBrowseUIHTMLSource : public ChromeURLDataManager::DataSource { public: @@ -959,7 +957,9 @@ FileBrowseUI::FileBrowseUI(TabContents* contents) : HtmlDialogUI(contents) { // static Browser* FileBrowseUI::OpenPopup(Profile* profile, - const std::string& hashArgument) { + const std::string& hashArgument, + int width, + int height) { // Get existing pop up for given hashArgument. Browser* browser = GetPopupForPath(hashArgument); @@ -975,8 +975,8 @@ Browser* FileBrowseUI::OpenPopup(Profile* profile, true, -1, false, NULL); browser->window()->SetBounds(gfx::Rect(kPopupLeft, kPopupTop, - kPopupWidth, - kPopupHeight)); + width, + height)); browser->window()->Show(); } @@ -1001,3 +1001,8 @@ Browser* FileBrowseUI::GetPopupForPath(const std::string& path) { return NULL; } + +const int FileBrowseUI::kPopupWidth = 250; +const int FileBrowseUI::kPopupHeight = 300; +const int FileBrowseUI::kSmallPopupWidth = 250; +const int FileBrowseUI::kSmallPopupHeight = 50; diff --git a/chrome/browser/dom_ui/filebrowse_ui.h b/chrome/browser/dom_ui/filebrowse_ui.h index c6fdc43..ce02a8f 100644 --- a/chrome/browser/dom_ui/filebrowse_ui.h +++ b/chrome/browser/dom_ui/filebrowse_ui.h @@ -21,9 +21,17 @@ class Profile; class FileBrowseUI : public HtmlDialogUI { public: + static const int kPopupWidth; + static const int kPopupHeight; + static const int kSmallPopupWidth; + static const int kSmallPopupHeight; + explicit FileBrowseUI(TabContents* contents); - static Browser* OpenPopup(Profile* profile, const std::string& hashArgument); + static Browser* OpenPopup(Profile* profile, + const std::string& hashArgument, + int width, + int height); static Browser* GetPopupForPath(const std::string& path); private: diff --git a/chrome/browser/resources/filebrowse.html b/chrome/browser/resources/filebrowse.html index afa1b00..38e7f55 100644 --- a/chrome/browser/resources/filebrowse.html +++ b/chrome/browser/resources/filebrowse.html @@ -593,6 +593,7 @@ var inSaveMode = false; var currentMenu = null; var mainColumn = null; var localStrings; +var downloadList = []; // strings var kPauseDownload; @@ -692,7 +693,6 @@ function browseFileResult(info, results) { clearList(main); createNewList(lastDir, results, main, info.path); } else { - alert('hmm, got a refresh on an unknown directory: '+ 'dir/' + info.path); // not currently displayed, so just return. return; } @@ -951,10 +951,27 @@ function cancelDownload(id) { chrome.send('cancelDownload', ['' + id]); } +function getPathAndFilenameForPath(path) { + return path.match(/(.*)[\/\\]([^\/\\]+\.\w+)$/); +} + function downloadUpdated(results) { for (var x = 0; x < results.length; x++) { var element = $(results[x].file_path); + if (!element && results[x].state != 'CANCELLED') { + extracted = getPathAndFilenameForPath(results[x].file_path); + var dirId = $('list/dir/' + extracted[1]); + if (dirId) { + element = createNewItem(extracted[2], results[x].file_path, false); + dirId.appendChild(element); + element.scrollIntoView(); + } + } if (element) { + if (results[x].state == 'CANCELLED') { + element.parentNode.removeChild(element); + continue; + } if (results[x].percent < 100 || results[x].state == 'DANGEROUS') { var progressDiv = null; for (var y = 0; y < element.children.length; y++) { @@ -1020,14 +1037,6 @@ function downloadUpdated(results) { } element.className = 'filebrowserow'; } - } else { - // Figure out if the item is currently visible - // TODO(dhg): Support multi pane - // This checks to make sure its not mid updating when it does this. - var element = $('dir/' + pathArray[currentNode]); - if (element && results[x].file_path.indexOf(pathArray[currentNode]) >= 0) { - chrome.send("refreshDirectory", [pathArray[currentNode]]); - } } } } @@ -1459,7 +1468,7 @@ function createNewList(title, results, main, path) { mainList.className = 'columnlist'; var list = document.createElement('ul'); list.className = 'filebrowselist'; - + list.id = 'list/dir/' + path; var header = document.createElement('div'); header.className = 'header'; var divTitle = document.createElement('div'); |