| 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/url_fixer_upper.h" | 5 #include "chrome/browser/net/url_fixer_upper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 #else | 96 #else |
| 97 TrimWhitespaceUTF8(text.value(), TRIM_ALL, output); | 97 TrimWhitespaceUTF8(text.value(), TRIM_ALL, output); |
| 98 #endif | 98 #endif |
| 99 } | 99 } |
| 100 | 100 |
| 101 // Tries to create a full path from |text|. If the result is valid and the | 101 // Tries to create a full path from |text|. If the result is valid and the |
| 102 // file exists, returns true and sets |full_path| to the result. Otherwise, | 102 // file exists, returns true and sets |full_path| to the result. Otherwise, |
| 103 // returns false and leaves |full_path| unchanged. | 103 // returns false and leaves |full_path| unchanged. |
| 104 bool ValidPathForFile(const base::FilePath::StringType& text, | 104 bool ValidPathForFile(const base::FilePath::StringType& text, |
| 105 base::FilePath* full_path) { | 105 base::FilePath* full_path) { |
| 106 base::FilePath file_path(text); | 106 base::FilePath file_path = base::MakeAbsoluteFilePath(base::FilePath(text)); |
| 107 if (!file_util::AbsolutePath(&file_path)) | 107 if (file_path.empty()) |
| 108 return false; | 108 return false; |
| 109 | 109 |
| 110 if (!file_util::PathExists(file_path)) | 110 if (!file_util::PathExists(file_path)) |
| 111 return false; | 111 return false; |
| 112 | 112 |
| 113 *full_path = file_path; | 113 *full_path = file_path; |
| 114 return true; | 114 return true; |
| 115 } | 115 } |
| 116 | 116 |
| 117 #if defined(OS_POSIX) | 117 #if defined(OS_POSIX) |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 | 633 |
| 634 if (part->is_valid()) { | 634 if (part->is_valid()) { |
| 635 // Offset the location of this component. | 635 // Offset the location of this component. |
| 636 part->begin += offset; | 636 part->begin += offset; |
| 637 | 637 |
| 638 // This part might not have existed in the original text. | 638 // This part might not have existed in the original text. |
| 639 if (part->begin < 0) | 639 if (part->begin < 0) |
| 640 part->reset(); | 640 part->reset(); |
| 641 } | 641 } |
| 642 } | 642 } |
| OLD | NEW |