Chromium Code Reviews| 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 "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_fixer/url_fixer.h" |
| 19 #include "content/public/browser/navigation_entry.h" | |
| 19 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 20 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 20 #include "net/base/url_util.h" | 21 #include "net/base/url_util.h" |
| 21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 22 | 23 |
| 23 // 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 |
| 24 // 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 |
| 25 // server load. | 26 // server load. |
| 26 #if defined(GOOGLE_CHROME_BUILD) | 27 #if defined(GOOGLE_CHROME_BUILD) |
| 27 #define LINKDOCTOR_SERVER_REQUEST_URL "https://www.googleapis.com/rpc" | 28 #define LINKDOCTOR_SERVER_REQUEST_URL "https://www.googleapis.com/rpc" |
| 28 #else | 29 #else |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 (!is_home_page_base && HasGoogleSearchQueryParam(url.query())); | 208 (!is_home_page_base && HasGoogleSearchQueryParam(url.query())); |
| 208 } | 209 } |
| 209 | 210 |
| 210 bool IsYoutubeDomainUrl(const GURL& url, | 211 bool IsYoutubeDomainUrl(const GURL& url, |
| 211 SubdomainPermission subdomain_permission, | 212 SubdomainPermission subdomain_permission, |
| 212 PortPermission port_permission) { | 213 PortPermission port_permission) { |
| 213 return IsValidURL(url, port_permission) && | 214 return IsValidURL(url, port_permission) && |
| 214 IsValidHostName(url.host(), "youtube", subdomain_permission); | 215 IsValidHostName(url.host(), "youtube", subdomain_permission); |
| 215 } | 216 } |
| 216 | 217 |
| 218 GoogleSearchMetrics::AccessPoint GetGoogleSearchAccessPointForSearchNavEntry( | |
| 219 const content::NavigationEntry& entry) { | |
| 220 DCHECK(google_util::IsGoogleSearchUrl(entry.GetURL())); | |
| 221 | |
| 222 // If the commit is a GENERATED commit with a Google search URL, we know it's | |
| 223 // an Omnibox search. | |
|
Peter Kasting
2014/06/20 01:23:18
Nit: This comment isn't quite accurate to the code
kmadhusu
2014/06/20 01:40:51
Done.
| |
| 224 if (entry.GetTransitionType() == (content::PAGE_TRANSITION_GENERATED | | |
| 225 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)) { | |
| 226 return GoogleSearchMetrics::AP_OMNIBOX; | |
| 227 } | |
| 228 | |
| 229 // The string "source=search_app" in the |entry| URL represents a Google | |
| 230 // search from the Google Search App. For all other cases that we have not yet | |
| 231 // implemented or care to measure, we log a generic "catch-all" metric. | |
| 232 return (entry.GetURL().query().find("source=search_app") != | |
| 233 std::string::npos) ? GoogleSearchMetrics::AP_SEARCH_APP : | |
| 234 GoogleSearchMetrics::AP_OTHER; | |
|
Peter Kasting
2014/06/20 01:23:19
Nit: I think this would be more readable split up:
kmadhusu
2014/06/20 01:40:51
Done.
| |
| 235 } | |
| 236 | |
| 217 } // namespace google_util | 237 } // namespace google_util |
| OLD | NEW |