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/google/google_util.h" | 5 #include "chrome/browser/google/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 "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/common/net/url_fixer_upper.h" | |
18 #include "components/google/core/browser/google_switches.h" | 17 #include "components/google/core/browser/google_switches.h" |
19 #include "components/google/core/browser/google_url_tracker.h" | 18 #include "components/google/core/browser/google_url_tracker.h" |
| 19 #include "components/url_fixer/url_fixer.h" |
20 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 20 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
21 #include "net/base/url_util.h" | 21 #include "net/base/url_util.h" |
22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
23 | 23 |
24 // Only use Link Doctor on official builds. It uses an API key, too, but | 24 // Only use Link Doctor on official builds. It uses an API key, too, but |
25 // seems best to just disable it, for more responsive error pages and to reduce | 25 // seems best to just disable it, for more responsive error pages and to reduce |
26 // server load. | 26 // server load. |
27 #if defined(GOOGLE_CHROME_BUILD) | 27 #if defined(GOOGLE_CHROME_BUILD) |
28 #define LINKDOCTOR_SERVER_REQUEST_URL "https://www.googleapis.com/rpc" | 28 #define LINKDOCTOR_SERVER_REQUEST_URL "https://www.googleapis.com/rpc" |
29 #else | 29 #else |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // Unit tests may add command-line flags after the first call to this | 123 // Unit tests may add command-line flags after the first call to this |
124 // function, so we don't simply initialize a static |base_url| directly and | 124 // function, so we don't simply initialize a static |base_url| directly and |
125 // then unconditionally return it. | 125 // then unconditionally return it. |
126 CR_DEFINE_STATIC_LOCAL(std::string, switch_value, ()); | 126 CR_DEFINE_STATIC_LOCAL(std::string, switch_value, ()); |
127 CR_DEFINE_STATIC_LOCAL(GURL, base_url, ()); | 127 CR_DEFINE_STATIC_LOCAL(GURL, base_url, ()); |
128 std::string current_switch_value( | 128 std::string current_switch_value( |
129 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 129 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
130 switches::kGoogleBaseURL)); | 130 switches::kGoogleBaseURL)); |
131 if (current_switch_value != switch_value) { | 131 if (current_switch_value != switch_value) { |
132 switch_value = current_switch_value; | 132 switch_value = current_switch_value; |
133 base_url = URLFixerUpper::FixupURL(switch_value, std::string()); | 133 base_url = url_fixer::FixupURL(switch_value, std::string()); |
134 if (!base_url.is_valid() || base_url.has_query() || base_url.has_ref()) | 134 if (!base_url.is_valid() || base_url.has_query() || base_url.has_ref()) |
135 base_url = GURL(); | 135 base_url = GURL(); |
136 } | 136 } |
137 return base_url; | 137 return base_url; |
138 } | 138 } |
139 | 139 |
140 bool StartsWithCommandLineGoogleBaseURL(const GURL& url) { | 140 bool StartsWithCommandLineGoogleBaseURL(const GURL& url) { |
141 GURL base_url(CommandLineGoogleBaseURL()); | 141 GURL base_url(CommandLineGoogleBaseURL()); |
142 return base_url.is_valid() && | 142 return base_url.is_valid() && |
143 StartsWithASCII(url.possibly_invalid_spec(), base_url.spec(), true); | 143 StartsWithASCII(url.possibly_invalid_spec(), base_url.spec(), true); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 if (!is_home_page_base && (path != "/search")) | 192 if (!is_home_page_base && (path != "/search")) |
193 return false; | 193 return false; |
194 | 194 |
195 // Check for query parameter in URL parameter and hash fragment, depending on | 195 // Check for query parameter in URL parameter and hash fragment, depending on |
196 // the path type. | 196 // the path type. |
197 return HasGoogleSearchQueryParam(url.ref()) || | 197 return HasGoogleSearchQueryParam(url.ref()) || |
198 (!is_home_page_base && HasGoogleSearchQueryParam(url.query())); | 198 (!is_home_page_base && HasGoogleSearchQueryParam(url.query())); |
199 } | 199 } |
200 | 200 |
201 } // namespace google_util | 201 } // namespace google_util |
OLD | NEW |