OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/google/core/browser/google_util.h" | 5 #include "components/google/core/browser/google_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 return google_homepage_url.ReplaceComponents(replacements); | 140 return google_homepage_url.ReplaceComponents(replacements); |
141 } | 141 } |
142 | 142 |
143 GURL CommandLineGoogleBaseURL() { | 143 GURL CommandLineGoogleBaseURL() { |
144 // Unit tests may add command-line flags after the first call to this | 144 // Unit tests may add command-line flags after the first call to this |
145 // function, so we don't simply initialize a static |base_url| directly and | 145 // function, so we don't simply initialize a static |base_url| directly and |
146 // then unconditionally return it. | 146 // then unconditionally return it. |
147 CR_DEFINE_STATIC_LOCAL(std::string, switch_value, ()); | 147 CR_DEFINE_STATIC_LOCAL(std::string, switch_value, ()); |
148 CR_DEFINE_STATIC_LOCAL(GURL, base_url, ()); | 148 CR_DEFINE_STATIC_LOCAL(GURL, base_url, ()); |
149 std::string current_switch_value( | 149 std::string current_switch_value( |
150 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 150 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
151 switches::kGoogleBaseURL)); | 151 switches::kGoogleBaseURL)); |
152 if (current_switch_value != switch_value) { | 152 if (current_switch_value != switch_value) { |
153 switch_value = current_switch_value; | 153 switch_value = current_switch_value; |
154 base_url = url_fixer::FixupURL(switch_value, std::string()); | 154 base_url = url_fixer::FixupURL(switch_value, std::string()); |
155 if (!base_url.is_valid() || base_url.has_query() || base_url.has_ref()) | 155 if (!base_url.is_valid() || base_url.has_query() || base_url.has_ref()) |
156 base_url = GURL(); | 156 base_url = GURL(); |
157 } | 157 } |
158 return base_url; | 158 return base_url; |
159 } | 159 } |
160 | 160 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 bool IsYoutubeDomainUrl(const GURL& url, | 210 bool IsYoutubeDomainUrl(const GURL& url, |
211 SubdomainPermission subdomain_permission, | 211 SubdomainPermission subdomain_permission, |
212 PortPermission port_permission) { | 212 PortPermission port_permission) { |
213 return IsValidURL(url, port_permission) && | 213 return IsValidURL(url, port_permission) && |
214 IsValidHostName(url.host(), "youtube", subdomain_permission); | 214 IsValidHostName(url.host(), "youtube", subdomain_permission); |
215 } | 215 } |
216 | 216 |
217 } // namespace google_util | 217 } // namespace google_util |
OLD | NEW |