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/renderer_host/render_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 #include "content/public/common/file_chooser_file_info.h" | 73 #include "content/public/common/file_chooser_file_info.h" |
74 #include "content/public/common/file_chooser_params.h" | 74 #include "content/public/common/file_chooser_params.h" |
75 #include "content/public/common/result_codes.h" | 75 #include "content/public/common/result_codes.h" |
76 #include "content/public/common/url_constants.h" | 76 #include "content/public/common/url_constants.h" |
77 #include "content/public/common/url_utils.h" | 77 #include "content/public/common/url_utils.h" |
78 #include "net/base/filename_util.h" | 78 #include "net/base/filename_util.h" |
79 #include "net/base/url_util.h" | 79 #include "net/base/url_util.h" |
80 #include "net/url_request/url_request_context_getter.h" | 80 #include "net/url_request/url_request_context_getter.h" |
81 #include "storage/browser/fileapi/isolated_context.h" | 81 #include "storage/browser/fileapi/isolated_context.h" |
82 #include "third_party/skia/include/core/SkBitmap.h" | 82 #include "third_party/skia/include/core/SkBitmap.h" |
| 83 #include "ui/base/clipboard/clipboard.h" |
83 #include "ui/base/touch/touch_device.h" | 84 #include "ui/base/touch/touch_device.h" |
84 #include "ui/base/touch/touch_enabled.h" | 85 #include "ui/base/touch/touch_enabled.h" |
85 #include "ui/base/ui_base_switches.h" | 86 #include "ui/base/ui_base_switches.h" |
86 #include "ui/gfx/animation/animation.h" | 87 #include "ui/gfx/animation/animation.h" |
87 #include "ui/gfx/image/image_skia.h" | 88 #include "ui/gfx/image/image_skia.h" |
88 #include "ui/gfx/native_widget_types.h" | 89 #include "ui/gfx/native_widget_types.h" |
89 #include "ui/native_theme/native_theme_switches.h" | 90 #include "ui/native_theme/native_theme_switches.h" |
90 #include "url/url_constants.h" | 91 #include "url/url_constants.h" |
91 | 92 |
92 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 gfx::win::GetSystemMetricsInDIP(SM_CXVSCROLL); | 158 gfx::win::GetSystemMetricsInDIP(SM_CXVSCROLL); |
158 prefs->horizontal_scroll_bar_height_in_dips = | 159 prefs->horizontal_scroll_bar_height_in_dips = |
159 gfx::win::GetSystemMetricsInDIP(SM_CYHSCROLL); | 160 gfx::win::GetSystemMetricsInDIP(SM_CYHSCROLL); |
160 prefs->arrow_bitmap_height_vertical_scroll_bar_in_dips = | 161 prefs->arrow_bitmap_height_vertical_scroll_bar_in_dips = |
161 gfx::win::GetSystemMetricsInDIP(SM_CYVSCROLL); | 162 gfx::win::GetSystemMetricsInDIP(SM_CYVSCROLL); |
162 prefs->arrow_bitmap_width_horizontal_scroll_bar_in_dips = | 163 prefs->arrow_bitmap_width_horizontal_scroll_bar_in_dips = |
163 gfx::win::GetSystemMetricsInDIP(SM_CXHSCROLL); | 164 gfx::win::GetSystemMetricsInDIP(SM_CXHSCROLL); |
164 } | 165 } |
165 #endif | 166 #endif |
166 | 167 |
| 168 void DropDataToMetaData(const DropData& drop_data, |
| 169 std::vector<MimeTypeKindPair>& meta_data) { |
| 170 base::string16 string_kind = base::ASCIIToUTF16("string"); |
| 171 base::string16 filename_kind = base::ASCIIToUTF16("filename"); |
| 172 base::string16 filesystemfile_kind = base::ASCIIToUTF16("filesystemfile"); |
| 173 if (!drop_data.text.is_null()) { |
| 174 MimeTypeKindPair pair = std::make_pair( |
| 175 base::ASCIIToUTF16(ui::Clipboard::kMimeTypeText), string_kind); |
| 176 meta_data.push_back(pair); |
| 177 } |
| 178 |
| 179 if (!drop_data.url.is_empty()) { |
| 180 MimeTypeKindPair pair = std::make_pair( |
| 181 base::ASCIIToUTF16(ui::Clipboard::kMimeTypeURIList), string_kind); |
| 182 meta_data.push_back(pair); |
| 183 } |
| 184 |
| 185 if (!drop_data.html.is_null()) { |
| 186 MimeTypeKindPair pair = std::make_pair( |
| 187 base::ASCIIToUTF16(ui::Clipboard::kMimeTypeHTML), string_kind); |
| 188 meta_data.push_back(pair); |
| 189 } |
| 190 |
| 191 for (std::vector<ui::FileInfo>::const_iterator it = |
| 192 drop_data.filenames.begin(); |
| 193 it != drop_data.filenames.end(); ++it) { |
| 194 if (!it->path.empty()) { |
| 195 MimeTypeKindPair pair = std::make_pair(base::string16(), filename_kind); |
| 196 meta_data.push_back(pair); |
| 197 } |
| 198 } |
| 199 |
| 200 for (std::vector<DropData::FileSystemFileInfo>::const_iterator it = |
| 201 drop_data.file_system_files.begin(); |
| 202 it != drop_data.file_system_files.end(); ++it) { |
| 203 if (!it->url.is_empty()) { |
| 204 MimeTypeKindPair pair = |
| 205 std::make_pair(base::string16(), filesystemfile_kind); |
| 206 meta_data.push_back(pair); |
| 207 } |
| 208 } |
| 209 |
| 210 for (std::map<base::string16, base::string16>::const_iterator it = |
| 211 drop_data.custom_data.begin(); |
| 212 it != drop_data.custom_data.end(); ++it) { |
| 213 MimeTypeKindPair pair = std::make_pair(it->first, string_kind); |
| 214 meta_data.push_back(pair); |
| 215 } |
| 216 } |
| 217 |
167 } // namespace | 218 } // namespace |
168 | 219 |
169 // static | 220 // static |
170 const int64_t RenderViewHostImpl::kUnloadTimeoutMS = 1000; | 221 const int64_t RenderViewHostImpl::kUnloadTimeoutMS = 1000; |
171 | 222 |
172 /////////////////////////////////////////////////////////////////////////////// | 223 /////////////////////////////////////////////////////////////////////////////// |
173 // RenderViewHost, public: | 224 // RenderViewHost, public: |
174 | 225 |
175 // static | 226 // static |
176 RenderViewHost* RenderViewHost::FromID(int render_process_id, | 227 RenderViewHost* RenderViewHost::FromID(int render_process_id, |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 policy->GrantReadFileSystem(renderer_id, filesystem_id); | 724 policy->GrantReadFileSystem(renderer_id, filesystem_id); |
674 | 725 |
675 // Note: We are using the origin URL provided by the sender here. It may be | 726 // Note: We are using the origin URL provided by the sender here. It may be |
676 // different from the receiver's. | 727 // different from the receiver's. |
677 filtered_data.file_system_files[i].url = | 728 filtered_data.file_system_files[i].url = |
678 GURL(storage::GetIsolatedFileSystemRootURIString( | 729 GURL(storage::GetIsolatedFileSystemRootURIString( |
679 file_system_url.origin(), filesystem_id, std::string()) | 730 file_system_url.origin(), filesystem_id, std::string()) |
680 .append(register_name)); | 731 .append(register_name)); |
681 } | 732 } |
682 | 733 |
683 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, | 734 std::vector<MimeTypeKindPair> meta_data; |
| 735 DropDataToMetaData(filtered_data, meta_data); |
| 736 Send(new DragMsg_TargetDragEnter(GetRoutingID(), meta_data, client_pt, |
684 screen_pt, operations_allowed, | 737 screen_pt, operations_allowed, |
685 key_modifiers)); | 738 key_modifiers)); |
686 } | 739 } |
687 | 740 |
688 void RenderViewHostImpl::DragTargetDragOver( | 741 void RenderViewHostImpl::DragTargetDragOver( |
689 const gfx::Point& client_pt, | 742 const gfx::Point& client_pt, |
690 const gfx::Point& screen_pt, | 743 const gfx::Point& screen_pt, |
691 WebDragOperationsMask operations_allowed, | 744 WebDragOperationsMask operations_allowed, |
692 int key_modifiers) { | 745 int key_modifiers) { |
693 Send(new DragMsg_TargetDragOver(GetRoutingID(), client_pt, screen_pt, | 746 Send(new DragMsg_TargetDragOver(GetRoutingID(), client_pt, screen_pt, |
694 operations_allowed, key_modifiers)); | 747 operations_allowed, key_modifiers)); |
695 } | 748 } |
696 | 749 |
697 void RenderViewHostImpl::DragTargetDragLeave() { | 750 void RenderViewHostImpl::DragTargetDragLeave() { |
698 Send(new DragMsg_TargetDragLeave(GetRoutingID())); | 751 Send(new DragMsg_TargetDragLeave(GetRoutingID())); |
699 } | 752 } |
700 | 753 |
701 void RenderViewHostImpl::DragTargetDrop( | 754 void RenderViewHostImpl::DragTargetDrop(const DropData& drop_data, |
702 const gfx::Point& client_pt, | 755 const gfx::Point& client_pt, |
703 const gfx::Point& screen_pt, | 756 const gfx::Point& screen_pt, |
704 int key_modifiers) { | 757 int key_modifiers) { |
705 Send(new DragMsg_TargetDrop(GetRoutingID(), client_pt, screen_pt, | 758 // TODO(hush): filter the drop_data like what's done in DragTargetDragEnter if |
| 759 // drop data is valid. |
| 760 Send(new DragMsg_TargetDrop(GetRoutingID(), drop_data, client_pt, screen_pt, |
706 key_modifiers)); | 761 key_modifiers)); |
707 } | 762 } |
708 | 763 |
709 void RenderViewHostImpl::DragSourceEndedAt( | 764 void RenderViewHostImpl::DragSourceEndedAt( |
710 int client_x, int client_y, int screen_x, int screen_y, | 765 int client_x, int client_y, int screen_x, int screen_y, |
711 WebDragOperation operation) { | 766 WebDragOperation operation) { |
712 Send(new DragMsg_SourceEnded(GetRoutingID(), | 767 Send(new DragMsg_SourceEnded(GetRoutingID(), |
713 gfx::Point(client_x, client_y), | 768 gfx::Point(client_x, client_y), |
714 gfx::Point(screen_x, screen_y), | 769 gfx::Point(screen_x, screen_y), |
715 operation)); | 770 operation)); |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 } else { | 1406 } else { |
1352 render_view_ready_on_process_launch_ = true; | 1407 render_view_ready_on_process_launch_ = true; |
1353 } | 1408 } |
1354 } | 1409 } |
1355 | 1410 |
1356 void RenderViewHostImpl::RenderViewReady() { | 1411 void RenderViewHostImpl::RenderViewReady() { |
1357 delegate_->RenderViewReady(this); | 1412 delegate_->RenderViewReady(this); |
1358 } | 1413 } |
1359 | 1414 |
1360 } // namespace content | 1415 } // namespace content |
OLD | NEW |