| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "content/browser/renderer_host/dip_util.h" | 8 #include "content/browser/renderer_host/dip_util.h" |
| 9 #include "content/browser/renderer_host/render_view_host_factory.h" | 9 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 10 #include "content/browser/web_contents/interstitial_page_impl.h" | 10 #include "content/browser/web_contents/interstitial_page_impl.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 WebContentsImpl* contents_; | 89 WebContentsImpl* contents_; |
| 90 | 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(WebDragSourceAura); | 91 DISALLOW_COPY_AND_ASSIGN(WebDragSourceAura); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 // Utility to fill a ui::OSExchangeDataProviderAura object from WebDropData. | 94 // Utility to fill a ui::OSExchangeDataProviderAura object from WebDropData. |
| 95 void PrepareDragData(const WebDropData& drop_data, | 95 void PrepareDragData(const WebDropData& drop_data, |
| 96 ui::OSExchangeDataProviderAura* provider) { | 96 ui::OSExchangeDataProviderAura* provider) { |
| 97 if (!drop_data.plain_text.empty()) | 97 if (!drop_data.text.string().empty()) |
| 98 provider->SetString(drop_data.plain_text); | 98 provider->SetString(drop_data.text.string()); |
| 99 if (drop_data.url.is_valid()) | 99 if (drop_data.url.is_valid()) |
| 100 provider->SetURL(drop_data.url, drop_data.url_title); | 100 provider->SetURL(drop_data.url, drop_data.url_title); |
| 101 if (!drop_data.text_html.empty()) | 101 if (!drop_data.html.string().empty()) |
| 102 provider->SetHtml(drop_data.text_html, drop_data.html_base_url); | 102 provider->SetHtml(drop_data.html.string(), drop_data.html_base_url); |
| 103 if (!drop_data.filenames.empty()) { | 103 if (!drop_data.filenames.empty()) { |
| 104 std::vector<ui::OSExchangeData::FileInfo> filenames; | 104 std::vector<ui::OSExchangeData::FileInfo> filenames; |
| 105 for (std::vector<WebDropData::FileInfo>::const_iterator it = | 105 for (std::vector<WebDropData::FileInfo>::const_iterator it = |
| 106 drop_data.filenames.begin(); | 106 drop_data.filenames.begin(); |
| 107 it != drop_data.filenames.end(); ++it) { | 107 it != drop_data.filenames.end(); ++it) { |
| 108 filenames.push_back( | 108 filenames.push_back( |
| 109 ui::OSExchangeData::FileInfo( | 109 ui::OSExchangeData::FileInfo( |
| 110 FilePath::FromUTF8Unsafe(UTF16ToUTF8(it->path)), | 110 FilePath::FromUTF8Unsafe(UTF16ToUTF8(it->path)), |
| 111 FilePath::FromUTF8Unsafe(UTF16ToUTF8(it->display_name)))); | 111 FilePath::FromUTF8Unsafe(UTF16ToUTF8(it->display_name)))); |
| 112 } | 112 } |
| 113 provider->SetFilenames(filenames); | 113 provider->SetFilenames(filenames); |
| 114 } | 114 } |
| 115 if (!drop_data.custom_data.empty()) { | 115 if (!drop_data.custom_data.empty()) { |
| 116 Pickle pickle; | 116 Pickle pickle; |
| 117 ui::WriteCustomDataToPickle(drop_data.custom_data, &pickle); | 117 ui::WriteCustomDataToPickle(drop_data.custom_data, &pickle); |
| 118 provider->SetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), | 118 provider->SetPickledData(ui::Clipboard::GetWebCustomDataFormatType(), |
| 119 pickle); | 119 pickle); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Utility to fill a WebDropData object from ui::OSExchangeData. | 123 // Utility to fill a WebDropData object from ui::OSExchangeData. |
| 124 void PrepareWebDropData(WebDropData* drop_data, | 124 void PrepareWebDropData(WebDropData* drop_data, |
| 125 const ui::OSExchangeData& data) { | 125 const ui::OSExchangeData& data) { |
| 126 string16 plain_text, url_title; | 126 string16 plain_text; |
| 127 GURL url; | |
| 128 | |
| 129 data.GetString(&plain_text); | 127 data.GetString(&plain_text); |
| 130 if (!plain_text.empty()) | 128 if (!plain_text.empty()) |
| 131 drop_data->plain_text = plain_text; | 129 drop_data->text = NullableString16(plain_text, false); |
| 132 | 130 |
| 131 GURL url; |
| 132 string16 url_title; |
| 133 data.GetURLAndTitle(&url, &url_title); | 133 data.GetURLAndTitle(&url, &url_title); |
| 134 if (url.is_valid()) { | 134 if (url.is_valid()) { |
| 135 drop_data->url = url; | 135 drop_data->url = url; |
| 136 drop_data->url_title = url_title; | 136 drop_data->url_title = url_title; |
| 137 } | 137 } |
| 138 | 138 |
| 139 data.GetHtml(&drop_data->text_html, &drop_data->html_base_url); | 139 string16 html; |
| 140 GURL html_base_url; |
| 141 data.GetHtml(&html, &html_base_url); |
| 142 if (!html.empty()) |
| 143 drop_data->html = NullableString16(html, false); |
| 144 if (html_base_url.is_valid()) |
| 145 drop_data->html_base_url = html_base_url; |
| 140 | 146 |
| 141 std::vector<ui::OSExchangeData::FileInfo> files; | 147 std::vector<ui::OSExchangeData::FileInfo> files; |
| 142 if (data.GetFilenames(&files) && !files.empty()) { | 148 if (data.GetFilenames(&files) && !files.empty()) { |
| 143 for (std::vector<ui::OSExchangeData::FileInfo>::const_iterator | 149 for (std::vector<ui::OSExchangeData::FileInfo>::const_iterator |
| 144 it = files.begin(); it != files.end(); ++it) { | 150 it = files.begin(); it != files.end(); ++it) { |
| 145 drop_data->filenames.push_back( | 151 drop_data->filenames.push_back( |
| 146 WebDropData::FileInfo( | 152 WebDropData::FileInfo( |
| 147 UTF8ToUTF16(it->path.AsUTF8Unsafe()), | 153 UTF8ToUTF16(it->path.AsUTF8Unsafe()), |
| 148 UTF8ToUTF16(it->display_name.AsUTF8Unsafe()))); | 154 UTF8ToUTF16(it->display_name.AsUTF8Unsafe()))); |
| 149 } | 155 } |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 OnDragEntered(event); | 622 OnDragEntered(event); |
| 617 | 623 |
| 618 web_contents_->GetRenderViewHost()->DragTargetDrop( | 624 web_contents_->GetRenderViewHost()->DragTargetDrop( |
| 619 event.location(), | 625 event.location(), |
| 620 GetNativeView()->GetRootWindow()->last_mouse_location(), | 626 GetNativeView()->GetRootWindow()->last_mouse_location(), |
| 621 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 627 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 622 if (drag_dest_delegate_) | 628 if (drag_dest_delegate_) |
| 623 drag_dest_delegate_->OnDrop(); | 629 drag_dest_delegate_->OnDrop(); |
| 624 return current_drag_op_; | 630 return current_drag_op_; |
| 625 } | 631 } |
| OLD | NEW |