OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_frame/navigation_constraints.h" | 5 #include "chrome_frame/navigation_constraints.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 #include "chrome_frame/utils.h" | 10 #include "chrome_frame/utils.h" |
11 #include "extensions/common/constants.h" | 11 #include "extensions/common/constants.h" |
12 | 12 |
13 NavigationConstraintsImpl::NavigationConstraintsImpl() : is_privileged_(false) { | 13 NavigationConstraintsImpl::NavigationConstraintsImpl() : is_privileged_(false) { |
14 } | 14 } |
15 | 15 |
16 // NavigationConstraintsImpl method definitions. | 16 // NavigationConstraintsImpl method definitions. |
17 bool NavigationConstraintsImpl::AllowUnsafeUrls() { | 17 bool NavigationConstraintsImpl::AllowUnsafeUrls() { |
18 // No sanity checks if unsafe URLs are allowed | 18 // No sanity checks if unsafe URLs are allowed |
19 return GetConfigBool(false, kAllowUnsafeURLs); | 19 return GetConfigBool(false, kAllowUnsafeURLs); |
20 } | 20 } |
21 | 21 |
22 bool NavigationConstraintsImpl::IsSchemeAllowed(const GURL& url) { | 22 bool NavigationConstraintsImpl::IsSchemeAllowed(const GURL& url) { |
23 if (url.is_empty()) | 23 if (url.is_empty()) |
24 return false; | 24 return false; |
25 | 25 |
26 if (!url.is_valid()) | 26 if (!url.is_valid()) |
27 return false; | 27 return false; |
28 | 28 |
29 if (url.SchemeIs(chrome::kHttpScheme) || url.SchemeIs(content::kHttpsScheme)) | 29 if (url.SchemeIs(content::kHttpScheme) || url.SchemeIs(content::kHttpsScheme)) |
30 return true; | 30 return true; |
31 | 31 |
32 // Additional checking for view-source. Allow only http and https | 32 // Additional checking for view-source. Allow only http and https |
33 // URLs in view source. | 33 // URLs in view source. |
34 if (url.SchemeIs(content::kViewSourceScheme)) { | 34 if (url.SchemeIs(content::kViewSourceScheme)) { |
35 GURL sub_url(url.path()); | 35 GURL sub_url(url.path()); |
36 if (sub_url.SchemeIs(chrome::kHttpScheme) || | 36 if (sub_url.SchemeIs(content::kHttpScheme) || |
37 sub_url.SchemeIs(content::kHttpsScheme)) | 37 sub_url.SchemeIs(content::kHttpsScheme)) |
38 return true; | 38 return true; |
39 } | 39 } |
40 | 40 |
41 // Allow only about:blank or about:version | 41 // Allow only about:blank or about:version |
42 if (url.SchemeIs(chrome::kAboutScheme)) { | 42 if (url.SchemeIs(chrome::kAboutScheme)) { |
43 if (LowerCaseEqualsASCII(url.spec(), content::kAboutBlankURL) || | 43 if (LowerCaseEqualsASCII(url.spec(), content::kAboutBlankURL) || |
44 LowerCaseEqualsASCII(url.spec(), chrome::kAboutVersionURL)) { | 44 LowerCaseEqualsASCII(url.spec(), chrome::kAboutVersionURL)) { |
45 return true; | 45 return true; |
46 } | 46 } |
(...skipping 30 matching lines...) Expand all Loading... |
77 return true; | 77 return true; |
78 } | 78 } |
79 | 79 |
80 bool NavigationConstraintsImpl::is_privileged() const { | 80 bool NavigationConstraintsImpl::is_privileged() const { |
81 return is_privileged_; | 81 return is_privileged_; |
82 } | 82 } |
83 | 83 |
84 void NavigationConstraintsImpl::set_is_privileged(bool is_privileged) { | 84 void NavigationConstraintsImpl::set_is_privileged(bool is_privileged) { |
85 is_privileged_ = is_privileged; | 85 is_privileged_ = is_privileged; |
86 } | 86 } |
OLD | NEW |