| 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 "base/path_service.h" | 5 #include "base/path_service.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/browser/child_process_security_policy_impl.h" | 7 #include "content/browser/child_process_security_policy_impl.h" |
| 8 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
| 9 #include "content/common/input_messages.h" | 9 #include "content/common/input_messages.h" |
| 10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 public: | 118 public: |
| 119 virtual ~MockDraggingRenderViewHostDelegateView() {} | 119 virtual ~MockDraggingRenderViewHostDelegateView() {} |
| 120 virtual void ShowPopupMenu(const gfx::Rect& bounds, | 120 virtual void ShowPopupMenu(const gfx::Rect& bounds, |
| 121 int item_height, | 121 int item_height, |
| 122 double item_font_size, | 122 double item_font_size, |
| 123 int selected_item, | 123 int selected_item, |
| 124 const std::vector<MenuItem>& items, | 124 const std::vector<MenuItem>& items, |
| 125 bool right_aligned, | 125 bool right_aligned, |
| 126 bool allow_multiple_selection) OVERRIDE {} | 126 bool allow_multiple_selection) OVERRIDE {} |
| 127 virtual void StartDragging(const DropData& drop_data, | 127 virtual void StartDragging(const DropData& drop_data, |
| 128 WebKit::WebDragOperationsMask allowed_ops, | 128 blink::WebDragOperationsMask allowed_ops, |
| 129 const gfx::ImageSkia& image, | 129 const gfx::ImageSkia& image, |
| 130 const gfx::Vector2d& image_offset, | 130 const gfx::Vector2d& image_offset, |
| 131 const DragEventSourceInfo& event_info) OVERRIDE { | 131 const DragEventSourceInfo& event_info) OVERRIDE { |
| 132 drag_url_ = drop_data.url; | 132 drag_url_ = drop_data.url; |
| 133 html_base_url_ = drop_data.html_base_url; | 133 html_base_url_ = drop_data.html_base_url; |
| 134 } | 134 } |
| 135 virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE {} | 135 virtual void UpdateDragCursor(blink::WebDragOperation operation) OVERRIDE {} |
| 136 virtual void GotFocus() OVERRIDE {} | 136 virtual void GotFocus() OVERRIDE {} |
| 137 virtual void TakeFocus(bool reverse) OVERRIDE {} | 137 virtual void TakeFocus(bool reverse) OVERRIDE {} |
| 138 virtual void UpdatePreferredSize(const gfx::Size& pref_size) {} | 138 virtual void UpdatePreferredSize(const gfx::Size& pref_size) {} |
| 139 | 139 |
| 140 GURL drag_url() { | 140 GURL drag_url() { |
| 141 return drag_url_; | 141 return drag_url_; |
| 142 } | 142 } |
| 143 | 143 |
| 144 GURL html_base_url() { | 144 GURL html_base_url() { |
| 145 return html_base_url_; | 145 return html_base_url_; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 base::FilePath dragged_file_path(FILE_PATH_LITERAL("//tmp/image.jpg")); | 195 base::FilePath dragged_file_path(FILE_PATH_LITERAL("//tmp/image.jpg")); |
| 196 base::FilePath sensitive_file_path(FILE_PATH_LITERAL("//etc/passwd")); | 196 base::FilePath sensitive_file_path(FILE_PATH_LITERAL("//etc/passwd")); |
| 197 GURL highlighted_file_url = net::FilePathToFileURL(highlighted_file_path); | 197 GURL highlighted_file_url = net::FilePathToFileURL(highlighted_file_path); |
| 198 GURL dragged_file_url = net::FilePathToFileURL(dragged_file_path); | 198 GURL dragged_file_url = net::FilePathToFileURL(dragged_file_path); |
| 199 GURL sensitive_file_url = net::FilePathToFileURL(sensitive_file_path); | 199 GURL sensitive_file_url = net::FilePathToFileURL(sensitive_file_path); |
| 200 dropped_data.url = highlighted_file_url; | 200 dropped_data.url = highlighted_file_url; |
| 201 dropped_data.filenames.push_back(DropData::FileInfo( | 201 dropped_data.filenames.push_back(DropData::FileInfo( |
| 202 UTF8ToUTF16(dragged_file_path.AsUTF8Unsafe()), string16())); | 202 UTF8ToUTF16(dragged_file_path.AsUTF8Unsafe()), string16())); |
| 203 | 203 |
| 204 rvh()->DragTargetDragEnter(dropped_data, client_point, screen_point, | 204 rvh()->DragTargetDragEnter(dropped_data, client_point, screen_point, |
| 205 WebKit::WebDragOperationNone, 0); | 205 blink::WebDragOperationNone, 0); |
| 206 | 206 |
| 207 int id = process()->GetID(); | 207 int id = process()->GetID(); |
| 208 ChildProcessSecurityPolicyImpl* policy = | 208 ChildProcessSecurityPolicyImpl* policy = |
| 209 ChildProcessSecurityPolicyImpl::GetInstance(); | 209 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 210 | 210 |
| 211 EXPECT_FALSE(policy->CanRequestURL(id, highlighted_file_url)); | 211 EXPECT_FALSE(policy->CanRequestURL(id, highlighted_file_url)); |
| 212 EXPECT_FALSE(policy->CanReadFile(id, highlighted_file_path)); | 212 EXPECT_FALSE(policy->CanReadFile(id, highlighted_file_path)); |
| 213 EXPECT_TRUE(policy->CanRequestURL(id, dragged_file_url)); | 213 EXPECT_TRUE(policy->CanRequestURL(id, dragged_file_url)); |
| 214 EXPECT_TRUE(policy->CanReadFile(id, dragged_file_path)); | 214 EXPECT_TRUE(policy->CanReadFile(id, dragged_file_path)); |
| 215 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url)); | 215 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url)); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 288 } |
| 289 | 289 |
| 290 TEST_F(RenderViewHostTest, RoutingIdSane) { | 290 TEST_F(RenderViewHostTest, RoutingIdSane) { |
| 291 EXPECT_EQ(test_rvh()->GetProcess(), | 291 EXPECT_EQ(test_rvh()->GetProcess(), |
| 292 test_rvh()->main_render_frame_host()->GetProcess()); | 292 test_rvh()->main_render_frame_host()->GetProcess()); |
| 293 EXPECT_NE(test_rvh()->GetRoutingID(), | 293 EXPECT_NE(test_rvh()->GetRoutingID(), |
| 294 test_rvh()->main_render_frame_host()->routing_id()); | 294 test_rvh()->main_render_frame_host()->routing_id()); |
| 295 } | 295 } |
| 296 | 296 |
| 297 } // namespace content | 297 } // namespace content |
| OLD | NEW |