| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/drag_utils.h" | 5 #include "views/drag_utils.h" |
| 6 | 6 |
| 7 #include <objidl.h> | 7 #include <objidl.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <shobjidl.h> | 9 #include <shobjidl.h> |
| 10 | 10 |
| 11 #include "app/gfx/chrome_canvas.h" | 11 #include "app/gfx/chrome_canvas.h" |
| 12 #include "app/gfx/chrome_font.h" | 12 #include "app/gfx/chrome_font.h" |
| 13 #include "app/l10n_util.h" | 13 #include "app/l10n_util.h" |
| 14 #include "app/os_exchange_data.h" | 14 #include "app/os_exchange_data.h" |
| 15 #include "app/resource_bundle.h" | 15 #include "app/resource_bundle.h" |
| 16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
| 17 #include "base/gfx/gdi_util.h" | 17 #include "base/gfx/gdi_util.h" |
| 18 #include "base/gfx/point.h" | 18 #include "base/gfx/point.h" |
| 19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 20 #include "chrome/browser/views/bookmark_bar_view.h" | |
| 21 #include "chrome/common/win_util.h" | 20 #include "chrome/common/win_util.h" |
| 22 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 23 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
| 24 #include "views/controls/button/text_button.h" | 23 #include "views/controls/button/text_button.h" |
| 25 | 24 |
| 26 namespace drag_utils { | 25 namespace drag_utils { |
| 27 | 26 |
| 28 // Maximum width of the link drag image in pixels. | 27 // Maximum width of the link drag image in pixels. |
| 29 static const int kLinkDragImageMaxWidth = 200; | 28 static const int kLinkDragImageMaxWidth = 200; |
| 30 static const int kLinkDragImageVPadding = 3; | 29 static const int kLinkDragImageVPadding = 3; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 const std::wstring& title, | 85 const std::wstring& title, |
| 87 const SkBitmap& icon, | 86 const SkBitmap& icon, |
| 88 OSExchangeData* data) { | 87 OSExchangeData* data) { |
| 89 DCHECK(url.is_valid() && data); | 88 DCHECK(url.is_valid() && data); |
| 90 | 89 |
| 91 data->SetURL(url, title); | 90 data->SetURL(url, title); |
| 92 | 91 |
| 93 // Create a button to render the drag image for us. | 92 // Create a button to render the drag image for us. |
| 94 views::TextButton button(NULL, | 93 views::TextButton button(NULL, |
| 95 title.empty() ? UTF8ToWide(url.spec()) : title); | 94 title.empty() ? UTF8ToWide(url.spec()) : title); |
| 96 button.set_max_width(BookmarkBarView::kMaxButtonWidth); | 95 button.set_max_width(kLinkDragImageMaxWidth); |
| 97 if (icon.isNull()) { | 96 if (icon.isNull()) { |
| 98 button.SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed( | 97 button.SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 99 IDR_DEFAULT_FAVICON)); | 98 IDR_DEFAULT_FAVICON)); |
| 100 } else { | 99 } else { |
| 101 button.SetIcon(icon); | 100 button.SetIcon(icon); |
| 102 } | 101 } |
| 103 gfx::Size prefsize = button.GetPreferredSize(); | 102 gfx::Size prefsize = button.GetPreferredSize(); |
| 104 button.SetBounds(0, 0, prefsize.width(), prefsize.height()); | 103 button.SetBounds(0, 0, prefsize.width(), prefsize.height()); |
| 105 | 104 |
| 106 // Render the image. | 105 // Render the image. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 HBITMAP bitmap = CreateBitmapFromCanvas(canvas, width, height); | 151 HBITMAP bitmap = CreateBitmapFromCanvas(canvas, width, height); |
| 153 | 152 |
| 154 // Attach 'bitmap' to the data_object. | 153 // Attach 'bitmap' to the data_object. |
| 155 SetDragImageOnDataObject(bitmap, width, height, | 154 SetDragImageOnDataObject(bitmap, width, height, |
| 156 cursor_x_offset, | 155 cursor_x_offset, |
| 157 cursor_y_offset, | 156 cursor_y_offset, |
| 158 data_object); | 157 data_object); |
| 159 } | 158 } |
| 160 | 159 |
| 161 } // namespace drag_utils | 160 } // namespace drag_utils |
| OLD | NEW |