Android Chromoting: Remove exit-fullscreen button.
[chromium-blink-merge.git] / components / rappor / rappor_utils.cc
blob311c75da66c0623bfefda5f696f3f566f2c1d786
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/rappor/rappor_utils.h"
7 #include "components/rappor/rappor_service.h"
8 #include "net/base/net_util.h"
9 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
10 #include "url/gurl.h"
12 namespace rappor {
14 std::string GetDomainAndRegistrySampleFromGURL(const GURL& gurl) {
15 if (gurl.SchemeIsHTTPOrHTTPS()) {
16 if (net::IsLocalhost(gurl.host()))
17 return "localhost";
18 if (gurl.HostIsIPAddress())
19 return "ip_address";
20 return net::registry_controlled_domains::GetDomainAndRegistry(
21 gurl, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
23 if (gurl.SchemeIsFile())
24 return gurl.scheme() + "://";
25 return gurl.scheme() + "://" + gurl.host();
28 void SampleDomainAndRegistryFromGURL(RapporService* rappor_service,
29 const std::string& metric,
30 const GURL& gurl) {
31 if (!rappor_service)
32 return;
33 rappor_service->RecordSample(
34 metric,
35 rappor::ETLD_PLUS_ONE_RAPPOR_TYPE,
36 GetDomainAndRegistrySampleFromGURL(gurl));
39 } // namespace rappor