summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-05 18:19:25 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-05 18:19:25 +0000
commitf5bf8ccfcaa51e3f8b12e7eaf4bb26fa6bf2d69c (patch)
tree98b1017d118b3157a449d0b917b3c1ce57869f81 /chrome/browser/chromeos
parentcd023e807914d91d64e325391bde25ff0bdea3f3 (diff)
downloadchromium_src-f5bf8ccfcaa51e3f8b12e7eaf4bb26fa6bf2d69c.zip
chromium_src-f5bf8ccfcaa51e3f8b12e7eaf4bb26fa6bf2d69c.tar.gz
chromium_src-f5bf8ccfcaa51e3f8b12e7eaf4bb26fa6bf2d69c.tar.bz2
Show the filebrowse ui rather than the download shelf in chromeos.
This cl displays the filebrowse ui rather than download shelf for downloads in chrom(e|ium) os. It conditionally replaces (with preprocessor macros) the Browser::OnStartDownload method to do this. The cl adds a static FileBrowseUI::OpenPopup(profile, hashArgument), which opens the file browse ui and passes it the provided hash argument. This is invoked directly from Browser::OnStartDownload. The USBMountObserver code was changed to call this static method, rather than open the popup by hand as it had been doing. I'm not sure about ownership of the Browser* returned by OpenPopup, but based on other code in the tree I assume chrome will deal with freeing it when appropriate. Before this change, USBMountObserver would add the window to registrar_ *before* showing it. Now that FileBrowseUI::OpenPopup returns a which which is already visible, this is no longer the case. I assume this won't be a problem. Commit this for rginda. Original review: http://codereview.chromium.org/555167 BUG=none TEST=none Review URL: http://codereview.chromium.org/564022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38222 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/usb_mount_observer.cc24
-rw-r--r--chrome/browser/chromeos/usb_mount_observer.h2
2 files changed, 8 insertions, 18 deletions
diff --git a/chrome/browser/chromeos/usb_mount_observer.cc b/chrome/browser/chromeos/usb_mount_observer.cc
index d088334..7a271f4 100644
--- a/chrome/browser/chromeos/usb_mount_observer.cc
+++ b/chrome/browser/chromeos/usb_mount_observer.cc
@@ -6,12 +6,13 @@
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
+#include "chrome/browser/dom_ui/filebrowse_ui.h"
#include "chrome/browser/tab_contents/tab_contents.h"
namespace chromeos {
const char* kFilebrowseURLHash = "chrome://filebrowse#";
-const char* kFilebrowseURLScanning = "chrome://filebrowse#scanningdevice";
+const char* kFilebrowseScanning = "scanningdevice";
const int kPopupLeft = 0;
const int kPopupTop = 0;
const int kPopupWidth = 250;
@@ -33,20 +34,12 @@ void USBMountObserver::Observe(NotificationType type,
}
}
-void USBMountObserver::PopUpWindow(const std::string& url,
- const std::string& device_path) {
- Browser* browser = Browser::CreateForPopup(profile_);
- browser->AddTabWithURL(
- GURL(url), GURL(), PageTransition::LINK,
- true, -1, false, NULL);
- browser->window()->SetBounds(gfx::Rect(kPopupLeft,
- kPopupTop,
- kPopupWidth,
- kPopupHeight));
+void USBMountObserver::OpenFileBrowse(const std::string& url,
+ const std::string& device_path) {
+ Browser *browser = FileBrowseUI::OpenPopup(profile_, url);
registrar_.Add(this,
NotificationType::BROWSER_CLOSED,
Source<Browser>(browser));
- browser->window()->Show();
BrowserWithPath new_browser;
new_browser.browser = browser;
new_browser.device_path = device_path;
@@ -85,9 +78,7 @@ void USBMountObserver::MountChanged(chromeos::MountLibrary* obj,
iter->device_path = path;
iter->browser->Reload();
} else {
- std::string url = kFilebrowseURLHash;
- url += disks[i].mount_path;
- PopUpWindow(url, disks[i].device_path);
+ OpenFileBrowse(disks[i].mount_path, disks[i].device_path);
}
}
return;
@@ -97,8 +88,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.
- std::string url = kFilebrowseURLScanning;
- PopUpWindow(url, path);
+ OpenFileBrowse(kFilebrowseScanning, path);
} 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 7f11444..11e5f26 100644
--- a/chrome/browser/chromeos/usb_mount_observer.h
+++ b/chrome/browser/chromeos/usb_mount_observer.h
@@ -52,7 +52,7 @@ 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 PopUpWindow(const std::string& url, const std::string& device_path);
+ void OpenFileBrowse(const std::string& url, const std::string& device_path);
Profile* profile_;
std::vector<BrowserWithPath> browsers_;