summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 21:58:18 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 21:58:18 +0000
commit8c3dc79bc13ba84f418d3c135e1bf296a3e29722 (patch)
tree32eb9688d500a90eb74a7c4f8cb5a97e507dd0fc /chrome
parentabaccb2cb8cff8138e5ea9daf420645e5852c9eb (diff)
downloadchromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.zip
chromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.tar.gz
chromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.tar.bz2
Refactors OSExchangeData for easier portability.
BUG=none TEST=none Review URL: http://codereview.chromium.org/164401 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23230 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc17
-rw-r--r--chrome/browser/bookmarks/bookmark_context_menu_controller.cc2
-rw-r--r--chrome/browser/bookmarks/bookmark_context_menu_controller.h1
-rw-r--r--chrome/browser/bookmarks/bookmark_drag_data.cc56
-rw-r--r--chrome/browser/bookmarks/bookmark_drag_data.h11
-rw-r--r--chrome/browser/bookmarks/bookmark_drag_data_unittest.cc54
-rw-r--r--chrome/browser/download/download_util.cc14
-rw-r--r--chrome/browser/tab_contents/web_drop_target.cc3
-rw-r--r--chrome/browser/views/bookmark_folder_tree_view.cc7
-rw-r--r--chrome/browser/views/bookmark_table_view.cc7
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_win.cc16
11 files changed, 99 insertions, 89 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index 5e88e94..839e1b3 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -10,6 +10,7 @@
#include "app/l10n_util.h"
#include "app/l10n_util_win.h"
#include "app/os_exchange_data.h"
+#include "app/os_exchange_data_provider_win.h"
#include "app/win_util.h"
#include "base/base_drag_source.h"
#include "base/base_drop_target.h"
@@ -127,7 +128,7 @@ DWORD EditDropTarget::OnDragEnter(IDataObject* data_object,
DWORD key_state,
POINT cursor_position,
DWORD effect) {
- OSExchangeData os_data(data_object);
+ OSExchangeData os_data(new OSExchangeDataProviderWin(data_object));
drag_has_url_ = os_data.HasURL();
drag_has_string_ = !drag_has_url_ && os_data.HasString();
if (drag_has_url_) {
@@ -177,7 +178,7 @@ DWORD EditDropTarget::OnDrop(IDataObject* data_object,
DWORD key_state,
POINT cursor_position,
DWORD effect) {
- OSExchangeData os_data(data_object);
+ OSExchangeData os_data(new OSExchangeDataProviderWin(data_object));
if (drag_has_url_) {
GURL url;
@@ -2230,7 +2231,7 @@ void AutocompleteEditViewWin::StartDragIfNecessary(const CPoint& point) {
if (initiated_drag_ || !win_util::IsDrag(mouse_down_point_, point))
return;
- scoped_refptr<OSExchangeData> data = new OSExchangeData;
+ OSExchangeData data;
DWORD supported_modes = DROPEFFECT_COPY;
@@ -2258,8 +2259,8 @@ void AutocompleteEditViewWin::StartDragIfNecessary(const CPoint& point) {
std::wstring title;
SkBitmap favicon;
model_->GetDataForURLExport(&url, &title, &favicon);
- drag_utils::SetURLAndDragImage(url, title, favicon, data.get());
- data->SetURL(url, title);
+ drag_utils::SetURLAndDragImage(url, title, favicon, &data);
+ data.SetURL(url, title);
supported_modes |= DROPEFFECT_LINK;
UserMetrics::RecordAction(L"Omnibox_DragURL", model_->profile());
} else {
@@ -2267,13 +2268,13 @@ void AutocompleteEditViewWin::StartDragIfNecessary(const CPoint& point) {
UserMetrics::RecordAction(L"Omnibox_DragString", model_->profile());
}
- data->SetString(GetSelectedText());
+ data.SetString(GetSelectedText());
scoped_refptr<BaseDragSource> drag_source(new BaseDragSource);
DWORD dropped_mode;
in_drag_ = true;
- if (DoDragDrop(data, drag_source, supported_modes, &dropped_mode) ==
- DRAGDROP_S_DROP) {
+ if (DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source,
+ supported_modes, &dropped_mode) == DRAGDROP_S_DROP) {
if ((dropped_mode == DROPEFFECT_MOVE) && (start_text == GetText())) {
ScopedFreeze freeze(this, GetTextObjectModel());
OnBeforePossibleChange();
diff --git a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc
index 4f6d941..81fbcc9 100644
--- a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc
+++ b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/views/bookmark_context_menu.h"
+#include "chrome/browser/bookmarks/bookmark_context_menu_controller.h"
#include "app/l10n_util.h"
#include "base/compiler_specific.h"
diff --git a/chrome/browser/bookmarks/bookmark_context_menu_controller.h b/chrome/browser/bookmarks/bookmark_context_menu_controller.h
index 4d611d8..03a57c4 100644
--- a/chrome/browser/bookmarks/bookmark_context_menu_controller.h
+++ b/chrome/browser/bookmarks/bookmark_context_menu_controller.h
@@ -10,7 +10,6 @@
#include "base/basictypes.h"
#include "base/gfx/native_widget_types.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
-#include "views/controls/menu/chrome_menu.h"
class Browser;
class PageNavigator;
diff --git a/chrome/browser/bookmarks/bookmark_drag_data.cc b/chrome/browser/bookmarks/bookmark_drag_data.cc
index 0ed2273..47ea0c0 100644
--- a/chrome/browser/bookmarks/bookmark_drag_data.cc
+++ b/chrome/browser/bookmarks/bookmark_drag_data.cc
@@ -13,29 +13,9 @@
#include "chrome/common/url_constants.h"
#include "chrome/browser/browser_process.h"
-// TODO(port): Port this file.
-#if defined(TOOLKIT_VIEWS)
-#include "app/os_exchange_data.h"
-#else
-#include "chrome/common/temp_scaffolding_stubs.h"
-#endif
-
const char* BookmarkDragData::kClipboardFormatString =
"chromium/x-bookmark-entries";
-#if defined(OS_WIN)
-static CLIPFORMAT clipboard_format = 0;
-
-static void RegisterFormat() {
- if (clipboard_format == 0) {
- clipboard_format =
- ::RegisterClipboardFormat(ASCIIToWide(
- BookmarkDragData::kClipboardFormatString).c_str());
- DCHECK(clipboard_format);
- }
-}
-#endif
-
BookmarkDragData::Element::Element(const BookmarkNode* node)
: is_url(node->is_url()),
url(node->GetURL()),
@@ -84,6 +64,21 @@ bool BookmarkDragData::Element::ReadFromPickle(Pickle* pickle,
return true;
}
+#if defined(TOOLKIT_VIEWS)
+// static
+OSExchangeData::CustomFormat BookmarkDragData::GetBookmarkCustomFormat() {
+ static OSExchangeData::CustomFormat format;
+ static bool format_valid = false;
+
+ if (!format_valid) {
+ format_valid = true;
+ format = OSExchangeData::RegisterCustomFormat(
+ BookmarkDragData::kClipboardFormatString);
+ }
+ return format;
+}
+#endif
+
BookmarkDragData::BookmarkDragData(const BookmarkNode* node) {
elements.push_back(Element(node));
}
@@ -139,10 +134,8 @@ bool BookmarkDragData::ReadFromClipboard() {
}
#endif // !defined(OS_MACOSX)
-#if defined(OS_WIN)
+#if defined(TOOLKIT_VIEWS)
void BookmarkDragData::Write(Profile* profile, OSExchangeData* data) const {
- RegisterFormat();
-
DCHECK(data);
// If there is only one element and it is a URL, write the URL to the
@@ -158,19 +151,17 @@ void BookmarkDragData::Write(Profile* profile, OSExchangeData* data) const {
Pickle data_pickle;
WriteToPickle(profile, &data_pickle);
- data->SetPickledData(clipboard_format, data_pickle);
+ data->SetPickledData(GetBookmarkCustomFormat(), data_pickle);
}
bool BookmarkDragData::Read(const OSExchangeData& data) {
- RegisterFormat();
-
elements.clear();
profile_path_.clear();
- if (data.HasFormat(clipboard_format)) {
+ if (data.HasCustomFormat(GetBookmarkCustomFormat())) {
Pickle drag_data_pickle;
- if (data.GetPickledData(clipboard_format, &drag_data_pickle)) {
+ if (data.GetPickledData(GetBookmarkCustomFormat(), &drag_data_pickle)) {
if (!ReadFromPickle(&drag_data_pickle))
return false;
}
@@ -186,15 +177,6 @@ bool BookmarkDragData::Read(const OSExchangeData& data) {
return is_valid();
}
-#elif defined(TOOLKIT_VIEWS)
-void BookmarkDragData::Write(Profile* profile, OSExchangeData* data) const {
- NOTIMPLEMENTED();
-}
-
-bool BookmarkDragData::Read(const OSExchangeData& data) {
- NOTIMPLEMENTED();
- return false;
-}
#endif
void BookmarkDragData::WriteToPickle(Profile* profile, Pickle* pickle) const {
diff --git a/chrome/browser/bookmarks/bookmark_drag_data.h b/chrome/browser/bookmarks/bookmark_drag_data.h
index 815e8e1d..0b9736c 100644
--- a/chrome/browser/bookmarks/bookmark_drag_data.h
+++ b/chrome/browser/bookmarks/bookmark_drag_data.h
@@ -11,6 +11,13 @@
#include "chrome/browser/history/history.h"
#include "googleurl/src/gurl.h"
+// TODO(port): Port this file.
+#if defined(TOOLKIT_VIEWS)
+#include "app/os_exchange_data.h"
+#else
+#include "chrome/common/temp_scaffolding_stubs.h"
+#endif
+
class BookmarkModel;
class BookmarkNode;
class OSExchangeData;
@@ -67,6 +74,10 @@ struct BookmarkDragData {
BookmarkDragData() { }
+#if defined(TOOLKIT_VIEWS)
+ static OSExchangeData::CustomFormat GetBookmarkCustomFormat();
+#endif
+
// Created a BookmarkDragData populated from the arguments.
explicit BookmarkDragData(const BookmarkNode* node);
explicit BookmarkDragData(const std::vector<const BookmarkNode*>& nodes);
diff --git a/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc b/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc
index 02b2016..77d999a 100644
--- a/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "app/os_exchange_data.h"
+#include "app/os_exchange_data_provider_win.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/bookmarks/bookmark_drag_data.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
@@ -12,6 +13,15 @@
typedef testing::Test BookmarkDragDataTest;
+namespace {
+
+OSExchangeData::Provider* CloneProvider(const OSExchangeData& data) {
+ return new OSExchangeDataProviderWin(
+ OSExchangeDataProviderWin::GetIDataObject(data));
+}
+
+} // namespace
+
// Makes sure BookmarkDragData is initially invalid.
TEST_F(BookmarkDragDataTest, InitialState) {
BookmarkDragData data;
@@ -20,9 +30,9 @@ TEST_F(BookmarkDragDataTest, InitialState) {
// Makes sure reading bogus data leaves the BookmarkDragData invalid.
TEST_F(BookmarkDragDataTest, BogusRead) {
- scoped_refptr<OSExchangeData> data(new OSExchangeData());
+ OSExchangeData data;
BookmarkDragData drag_data;
- EXPECT_FALSE(drag_data.Read(OSExchangeData(data.get())));
+ EXPECT_FALSE(drag_data.Read(OSExchangeData(CloneProvider(data))));
EXPECT_FALSE(drag_data.is_valid());
}
@@ -32,11 +42,11 @@ TEST_F(BookmarkDragDataTest, JustURL) {
const GURL url("http://google.com");
const std::wstring title(L"title");
- scoped_refptr<OSExchangeData> data(new OSExchangeData());
- data->SetURL(url, title);
+ OSExchangeData data;
+ data.SetURL(url, title);
BookmarkDragData drag_data;
- EXPECT_TRUE(drag_data.Read(OSExchangeData(data.get())));
+ EXPECT_TRUE(drag_data.Read(OSExchangeData(CloneProvider(data))));
EXPECT_TRUE(drag_data.is_valid());
ASSERT_EQ(1, drag_data.elements.size());
EXPECT_TRUE(drag_data.elements[0].is_url);
@@ -61,13 +71,13 @@ TEST_F(BookmarkDragDataTest, URL) {
EXPECT_TRUE(drag_data.elements[0].is_url);
EXPECT_TRUE(drag_data.elements[0].url == url);
EXPECT_EQ(title, drag_data.elements[0].title);
- scoped_refptr<OSExchangeData> data(new OSExchangeData());
- drag_data.Write(&profile, data.get());
+ OSExchangeData data;
+ drag_data.Write(&profile, &data);
// Now read the data back in.
- scoped_refptr<OSExchangeData> data2(new OSExchangeData(data.get()));
+ OSExchangeData data2(CloneProvider(data));
BookmarkDragData read_data;
- EXPECT_TRUE(read_data.Read(*data2));
+ EXPECT_TRUE(read_data.Read(data2));
EXPECT_TRUE(read_data.is_valid());
ASSERT_EQ(1, read_data.elements.size());
EXPECT_TRUE(read_data.elements[0].is_url);
@@ -82,7 +92,7 @@ TEST_F(BookmarkDragDataTest, URL) {
// Writing should also put the URL and title on the clipboard.
GURL read_url;
std::wstring read_title;
- EXPECT_TRUE(data2->GetURLAndTitle(&read_url, &read_title));
+ EXPECT_TRUE(data2.GetURLAndTitle(&read_url, &read_title));
EXPECT_TRUE(read_url == url);
EXPECT_EQ(title, read_title);
}
@@ -104,13 +114,13 @@ TEST_F(BookmarkDragDataTest, Group) {
EXPECT_EQ(g12->GetTitle(), drag_data.elements[0].title);
EXPECT_FALSE(drag_data.elements[0].is_url);
- scoped_refptr<OSExchangeData> data(new OSExchangeData());
- drag_data.Write(&profile, data.get());
+ OSExchangeData data;
+ drag_data.Write(&profile, &data);
// Now read the data back in.
- scoped_refptr<OSExchangeData> data2(new OSExchangeData(data.get()));
+ OSExchangeData data2(CloneProvider(data));
BookmarkDragData read_data;
- EXPECT_TRUE(read_data.Read(*data2));
+ EXPECT_TRUE(read_data.Read(data2));
EXPECT_TRUE(read_data.is_valid());
ASSERT_EQ(1, read_data.elements.size());
EXPECT_EQ(g12->GetTitle(), read_data.elements[0].title);
@@ -141,13 +151,13 @@ TEST_F(BookmarkDragDataTest, GroupWithChild) {
BookmarkDragData drag_data(group);
- scoped_refptr<OSExchangeData> data(new OSExchangeData());
- drag_data.Write(&profile, data.get());
+ OSExchangeData data;
+ drag_data.Write(&profile, &data);
// Now read the data back in.
- scoped_refptr<OSExchangeData> data2(new OSExchangeData(data.get()));
+ OSExchangeData data2(CloneProvider(data));
BookmarkDragData read_data;
- EXPECT_TRUE(read_data.Read(*data2));
+ EXPECT_TRUE(read_data.Read(data2));
ASSERT_EQ(1, read_data.elements.size());
ASSERT_EQ(1, read_data.elements[0].children.size());
const BookmarkDragData::Element& read_child =
@@ -182,13 +192,13 @@ TEST_F(BookmarkDragDataTest, MultipleNodes) {
nodes.push_back(group);
nodes.push_back(url_node);
BookmarkDragData drag_data(nodes);
- scoped_refptr<OSExchangeData> data(new OSExchangeData());
- drag_data.Write(&profile, data.get());
+ OSExchangeData data;
+ drag_data.Write(&profile, &data);
// Read the data back in.
- scoped_refptr<OSExchangeData> data2(new OSExchangeData(data.get()));
+ OSExchangeData data2(CloneProvider(data));
BookmarkDragData read_data;
- EXPECT_TRUE(read_data.Read(*data2));
+ EXPECT_TRUE(read_data.Read(data2));
EXPECT_TRUE(read_data.is_valid());
ASSERT_EQ(2, read_data.elements.size());
ASSERT_EQ(1, read_data.elements[0].children.size());
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index 0d9b5a9..23f47c7 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -29,6 +29,7 @@
#endif
#if defined(OS_WIN)
+#include "app/os_exchange_data_provider_win.h"
#include "base/base_drag_source.h"
#include "views/drag_utils.h"
#endif
@@ -242,14 +243,15 @@ void DragDownload(const DownloadItem* download, SkBitmap* icon) {
DCHECK(download);
// Set up our OLE machinery
- scoped_refptr<OSExchangeData> data(new OSExchangeData);
+ OSExchangeData data;
const FilePath::StringType file_name = download->file_name().value();
if (icon)
- drag_utils::CreateDragImageForFile(file_name, icon, data);
+ drag_utils::CreateDragImageForFile(file_name, icon, &data);
+ data.SetFilename(download->full_path().ToWStringHack());
const FilePath full_path = download->full_path();
- data->SetFilename(full_path.value());
+ data.SetFilename(full_path.value());
std::string mime_type = download->mime_type();
if (mime_type.empty())
@@ -257,14 +259,14 @@ void DragDownload(const DownloadItem* download, SkBitmap* icon) {
// Add URL so that we can load supported files when dragged to TabContents.
if (net::IsSupportedMimeType(mime_type))
- data->SetURL(GURL(full_path.value()), file_name);
+ data.SetURL(GURL(full_path.value()), file_name);
scoped_refptr<BaseDragSource> drag_source(new BaseDragSource);
// Run the drag and drop loop
DWORD effects;
- DoDragDrop(data.get(), drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK,
- &effects);
+ DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source.get(),
+ DROPEFFECT_COPY | DROPEFFECT_LINK, &effects);
#else
NOTIMPLEMENTED();
#endif
diff --git a/chrome/browser/tab_contents/web_drop_target.cc b/chrome/browser/tab_contents/web_drop_target.cc
index bad7e1d..af39273 100644
--- a/chrome/browser/tab_contents/web_drop_target.cc
+++ b/chrome/browser/tab_contents/web_drop_target.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/tab_contents/web_drop_target.h"
#include "app/os_exchange_data.h"
+#include "app/os_exchange_data_provider_win.h"
#include "base/clipboard_util.h"
#include "base/gfx/point.h"
#include "chrome/browser/renderer_host/render_view_host.h"
@@ -104,7 +105,7 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
WebDropData::PopulateWebDropData(data_object, &drop_data);
if (drop_data.url.is_empty())
- OSExchangeData::GetPlainTextURL(data_object, &drop_data.url);
+ OSExchangeDataProviderWin::GetPlainTextURL(data_object, &drop_data.url);
is_drop_target_ = true;
diff --git a/chrome/browser/views/bookmark_folder_tree_view.cc b/chrome/browser/views/bookmark_folder_tree_view.cc
index bd464c8..74a6dea 100644
--- a/chrome/browser/views/bookmark_folder_tree_view.cc
+++ b/chrome/browser/views/bookmark_folder_tree_view.cc
@@ -8,6 +8,7 @@
#include "app/drag_drop_types.h"
#include "app/os_exchange_data.h"
+#include "app/os_exchange_data_provider_win.h"
#include "base/base_drag_source.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
@@ -125,12 +126,12 @@ void BookmarkFolderTreeView::BeginDrag(const BookmarkNode* node) {
std::vector<const BookmarkNode*> nodes_to_drag;
nodes_to_drag.push_back(node);
- scoped_refptr<OSExchangeData> data = new OSExchangeData;
- BookmarkDragData(nodes_to_drag).Write(profile_, data);
+ OSExchangeData data;
+ BookmarkDragData(nodes_to_drag).Write(profile_, &data);
scoped_refptr<BaseDragSource> drag_source(new BaseDragSource);
DWORD effects;
is_dragging_ = true;
- DoDragDrop(data, drag_source,
+ DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source,
DROPEFFECT_LINK | DROPEFFECT_COPY | DROPEFFECT_MOVE, &effects);
is_dragging_ = false;
}
diff --git a/chrome/browser/views/bookmark_table_view.cc b/chrome/browser/views/bookmark_table_view.cc
index 3eaa2f3..1ea3aa6 100644
--- a/chrome/browser/views/bookmark_table_view.cc
+++ b/chrome/browser/views/bookmark_table_view.cc
@@ -11,6 +11,7 @@
#include "app/gfx/font.h"
#include "app/l10n_util.h"
#include "app/os_exchange_data.h"
+#include "app/os_exchange_data_provider_win.h"
#include "app/resource_bundle.h"
#include "base/base_drag_source.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
@@ -197,11 +198,11 @@ void BookmarkTableView::BeginDrag() {
// We do this as SelectionBegin starts at the end of the visual order.
std::reverse(nodes_to_drag.begin(), nodes_to_drag.end());
- scoped_refptr<OSExchangeData> data = new OSExchangeData;
- BookmarkDragData(nodes_to_drag).Write(profile_, data);
+ OSExchangeData data;
+ BookmarkDragData(nodes_to_drag).Write(profile_, &data);
scoped_refptr<BaseDragSource> drag_source(new BaseDragSource);
DWORD effects;
- DoDragDrop(data, drag_source,
+ DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source,
DROPEFFECT_LINK | DROPEFFECT_COPY | DROPEFFECT_MOVE, &effects);
}
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
index 570df67..47a73e3 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
@@ -8,6 +8,7 @@
#include "app/gfx/canvas_paint.h"
#include "app/os_exchange_data.h"
+#include "app/os_exchange_data_provider_win.h"
#include "base/time.h"
#include "chrome/browser/bookmarks/bookmark_drag_data.h"
#include "chrome/browser/browser.h" // TODO(beng): this dependency is awful.
@@ -132,7 +133,7 @@ void TabContentsViewWin::GetContainerBounds(gfx::Rect* out) const {
}
void TabContentsViewWin::StartDragging(const WebDropData& drop_data) {
- scoped_refptr<OSExchangeData> data(new OSExchangeData);
+ OSExchangeData data;
// TODO(tc): Generate an appropriate drag image.
@@ -150,10 +151,10 @@ void TabContentsViewWin::StartDragging(const WebDropData& drop_data) {
net::GetSuggestedFilename(drop_data.url, "", "", L""));
}
file_name = file_name.ReplaceExtension(drop_data.file_extension);
- data->SetFileContents(file_name.value(), drop_data.file_contents);
+ data.SetFileContents(file_name.value(), drop_data.file_contents);
}
if (!drop_data.text_html.empty())
- data->SetHtml(drop_data.text_html, drop_data.html_base_url);
+ data.SetHtml(drop_data.text_html, drop_data.html_base_url);
if (drop_data.url.is_valid()) {
if (drop_data.url.SchemeIs(chrome::kJavaScriptScheme)) {
// We don't want to allow javascript URLs to be dragged to the desktop,
@@ -170,13 +171,13 @@ void TabContentsViewWin::StartDragging(const WebDropData& drop_data) {
// Pass in NULL as the profile so that the bookmark always adds the url
// rather than trying to move an existing url.
- bm_drag_data.Write(NULL, data);
+ bm_drag_data.Write(NULL, &data);
} else {
- data->SetURL(drop_data.url, drop_data.url_title);
+ data.SetURL(drop_data.url, drop_data.url_title);
}
}
if (!drop_data.plain_text.empty())
- data->SetString(drop_data.plain_text);
+ data.SetString(drop_data.plain_text);
drag_source_ = new WebDragSource(GetNativeView(), tab_contents());
@@ -186,7 +187,8 @@ void TabContentsViewWin::StartDragging(const WebDropData& drop_data) {
// updates while in the system DoDragDrop loop.
bool old_state = MessageLoop::current()->NestableTasksAllowed();
MessageLoop::current()->SetNestableTasksAllowed(true);
- DoDragDrop(data, drag_source_, DROPEFFECT_COPY | DROPEFFECT_LINK, &effects);
+ DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source_,
+ DROPEFFECT_COPY | DROPEFFECT_LINK, &effects);
MessageLoop::current()->SetNestableTasksAllowed(old_state);
drag_source_ = NULL;