summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/download_item_view.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 20:22:26 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 20:22:26 +0000
commit04537be0a183839472a8a3b6422cba17d56ba9b1 (patch)
treee68330190f2a1d69ba92bde2c9e054ab7d8e7754 /chrome/browser/views/download_item_view.cc
parent6463cb2a117dcd866a12becb513cfdba935c16e5 (diff)
downloadchromium_src-04537be0a183839472a8a3b6422cba17d56ba9b1.zip
chromium_src-04537be0a183839472a8a3b6422cba17d56ba9b1.tar.gz
chromium_src-04537be0a183839472a8a3b6422cba17d56ba9b1.tar.bz2
Gets a couple of download classes to compile on linux. Updates the
views build so that we only include the gtk classes we need. BUG=none TEST=none Review URL: http://codereview.chromium.org/115788 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16899 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/download_item_view.cc')
-rw-r--r--chrome/browser/views/download_item_view.cc57
1 files changed, 38 insertions, 19 deletions
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index 6ba34d7..9012145c 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -10,9 +10,9 @@
#include "app/gfx/text_elider.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
-#include "app/win_util.h"
#include "base/file_path.h"
#include "base/string_util.h"
+#include "base/sys_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_util.h"
@@ -24,6 +24,10 @@
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
+#if defined(OS_WIN)
+#include "app/win_util.h"
+#endif
+
using base::TimeDelta;
// TODO(paulg): These may need to be adjusted when download progress
@@ -67,11 +71,10 @@ static const int kDisabledOnOpenDuration = 3000;
class DownloadShelfContextMenuWin : public DownloadShelfContextMenu,
public views::Menu::Delegate {
public:
- DownloadShelfContextMenuWin::DownloadShelfContextMenuWin(
- BaseDownloadItemModel* model,
- HWND window,
- const gfx::Point& point)
- : DownloadShelfContextMenu(model) {
+ DownloadShelfContextMenuWin(BaseDownloadItemModel* model,
+ gfx::NativeView window,
+ const gfx::Point& point)
+ : DownloadShelfContextMenu(model) {
DCHECK(model);
// The menu's anchor point is determined based on the UI layout.
@@ -130,25 +133,25 @@ class DownloadShelfContextMenuWin : public DownloadShelfContextMenu,
DownloadItemView::DownloadItemView(DownloadItem* download,
DownloadShelfView* parent,
BaseDownloadItemModel* model)
- : download_(download),
+ : warning_icon_(NULL),
+ download_(download),
parent_(parent),
- model_(model),
- progress_angle_(download_util::kStartAngleDegrees),
+ status_text_(l10n_util::GetString(IDS_DOWNLOAD_STATUS_STARTING)),
+ show_status_text_(true),
body_state_(NORMAL),
drop_down_state_(NORMAL),
+ progress_angle_(download_util::kStartAngleDegrees),
drop_down_pressed_(false),
- status_text_(l10n_util::GetString(IDS_DOWNLOAD_STATUS_STARTING)),
- show_status_text_(true),
dragging_(false),
starting_drag_(false),
- warning_icon_(NULL),
+ model_(model),
save_button_(NULL),
discard_button_(NULL),
dangerous_download_label_(NULL),
dangerous_download_label_sized_(false),
+ disabled_while_opening_(false),
creation_time_(base::Time::Now()),
- ALLOW_THIS_IN_INITIALIZER_LIST(reenable_method_factory_(this)),
- disabled_while_opening_(false) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(reenable_method_factory_(this)) {
// TODO(idana) Bug# 1163334
//
// We currently do not mirror each download item on the download shelf (even
@@ -276,12 +279,21 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
// Extract the file extension (if any).
FilePath filepath(download->original_name());
+#if defined(OS_LINUX)
+ std::wstring extension = base::SysNativeMBToWide(filepath.Extension());
+#else
std::wstring extension = filepath.Extension();
+#endif
// Remove leading '.'
if (extension.length() > 0)
extension = extension.substr(1);
+#if defined(OS_LINUX)
+ std::wstring rootname =
+ base::SysNativeMBToWide(filepath.BaseName().RemoveExtension().value());
+#else
std::wstring rootname = filepath.BaseName().RemoveExtension().value();
+#endif
// Elide giant extensions (this shouldn't currently be hit, but might
// in future, should we ever notice unsafe giant extensions).
@@ -548,8 +560,14 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
filename = gfx::ElideFilename(download_->GetFileName(),
font_, kTextWidth);
} else {
- FilePath filepath(l10n_util::GetStringF(IDS_DOWNLOAD_STATUS_OPENING,
- download_->GetFileName().ToWStringHack()));
+ std::wstring tmp_name =
+ l10n_util::GetStringF(IDS_DOWNLOAD_STATUS_OPENING,
+ download_->GetFileName().ToWStringHack());
+#if defined(OS_WIN)
+ FilePath filepath(tmp_name);
+#else
+ FilePath filepath(base::SysWideToNativeMB(tmp_name));
+#endif
filename = gfx::ElideFilename(filepath, font_, kTextWidth);
}
@@ -826,8 +844,9 @@ bool DownloadItemView::OnMouseDragged(const views::MouseEvent& event) {
if (icon)
download_util::DragDownload(download_, icon);
}
- } else if (win_util::IsDrag(drag_start_point_.ToPOINT(),
- event.location().ToPOINT())) {
+ } else if (ExceededDragThreshold(
+ event.location().x() - drag_start_point_.x(),
+ event.location().y() - drag_start_point_.y())) {
dragging_ = true;
}
return true;
@@ -903,7 +922,7 @@ void DownloadItemView::SizeLabelToMinWidth() {
gfx::Size size;
int min_width = -1;
- int sp_index = text.find(L" ");
+ size_t sp_index = text.find(L" ");
while (sp_index != std::wstring::npos) {
text.replace(sp_index, 1, L"\n");
dangerous_download_label_->SetText(text);