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

Unified Diff: ui/base/dragdrop/drag_utils.cc

Issue 9582041: Move most of ui/views/drag_utils to ui/base/dragdrop so it can be used outside of views. I tried to… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | « ui/base/dragdrop/drag_utils.h ('k') | ui/base/dragdrop/drag_utils_aura.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/dragdrop/drag_utils.cc
===================================================================
--- ui/base/dragdrop/drag_utils.cc (revision 124765)
+++ ui/base/dragdrop/drag_utils.cc (working copy)
@@ -2,57 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/views/drag_utils.h"
+#include "ui/base/dragdrop/drag_utils.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "googleurl/src/gurl.h"
-#include "grit/ui_resources.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/font.h"
-#include "ui/views/controls/button/text_button.h"
+#include "ui/gfx/point.h"
+#include "ui/gfx/size.h"
namespace drag_utils {
// Maximum width of the link drag image in pixels.
-static const int kLinkDragImageMaxWidth = 200;
static const int kLinkDragImageVPadding = 3;
// File dragging pixel measurements
static const int kFileDragImageMaxWidth = 200;
static const SkColor kFileDragImageTextColor = SK_ColorBLACK;
-void SetURLAndDragImage(const GURL& url,
- const string16& title,
- const SkBitmap& icon,
- ui::OSExchangeData* data) {
- DCHECK(url.is_valid() && data);
-
- data->SetURL(url, title);
-
- // Create a button to render the drag image for us.
- views::TextButton button(NULL,
- title.empty() ? UTF8ToUTF16(url.spec()) : title);
- button.set_max_width(kLinkDragImageMaxWidth);
- if (icon.isNull()) {
- button.SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_DEFAULT_FAVICON));
- } else {
- button.SetIcon(icon);
- }
- gfx::Size prefsize = button.GetPreferredSize();
- button.SetBounds(0, 0, prefsize.width(), prefsize.height());
-
- // Render the image.
- gfx::CanvasSkia canvas(prefsize, false);
- button.PaintButton(&canvas, views::TextButton::PB_FOR_DRAG);
- SetDragImageOnDataObject(canvas, prefsize,
- gfx::Point(prefsize.width() / 2, prefsize.height() / 2), data);
-}
-
void CreateDragImageForFile(const FilePath& file_name,
const SkBitmap* icon,
ui::OSExchangeData* data_object) {
« no previous file with comments | « ui/base/dragdrop/drag_utils.h ('k') | ui/base/dragdrop/drag_utils_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698