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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 base::FilePath highlighted_file_path(FILE_PATH_LITERAL("//tmp/foo.html")); | 166 base::FilePath highlighted_file_path(FILE_PATH_LITERAL("//tmp/foo.html")); |
167 base::FilePath dragged_file_path(FILE_PATH_LITERAL("//tmp/image.jpg")); | 167 base::FilePath dragged_file_path(FILE_PATH_LITERAL("//tmp/image.jpg")); |
168 base::FilePath sensitive_file_path(FILE_PATH_LITERAL("//etc/passwd")); | 168 base::FilePath sensitive_file_path(FILE_PATH_LITERAL("//etc/passwd")); |
169 GURL highlighted_file_url = net::FilePathToFileURL(highlighted_file_path); | 169 GURL highlighted_file_url = net::FilePathToFileURL(highlighted_file_path); |
170 GURL dragged_file_url = net::FilePathToFileURL(dragged_file_path); | 170 GURL dragged_file_url = net::FilePathToFileURL(dragged_file_path); |
171 GURL sensitive_file_url = net::FilePathToFileURL(sensitive_file_path); | 171 GURL sensitive_file_url = net::FilePathToFileURL(sensitive_file_path); |
172 dropped_data.url = highlighted_file_url; | 172 dropped_data.url = highlighted_file_url; |
173 dropped_data.filenames.push_back( | 173 dropped_data.filenames.push_back( |
174 ui::FileInfo(dragged_file_path, base::FilePath())); | 174 ui::FileInfo(dragged_file_path, base::FilePath())); |
175 | 175 |
| 176 rvh()->FilterDropData(&dropped_data); |
176 rvh()->DragTargetDragEnter(dropped_data, client_point, screen_point, | 177 rvh()->DragTargetDragEnter(dropped_data, client_point, screen_point, |
177 blink::WebDragOperationNone, 0); | 178 blink::WebDragOperationNone, 0); |
178 | 179 |
179 int id = process()->GetID(); | 180 int id = process()->GetID(); |
180 ChildProcessSecurityPolicyImpl* policy = | 181 ChildProcessSecurityPolicyImpl* policy = |
181 ChildProcessSecurityPolicyImpl::GetInstance(); | 182 ChildProcessSecurityPolicyImpl::GetInstance(); |
182 | 183 |
| 184 // Permissions are not granted at DragEnter. |
183 EXPECT_FALSE(policy->CanRequestURL(id, highlighted_file_url)); | 185 EXPECT_FALSE(policy->CanRequestURL(id, highlighted_file_url)); |
184 EXPECT_FALSE(policy->CanReadFile(id, highlighted_file_path)); | 186 EXPECT_FALSE(policy->CanReadFile(id, highlighted_file_path)); |
185 EXPECT_TRUE(policy->CanRequestURL(id, dragged_file_url)); | 187 EXPECT_FALSE(policy->CanRequestURL(id, dragged_file_url)); |
186 EXPECT_TRUE(policy->CanReadFile(id, dragged_file_path)); | 188 EXPECT_FALSE(policy->CanReadFile(id, dragged_file_path)); |
187 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url)); | 189 EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url)); |
188 EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path)); | 190 EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path)); |
189 } | 191 } |
190 | 192 |
191 TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) { | 193 TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) { |
192 base::FilePath file_path; | 194 base::FilePath file_path; |
193 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); | 195 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); |
194 file_path = file_path.AppendASCII("foo"); | 196 file_path = file_path.AppendASCII("foo"); |
195 EXPECT_EQ(0, process()->bad_msg_count()); | 197 EXPECT_EQ(0, process()->bad_msg_count()); |
196 test_rvh()->TestOnUpdateStateWithFile(-1, file_path); | 198 test_rvh()->TestOnUpdateStateWithFile(-1, file_path); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 const std::string data_url = "data:image/gif;base64," | 305 const std::string data_url = "data:image/gif;base64," |
304 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; | 306 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; |
305 | 307 |
306 tester->Reset(); | 308 tester->Reset(); |
307 tester->Test(data_url); | 309 tester->Test(data_url); |
308 EXPECT_EQ(tester->UrlString(), data_url); | 310 EXPECT_EQ(tester->UrlString(), data_url); |
309 EXPECT_TRUE(tester->IsDownloaded()); | 311 EXPECT_TRUE(tester->IsDownloaded()); |
310 } | 312 } |
311 | 313 |
312 } // namespace content | 314 } // namespace content |
OLD | NEW |