Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: components/google/core/browser/google_util.cc

Issue 1171333003: Move net::FormatUrl and friends outside of //net and into //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again now that CQ is fixed Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/google/core/browser/BUILD.gn ('k') | components/history.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "components/google/core/browser/google_switches.h" 16 #include "components/google/core/browser/google_switches.h"
17 #include "components/google/core/browser/google_url_tracker.h" 17 #include "components/google/core/browser/google_url_tracker.h"
18 #include "components/url_fixer/url_fixer.h" 18 #include "components/url_formatter/url_fixer.h"
19 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 19 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
20 #include "net/base/url_util.h" 20 #include "net/base/url_util.h"
21 #include "url/gurl.h" 21 #include "url/gurl.h"
22 22
23 // Only use Link Doctor on official builds. It uses an API key, too, but 23 // Only use Link Doctor on official builds. It uses an API key, too, but
24 // seems best to just disable it, for more responsive error pages and to reduce 24 // seems best to just disable it, for more responsive error pages and to reduce
25 // server load. 25 // server load.
26 #if defined(GOOGLE_CHROME_BUILD) 26 #if defined(GOOGLE_CHROME_BUILD)
27 #define LINKDOCTOR_SERVER_REQUEST_URL "https://www.googleapis.com/rpc" 27 #define LINKDOCTOR_SERVER_REQUEST_URL "https://www.googleapis.com/rpc"
28 #else 28 #else
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // Unit tests may add command-line flags after the first call to this 146 // Unit tests may add command-line flags after the first call to this
147 // function, so we don't simply initialize a static |base_url| directly and 147 // function, so we don't simply initialize a static |base_url| directly and
148 // then unconditionally return it. 148 // then unconditionally return it.
149 CR_DEFINE_STATIC_LOCAL(std::string, switch_value, ()); 149 CR_DEFINE_STATIC_LOCAL(std::string, switch_value, ());
150 CR_DEFINE_STATIC_LOCAL(GURL, base_url, ()); 150 CR_DEFINE_STATIC_LOCAL(GURL, base_url, ());
151 std::string current_switch_value( 151 std::string current_switch_value(
152 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 152 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
153 switches::kGoogleBaseURL)); 153 switches::kGoogleBaseURL));
154 if (current_switch_value != switch_value) { 154 if (current_switch_value != switch_value) {
155 switch_value = current_switch_value; 155 switch_value = current_switch_value;
156 base_url = url_fixer::FixupURL(switch_value, std::string()); 156 base_url = url_formatter::FixupURL(switch_value, std::string());
157 if (!base_url.is_valid() || base_url.has_query() || base_url.has_ref()) 157 if (!base_url.is_valid() || base_url.has_query() || base_url.has_ref())
158 base_url = GURL(); 158 base_url = GURL();
159 } 159 }
160 return base_url; 160 return base_url;
161 } 161 }
162 162
163 bool StartsWithCommandLineGoogleBaseURL(const GURL& url) { 163 bool StartsWithCommandLineGoogleBaseURL(const GURL& url) {
164 GURL base_url(CommandLineGoogleBaseURL()); 164 GURL base_url(CommandLineGoogleBaseURL());
165 return base_url.is_valid() && 165 return base_url.is_valid() &&
166 base::StartsWith(url.possibly_invalid_spec(), base_url.spec(), 166 base::StartsWith(url.possibly_invalid_spec(), base_url.spec(),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 213
214 bool IsYoutubeDomainUrl(const GURL& url, 214 bool IsYoutubeDomainUrl(const GURL& url,
215 SubdomainPermission subdomain_permission, 215 SubdomainPermission subdomain_permission,
216 PortPermission port_permission) { 216 PortPermission port_permission) {
217 return IsValidURL(url, port_permission) && 217 return IsValidURL(url, port_permission) &&
218 IsValidHostName(url.host(), "youtube", subdomain_permission); 218 IsValidHostName(url.host(), "youtube", subdomain_permission);
219 } 219 }
220 220
221 } // namespace google_util 221 } // namespace google_util
OLDNEW
« no previous file with comments | « components/google/core/browser/BUILD.gn ('k') | components/history.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698