| 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 "chrome/browser/net/chrome_network_delegate.h" | 5 #include "chrome/browser/net/chrome_network_delegate.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 | 599 |
| 600 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 600 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 601 // Chrome OS and Android don't have access to random files. | 601 // Chrome OS and Android don't have access to random files. |
| 602 EXPECT_FALSE(IsAccessAllowed("/", "")); | 602 EXPECT_FALSE(IsAccessAllowed("/", "")); |
| 603 EXPECT_FALSE(IsAccessAllowed("/foo.txt", "")); | 603 EXPECT_FALSE(IsAccessAllowed("/foo.txt", "")); |
| 604 // Empty path should not be allowed. | 604 // Empty path should not be allowed. |
| 605 EXPECT_FALSE(IsAccessAllowed("", "")); | 605 EXPECT_FALSE(IsAccessAllowed("", "")); |
| 606 #endif | 606 #endif |
| 607 | 607 |
| 608 #if defined(OS_CHROMEOS) | 608 #if defined(OS_CHROMEOS) |
| 609 base::FilePath temp_dir; |
| 610 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &temp_dir)); |
| 609 // Chrome OS allows the following directories. | 611 // Chrome OS allows the following directories. |
| 610 EXPECT_TRUE(IsAccessAllowed("/home/chronos/user/Downloads", "")); | 612 EXPECT_TRUE(IsAccessAllowed("/home/chronos/user/Downloads", "")); |
| 611 EXPECT_TRUE(IsAccessAllowed("/home/chronos/user/log", "")); | 613 EXPECT_TRUE(IsAccessAllowed("/home/chronos/user/log", "")); |
| 612 EXPECT_TRUE(IsAccessAllowed("/home/chronos/user/WebRTC Logs", "")); | 614 EXPECT_TRUE(IsAccessAllowed("/home/chronos/user/WebRTC Logs", "")); |
| 613 EXPECT_TRUE(IsAccessAllowed("/media", "")); | 615 EXPECT_TRUE(IsAccessAllowed("/media", "")); |
| 614 EXPECT_TRUE(IsAccessAllowed("/opt/oem", "")); | 616 EXPECT_TRUE(IsAccessAllowed("/opt/oem", "")); |
| 615 EXPECT_TRUE(IsAccessAllowed("/usr/share/chromeos-assets", "")); | 617 EXPECT_TRUE(IsAccessAllowed("/usr/share/chromeos-assets", "")); |
| 616 EXPECT_TRUE(IsAccessAllowed("/tmp", "")); | 618 EXPECT_TRUE(IsAccessAllowed(temp_dir.AsUTF8Unsafe(), "")); |
| 617 EXPECT_TRUE(IsAccessAllowed("/var/log", "")); | 619 EXPECT_TRUE(IsAccessAllowed("/var/log", "")); |
| 618 // Files under the directories are allowed. | 620 // Files under the directories are allowed. |
| 619 EXPECT_TRUE(IsAccessAllowed("/tmp/foo.txt", "")); | 621 EXPECT_TRUE(IsAccessAllowed("/var/log/foo.txt", "")); |
| 620 // Make sure similar paths are not allowed. | 622 // Make sure similar paths are not allowed. |
| 621 EXPECT_FALSE(IsAccessAllowed("/home/chronos/user/log.txt", "")); | 623 EXPECT_FALSE(IsAccessAllowed("/home/chronos/user/log.txt", "")); |
| 622 EXPECT_FALSE(IsAccessAllowed("/home/chronos/user", "")); | 624 EXPECT_FALSE(IsAccessAllowed("/home/chronos/user", "")); |
| 623 EXPECT_FALSE(IsAccessAllowed("/home/chronos", "")); | 625 EXPECT_FALSE(IsAccessAllowed("/home/chronos", "")); |
| 624 | 626 |
| 625 // If profile path is given, the following additional paths are allowed. | 627 // If profile path is given, the following additional paths are allowed. |
| 626 EXPECT_TRUE(IsAccessAllowed("/profile/Downloads", "/profile")); | 628 EXPECT_TRUE(IsAccessAllowed("/profile/Downloads", "/profile")); |
| 627 EXPECT_TRUE(IsAccessAllowed("/profile/WebRTC Logs", "/profile")); | 629 EXPECT_TRUE(IsAccessAllowed("/profile/WebRTC Logs", "/profile")); |
| 628 | 630 |
| 629 #elif defined(OS_ANDROID) | 631 #elif defined(OS_ANDROID) |
| 630 // Android allows the following directories. | 632 // Android allows the following directories. |
| 631 EXPECT_TRUE(IsAccessAllowed("/sdcard", "")); | 633 EXPECT_TRUE(IsAccessAllowed("/sdcard", "")); |
| 632 EXPECT_TRUE(IsAccessAllowed("/mnt/sdcard", "")); | 634 EXPECT_TRUE(IsAccessAllowed("/mnt/sdcard", "")); |
| 633 // Files under the directories are allowed. | 635 // Files under the directories are allowed. |
| 634 EXPECT_TRUE(IsAccessAllowed("/sdcard/foo.txt", "")); | 636 EXPECT_TRUE(IsAccessAllowed("/sdcard/foo.txt", "")); |
| 635 // Make sure similar paths are not allowed. | 637 // Make sure similar paths are not allowed. |
| 636 EXPECT_FALSE(IsAccessAllowed("/mnt/sdcard.txt", "")); | 638 EXPECT_FALSE(IsAccessAllowed("/mnt/sdcard.txt", "")); |
| 637 EXPECT_FALSE(IsAccessAllowed("/mnt", "")); | 639 EXPECT_FALSE(IsAccessAllowed("/mnt", "")); |
| 638 | 640 |
| 639 // Files in external storage are allowed. | 641 // Files in external storage are allowed. |
| 640 base::FilePath external_storage_path; | 642 base::FilePath external_storage_path; |
| 641 PathService::Get(base::DIR_ANDROID_EXTERNAL_STORAGE, &external_storage_path); | 643 PathService::Get(base::DIR_ANDROID_EXTERNAL_STORAGE, &external_storage_path); |
| 642 EXPECT_TRUE(IsAccessAllowed( | 644 EXPECT_TRUE(IsAccessAllowed( |
| 643 external_storage_path.AppendASCII("foo.txt").AsUTF8Unsafe(), "")); | 645 external_storage_path.AppendASCII("foo.txt").AsUTF8Unsafe(), "")); |
| 644 // The external storage root itself is not allowed. | 646 // The external storage root itself is not allowed. |
| 645 EXPECT_FALSE(IsAccessAllowed(external_storage_path.AsUTF8Unsafe(), "")); | 647 EXPECT_FALSE(IsAccessAllowed(external_storage_path.AsUTF8Unsafe(), "")); |
| 646 #endif | 648 #endif |
| 647 } | 649 } |
| OLD | NEW |