diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-26 20:22:26 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-26 20:22:26 +0000 |
commit | 04537be0a183839472a8a3b6422cba17d56ba9b1 (patch) | |
tree | e68330190f2a1d69ba92bde2c9e054ab7d8e7754 /chrome | |
parent | 6463cb2a117dcd866a12becb513cfdba935c16e5 (diff) | |
download | chromium_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')
-rw-r--r-- | chrome/browser/download/download_util.cc | 19 | ||||
-rw-r--r-- | chrome/browser/download/download_util.h | 8 | ||||
-rw-r--r-- | chrome/browser/views/download_item_view.cc | 57 | ||||
-rw-r--r-- | chrome/browser/views/download_shelf_view.cc | 2 | ||||
-rw-r--r-- | chrome/chrome.gyp | 22 |
5 files changed, 78 insertions, 30 deletions
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index df3fb82..e22821a 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -22,8 +22,11 @@ #include "third_party/skia/include/core/SkPath.h" #include "third_party/skia/include/core/SkShader.h" -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) #include "app/os_exchange_data.h" +#endif + +#if defined(OS_WIN) #include "base/base_drag_source.h" #include "views/drag_utils.h" #endif @@ -66,7 +69,7 @@ SkBitmap* g_foreground_32 = NULL; SkBitmap* g_background_32 = NULL; void PaintDownloadProgress(gfx::Canvas* canvas, -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) views::View* containing_view, #endif int origin_x, @@ -96,7 +99,7 @@ void PaintDownloadProgress(gfx::Canvas* canvas, gfx::Rect foreground_bounds(origin_x, origin_y, foreground->width(), foreground->height()); -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) // Mirror the positions if necessary. int mirrored_x = containing_view->MirroredLeftPointForRect(background_bounds); background_bounds.set_x(mirrored_x); @@ -165,7 +168,7 @@ void PaintDownloadProgress(gfx::Canvas* canvas, } void PaintDownloadComplete(gfx::Canvas* canvas, -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) views::View* containing_view, #endif int origin_x, @@ -183,7 +186,7 @@ void PaintDownloadComplete(gfx::Canvas* canvas, gfx::Rect complete_bounds(origin_x, origin_y, complete->width(), complete->height()); -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) // Mirror the positions if necessary. complete_bounds.set_x( containing_view->MirroredLeftPointForRect(complete_bounds)); @@ -230,9 +233,10 @@ int GetBigProgressIconOffset() { return (GetBigProgressIconSize() - kBigIconSize) / 2; } -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) // Download dragging void DragDownload(const DownloadItem* download, SkBitmap* icon) { +#if defined(OS_WIN) DCHECK(download); // Set up our OLE machinery @@ -247,6 +251,9 @@ void DragDownload(const DownloadItem* download, SkBitmap* icon) { DWORD effects; DoDragDrop(data.get(), drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK, &effects); +#else + NOTIMPLEMENTED(); +#endif } #endif diff --git a/chrome/browser/download/download_util.h b/chrome/browser/download/download_util.h index f187706..bd43e67 100644 --- a/chrome/browser/download/download_util.h +++ b/chrome/browser/download/download_util.h @@ -14,7 +14,7 @@ #include "base/basictypes.h" #include "base/task.h" -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) #include "views/view.h" #endif @@ -98,7 +98,7 @@ enum PaintDownloadProgressSize { // drawing in a right-to-left locale, we need to mirror the position of the // progress animation within the containing View. void PaintDownloadProgress(gfx::Canvas* canvas, -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) views::View* containing_view, #endif int origin_x, @@ -108,7 +108,7 @@ void PaintDownloadProgress(gfx::Canvas* canvas, PaintDownloadProgressSize size); void PaintDownloadComplete(gfx::Canvas* canvas, -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) views::View* containing_view, #endif int origin_x, @@ -116,7 +116,7 @@ void PaintDownloadComplete(gfx::Canvas* canvas, double animation_progress, PaintDownloadProgressSize size); -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) // Drag support ---------------------------------------------------------------- // Helper function for download views to use when acting as a drag source for a 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); diff --git a/chrome/browser/views/download_shelf_view.cc b/chrome/browser/views/download_shelf_view.cc index 8e3353a..ba87039 100644 --- a/chrome/browser/views/download_shelf_view.cc +++ b/chrome/browser/views/download_shelf_view.cc @@ -23,7 +23,7 @@ // Max number of download views we'll contain. Any time a view is added and // we already have this many download views, one is removed. -static const int kMaxDownloadViews = 15; +static const size_t kMaxDownloadViews = 15; // Padding from left edge and first download view. static const int kLeftPadding = 2; diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 9287372..da25716 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1697,6 +1697,12 @@ ['include', '^browser/dock_info_gtk.cc'], ['include', '^browser/dock_info.cc'], ['include', '^browser/dock_info.h'], + ['include', '^browser/views/download_item_view.cc'], + ['include', '^browser/views/download_item_view.h'], + ['include', '^browser/views/download_shelf_view.cc'], + ['include', '^browser/views/download_shelf_view.h'], + ['include', '^browser/views/event_utils.cc'], + ['include', '^browser/views/event_utils.h'], ['include', '^browser/views/find_bar_view.cc'], ['include', '^browser/views/find_bar_view.h'], ['include', '^browser/views/find_bar_win.cc'], @@ -1720,6 +1726,22 @@ ['include', '^browser/views/tabs/tab_renderer.h'], ['include', '^browser/views/tabs/tab_strip.cc'], ['include', '^browser/views/tabs/tab_strip.h'], + + # Exclude all of browser/gtk, then include the things we want. + ['exclude', '^browser/gtk'], + ['include', '^browser/gtk/dialogs_gtk.cc'], + ['include', '^browser/gtk/dialogs_gtk.h'], + ['include', '^browser/gtk/download_started_animation_gtk.cc'], + ['include', '^browser/gtk/download_started_animation_gtk.h'], + ['include', '^browser/gtk/focus_store_gtk.cc'], + ['include', '^browser/gtk/focus_store_gtk.h'], + ['include', '^browser/gtk/hung_renderer_dialog_gtk.cc'], + ['include', '^browser/gtk/hung_renderer_dialog_gtk.h'], + ['include', '^browser/gtk/options'], + ['include', '^browser/gtk/menu_gtk.cc'], + ['include', '^browser/gtk/menu_gtk.h'], + ['include', '^browser/gtk/sad_tab_gtk.cc'], + ['include', '^browser/gtk/sad_tab_gtk.h'], ], }], ['toolkit_views==0',{ |